Bladeren bron

add disabledButtonColor (#1842)

* add disabledButtonColor in order to set navigation button disabled color

* add disabledButtonColor to the docs
Ran Greenberg 7 jaren geleden
bovenliggende
commit
c62d944c2b
2 gewijzigde bestanden met toevoegingen van 11 en 0 verwijderingen
  1. 1
    0
      docs/styling-the-navigator.md
  2. 10
    0
      ios/RCCNavigationController.m

+ 1
- 0
docs/styling-the-navigator.md Bestand weergeven

@@ -71,6 +71,7 @@ this.props.navigator.setStyle({
71 71
   navBarSubtitleFontFamily: 'font-name', // subtitle font
72 72
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
73 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 76
   // iOS only
76 77
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes

+ 10
- 0
ios/RCCNavigationController.m Bestand weergeven

@@ -389,6 +389,16 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
389 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 402
     NSString *testID = button[@"testID"];
393 403
     if (testID)
394 404
     {