Browse Source

add disabledButtonColor (#1842)

* add disabledButtonColor in order to set navigation button disabled color

* add disabledButtonColor to the docs
Ran Greenberg 7 years ago
parent
commit
c62d944c2b
2 changed files with 11 additions and 0 deletions
  1. 1
    0
      docs/styling-the-navigator.md
  2. 10
    0
      ios/RCCNavigationController.m

+ 1
- 0
docs/styling-the-navigator.md View File

71
   navBarSubtitleFontFamily: 'font-name', // subtitle font
71
   navBarSubtitleFontFamily: 'font-name', // subtitle font
72
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
72
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
73
   orientation: 'portrait' // Sets a specific orientation to a modal and all screens pushed to it. Default: 'auto'. Supported values: 'auto', 'landscape', 'portrait'
73
   orientation: 'portrait' // Sets a specific orientation to a modal and all screens pushed to it. Default: 'auto'. Supported values: 'auto', 'landscape', 'portrait'
74
+  disabledButtonColor: '#ff0000' // chnaged the navigation bar button text color when disabled.
74
   
75
   
75
   // iOS only
76
   // iOS only
76
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes
77
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes

+ 10
- 0
ios/RCCNavigationController.m View File

389
       [barButtonItem setImage:[barButtonItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
389
       [barButtonItem setImage:[barButtonItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
390
     }
390
     }
391
     
391
     
392
+    if ([viewController isKindOfClass:[RCCViewController class]]) {
393
+      RCCViewController *rccViewController = ((RCCViewController*)viewController);
394
+      NSDictionary *navigatorStyle = rccViewController.navigatorStyle;
395
+      id disabledButtonColor = navigatorStyle[@"disabledButtonColor"];
396
+      if (disabledButtonColor) {
397
+        UIColor *color = [RCTConvert UIColor:disabledButtonColor];
398
+        [barButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName : color} forState:UIControlStateDisabled];
399
+      }
400
+    }
401
+    
392
     NSString *testID = button[@"testID"];
402
     NSString *testID = button[@"testID"];
393
     if (testID)
403
     if (testID)
394
     {
404
     {