@@ -47,11 +47,34 @@ - (NSString *)description
4747 if (superDescription.length > 0 && [superDescription characterAtIndex: superDescription.length - 1 ] == ' >' ) {
4848 superDescription = [superDescription substringToIndex: superDescription.length - 1 ];
4949 }
50+
51+ #if TARGET_OS_IPHONE
52+ NSString *providerViewSafeAreaInsetsString = NSStringFromUIEdgeInsets(_providerView.safeAreaInsets );
53+ NSString *currentSafeAreaInsetsString = NSStringFromUIEdgeInsets(_currentSafeAreaInsets);
54+ #elif TARGET_OS_OSX
55+ NSString *providerViewSafeAreaInsetsString;
56+ NSString *currentSafeAreaInsetsString;
57+ if (@available (macOS 11.0 , *)) {
58+ providerViewSafeAreaInsetsString = [NSString stringWithFormat: @" {%f ,%f ,%f ,%f }" ,
59+ _providerView.safeAreaInsets.top,
60+ _providerView.safeAreaInsets.left,
61+ _providerView.safeAreaInsets.bottom,
62+ _providerView.safeAreaInsets.right];
63+ currentSafeAreaInsetsString = [NSString stringWithFormat: @" {%f ,%f ,%f ,%f }" ,
64+ _currentSafeAreaInsets.top,
65+ _currentSafeAreaInsets.left,
66+ _currentSafeAreaInsets.bottom,
67+ _currentSafeAreaInsets.right];
68+ } else {
69+ providerViewSafeAreaInsetsString = @" {0.0,0.0,0.0,0.0}" ;
70+ currentSafeAreaInsetsString = @" {0.0,0.0,0.0,0.0}" ;
71+ }
72+ #endif
5073
5174 return [NSString stringWithFormat: @" %@ ; RNCSafeAreaInsets = %@ ; appliedRNCSafeAreaInsets = %@ >" ,
5275 superDescription,
53- NSStringFromUIEdgeInsets (_providerView.safeAreaInsets) ,
54- NSStringFromUIEdgeInsets(_currentSafeAreaInsets) ];
76+ providerViewSafeAreaInsetsString ,
77+ currentSafeAreaInsetsString ];
5578}
5679
5780- (void )didMoveToWindow
@@ -80,12 +103,18 @@ - (void)updateStateIfNecessary
80103 if (_providerView == nil ) {
81104 return ;
82105 }
106+ #if TARGET_OS_IPHONE
83107 UIEdgeInsets safeAreaInsets = _providerView.safeAreaInsets ;
84108
85109 if (UIEdgeInsetsEqualToEdgeInsetsWithThreshold (safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale ())) {
86110 return ;
87111 }
88-
112+ #elif TARGET_OS_OSX
113+ NSEdgeInsets safeAreaInsets = _providerView.safeAreaInsets ;
114+ if (NSEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale ())) {
115+ return ;
116+ }
117+ #endif
89118 _currentSafeAreaInsets = safeAreaInsets;
90119 [self updateState ];
91120}
0 commit comments