Selaa lähdekoodia

Make sure insets are sent initially when zero

Janic Duplessis 5 vuotta sitten
vanhempi
commit
9b23dea23c
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4
    4
      ios/SafeAreaView/RNCSafeAreaView.m

+ 4
- 4
ios/SafeAreaView/RNCSafeAreaView.m Näytä tiedosto

@@ -16,6 +16,7 @@ static BOOL UIEdgeInsetsEqualToEdgeInsetsWithThreshold(UIEdgeInsets insets1, UIE
16 16
 @implementation RNCSafeAreaView
17 17
 {
18 18
   UIEdgeInsets _currentSafeAreaInsets;
19
+  BOOL _initialInsetsSent;
19 20
 }
20 21
 
21 22
 - (BOOL)isSupportedByOS
@@ -69,10 +70,11 @@ static BOOL UIEdgeInsetsEqualToEdgeInsetsWithThreshold(UIEdgeInsets insets1, UIE
69 70
 {
70 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 74
     return;
74 75
   }
75 76
 
77
+  _initialInsetsSent = YES;
76 78
   _currentSafeAreaInsets = safeAreaInsets;
77 79
 
78 80
   self.onInsetsChange(@{
@@ -89,9 +91,7 @@ static BOOL UIEdgeInsetsEqualToEdgeInsetsWithThreshold(UIEdgeInsets insets1, UIE
89 91
 {
90 92
   [super layoutSubviews];
91 93
 
92
-  if (!self.isSupportedByOS) {
93
-    [self invalidateSafeAreaInsets];
94
-  }
94
+  [self invalidateSafeAreaInsets];
95 95
 }
96 96
 
97 97
 @end