Browse Source

Make sure insets are sent initially when zero

Janic Duplessis 5 years ago
parent
commit
9b23dea23c
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      ios/SafeAreaView/RNCSafeAreaView.m

+ 4
- 4
ios/SafeAreaView/RNCSafeAreaView.m View File

16
 @implementation RNCSafeAreaView
16
 @implementation RNCSafeAreaView
17
 {
17
 {
18
   UIEdgeInsets _currentSafeAreaInsets;
18
   UIEdgeInsets _currentSafeAreaInsets;
19
+  BOOL _initialInsetsSent;
19
 }
20
 }
20
 
21
 
21
 - (BOOL)isSupportedByOS
22
 - (BOOL)isSupportedByOS
69
 {
70
 {
70
   UIEdgeInsets safeAreaInsets = [self realOrEmulateSafeAreaInsets];
71
   UIEdgeInsets safeAreaInsets = [self realOrEmulateSafeAreaInsets];
71
 
72
 
72
-  if (UIEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale())) {
73
+  if (_initialInsetsSent && UIEdgeInsetsEqualToEdgeInsetsWithThreshold(safeAreaInsets, _currentSafeAreaInsets, 1.0 / RCTScreenScale())) {
73
     return;
74
     return;
74
   }
75
   }
75
 
76
 
77
+  _initialInsetsSent = YES;
76
   _currentSafeAreaInsets = safeAreaInsets;
78
   _currentSafeAreaInsets = safeAreaInsets;
77
 
79
 
78
   self.onInsetsChange(@{
80
   self.onInsetsChange(@{
89
 {
91
 {
90
   [super layoutSubviews];
92
   [super layoutSubviews];
91
 
93
 
92
-  if (!self.isSupportedByOS) {
93
-    [self invalidateSafeAreaInsets];
94
-  }
94
+  [self invalidateSafeAreaInsets];
95
 }
95
 }
96
 
96
 
97
 @end
97
 @end