Browse Source

added status bar color scheme for single screen which isn't pass on p… (#608)

* added status bar color scheme for single screen which isn't pass on push. Set "statusBarTextColorSchemeSingleScreen" on the navigatorStyle

* make statusBarTextColorSchemeSingleScreen preferred option when both statusBarTextColorScheme and statusBarTextColorSchemeSingleScreen are exists
Ran 7 years ago
parent
commit
4d1c338f0b
3 changed files with 37 additions and 9 deletions
  1. 1
    1
      ios/RCCNavigationController.h
  2. 14
    0
      ios/RCCNavigationController.m
  3. 22
    8
      ios/RCCViewController.m

+ 1
- 1
ios/RCCNavigationController.h View File

@@ -1,7 +1,7 @@
1 1
 #import <UIKit/UIKit.h>
2 2
 #import "RCTBridge.h"
3 3
 
4
-@interface RCCNavigationController : UINavigationController
4
+@interface RCCNavigationController : UINavigationController <UINavigationControllerDelegate>
5 5
 
6 6
 - (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge;
7 7
 - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge;

+ 14
- 0
ios/RCCNavigationController.m View File

@@ -36,6 +36,7 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
36 36
   
37 37
   self = [super initWithRootViewController:viewController];
38 38
   if (!self) return nil;
39
+  self.delegate = self;
39 40
   
40 41
   self.navigationBar.translucent = NO; // default
41 42
   
@@ -76,6 +77,7 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
76 77
       [mergedStyle removeObjectForKey:@"navBarBlur"];
77 78
       [mergedStyle removeObjectForKey:@"navBarTranslucent"];
78 79
       [mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
80
+      [mergedStyle removeObjectForKey:@"statusBarTextColorSchemeSingleScreen"];
79 81
       
80 82
       [mergedStyle addEntriesFromDictionary:navigatorStyle];
81 83
       navigatorStyle = mergedStyle;
@@ -294,5 +296,17 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
294 296
   
295 297
 }
296 298
 
299
+- (UIStatusBarStyle)preferredStatusBarStyle {
300
+  return [self.topViewController preferredStatusBarStyle];
301
+}
302
+
303
+
304
+#pragma mark - UINavigationControllerDelegate
305
+
306
+
307
+-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
308
+  [viewController setNeedsStatusBarAppearanceUpdate];
309
+}
310
+
297 311
 
298 312
 @end

+ 22
- 8
ios/RCCViewController.m View File

@@ -233,19 +233,33 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
233 233
     {
234 234
         viewController.navigationController.navigationBar.tintColor = nil;
235 235
     }
236
-    
237
-    NSString *statusBarTextColorScheme = self.navigatorStyle[@"statusBarTextColorScheme"];
238
-    if (statusBarTextColorScheme && [statusBarTextColorScheme isEqualToString:@"light"])
236
+  
237
+    NSString *statusBarTextColorSchemeSingleScreen = self.navigatorStyle[@"statusBarTextColorSchemeSingleScreen"];
238
+    if (statusBarTextColorSchemeSingleScreen && [statusBarTextColorSchemeSingleScreen isEqualToString:@"light"])
239 239
     {
240
-        viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
241
-        self._statusBarTextColorSchemeLight = YES;
240
+      self._statusBarTextColorSchemeLight = YES;
242 241
     }
243 242
     else
244 243
     {
245
-        viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
246
-        self._statusBarTextColorSchemeLight = NO;
244
+      self._statusBarTextColorSchemeLight = NO;
247 245
     }
248
-    
246
+  
247
+    // incase statusBarTextColorSchemeSingleScreen exists ignore the statusBarTextColorScheme which more globaly
248
+    if (!statusBarTextColorSchemeSingleScreen) {
249
+      NSString *statusBarTextColorScheme = self.navigatorStyle[@"statusBarTextColorScheme"];
250
+      if (statusBarTextColorScheme && [statusBarTextColorScheme isEqualToString:@"light"] && !statusBarTextColorSchemeSingleScreen)
251
+      {
252
+          viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
253
+          self._statusBarTextColorSchemeLight = YES;
254
+        
255
+      }
256
+      else
257
+      {
258
+          viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
259
+          self._statusBarTextColorSchemeLight = NO;
260
+      }
261
+    }
262
+  
249 263
     NSNumber *navBarHidden = self.navigatorStyle[@"navBarHidden"];
250 264
     BOOL navBarHiddenBool = navBarHidden ? [navBarHidden boolValue] : NO;
251 265
     if (viewController.navigationController.navigationBarHidden != navBarHiddenBool)