소스 검색

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 년 전
부모
커밋
4d1c338f0b
3개의 변경된 파일37개의 추가작업 그리고 9개의 파일을 삭제
  1. 1
    1
      ios/RCCNavigationController.h
  2. 14
    0
      ios/RCCNavigationController.m
  3. 22
    8
      ios/RCCViewController.m

+ 1
- 1
ios/RCCNavigationController.h 파일 보기

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

+ 14
- 0
ios/RCCNavigationController.m 파일 보기

36
   
36
   
37
   self = [super initWithRootViewController:viewController];
37
   self = [super initWithRootViewController:viewController];
38
   if (!self) return nil;
38
   if (!self) return nil;
39
+  self.delegate = self;
39
   
40
   
40
   self.navigationBar.translucent = NO; // default
41
   self.navigationBar.translucent = NO; // default
41
   
42
   
76
       [mergedStyle removeObjectForKey:@"navBarBlur"];
77
       [mergedStyle removeObjectForKey:@"navBarBlur"];
77
       [mergedStyle removeObjectForKey:@"navBarTranslucent"];
78
       [mergedStyle removeObjectForKey:@"navBarTranslucent"];
78
       [mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
79
       [mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
80
+      [mergedStyle removeObjectForKey:@"statusBarTextColorSchemeSingleScreen"];
79
       
81
       
80
       [mergedStyle addEntriesFromDictionary:navigatorStyle];
82
       [mergedStyle addEntriesFromDictionary:navigatorStyle];
81
       navigatorStyle = mergedStyle;
83
       navigatorStyle = mergedStyle;
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
 @end
312
 @end

+ 22
- 8
ios/RCCViewController.m 파일 보기

233
     {
233
     {
234
         viewController.navigationController.navigationBar.tintColor = nil;
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
     else
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
     NSNumber *navBarHidden = self.navigatorStyle[@"navBarHidden"];
263
     NSNumber *navBarHidden = self.navigatorStyle[@"navBarHidden"];
250
     BOOL navBarHiddenBool = navBarHidden ? [navBarHidden boolValue] : NO;
264
     BOOL navBarHiddenBool = navBarHidden ? [navBarHidden boolValue] : NO;
251
     if (viewController.navigationController.navigationBarHidden != navBarHiddenBool)
265
     if (viewController.navigationController.navigationBarHidden != navBarHiddenBool)