Browse Source

customize tab badge color (#1932)

Bernabé González 7 years ago
parent
commit
2252ac1dde

+ 2
- 1
docs/screen-api.md View File

219
 ```js
219
 ```js
220
 this.props.navigator.setTabBadge({
220
 this.props.navigator.setTabBadge({
221
   tabIndex: 0, // (optional) if missing, the badge will be added to this screen's tab
221
   tabIndex: 0, // (optional) if missing, the badge will be added to this screen's tab
222
-  badge: 17 // badge value, null to remove badge
222
+  badge: 17, // badge value, null to remove badge
223
+  badgeColor: '#006400', // (optional) if missing, the badge will use the default color
223
 });
224
 });
224
 ```
225
 ```
225
 ## setTabButton(params = {})
226
 ## setTabButton(params = {})

+ 3
- 0
ios/RCCTabBarController.m View File

263
       }
263
       }
264
       else
264
       else
265
       {
265
       {
266
+        NSString *badgeColor = actionParams[@"badgeColor"];
267
+        UIColor *color = badgeColor != (id)[NSNull null] ? [RCTConvert UIColor:badgeColor] : nil;
268
+        viewController.tabBarItem.badgeColor = color;
266
         viewController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%@", badge];
269
         viewController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%@", badge];
267
       }
270
       }
268
     }
271
     }

+ 1
- 0
src/deprecated/controllers/index.js View File

244
         return RCCManager.TabBarControllerIOS(id, "setTabBarHidden", params);
244
         return RCCManager.TabBarControllerIOS(id, "setTabBarHidden", params);
245
       },
245
       },
246
       setBadge: function (params) {
246
       setBadge: function (params) {
247
+        _processProperties(params);
247
         return RCCManager.TabBarControllerIOS(id, "setBadge", params);
248
         return RCCManager.TabBarControllerIOS(id, "setBadge", params);
248
       },
249
       },
249
       switchTo: function (params) {
250
       switchTo: function (params) {

+ 2
- 1
src/deprecated/platformSpecificDeprecated.ios.js View File

384
   if (params.tabIndex || params.tabIndex === 0) {
384
   if (params.tabIndex || params.tabIndex === 0) {
385
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
385
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
386
       tabIndex: params.tabIndex,
386
       tabIndex: params.tabIndex,
387
-      badge: params.badge
387
+      badge: params.badge,
388
+      badgeColor: params.badgeColor
388
     });
389
     });
389
   } else {
390
   } else {
390
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({
391
     Controllers.TabBarControllerIOS(controllerID + '_tabs').setBadge({