Skip to content

Commit a50bafa

Browse files
skv-headlessFacebook Github Bot
authored and
Facebook Github Bot
committed
badgeColor property
Summary: **motivation:** make possible to use new tab bar item property ![1476033023249](https://cloud.githubusercontent.com/assets/1488195/19222245/f4c1292c-8e64-11e6-8a29-7b95b45e153c.jpg) Closes #10315 Differential Revision: D4000011 Pulled By: mmmulani fbshipit-source-id: 5c00b0b5f56c551cc4151fcc030da6c8bc1a3649
1 parent 065af66 commit a50bafa

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Examples/UIExplorer/js/TabBarIOSExample.js

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class TabBarExample extends React.Component {
7373
<TabBarIOS.Item
7474
systemIcon="history"
7575
badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
76+
badgeColor="black"
7677
selected={this.state.selectedTab === 'redTab'}
7778
onPress={() => {
7879
this.setState({

Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var React = require('React');
1616
var StaticContainer = require('StaticContainer.react');
1717
var StyleSheet = require('StyleSheet');
1818
var View = require('View');
19+
var ColorPropType = require('ColorPropType');
1920

2021
var requireNativeComponent = require('requireNativeComponent');
2122

@@ -29,6 +30,10 @@ class TabBarItemIOS extends React.Component {
2930
React.PropTypes.string,
3031
React.PropTypes.number,
3132
]),
33+
/**
34+
* Background color for the badge. Available since iOS 10.
35+
*/
36+
badgeColor: ColorPropType,
3237
/**
3338
* Items comes with a few predefined system icons. Note that if you are
3439
* using them, the title and selectedIcon will be overridden with the

React/Views/RCTTabBarItem.m

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ - (void)setSelectedIcon:(UIImage *)selectedIcon
105105
}
106106
}
107107

108+
- (void)setBadgeColor:(UIColor *)bagdeColor
109+
{
110+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
111+
_barItem.badgeColor = bagdeColor;
112+
#endif
113+
}
114+
108115
- (UIViewController *)reactViewController
109116
{
110117
return self.superview.reactViewController;

React/Views/RCTTabBarItemManager.m

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ - (UIView *)view
2828
RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage)
2929
RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem)
3030
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
31+
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
3132
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
3233
{
3334
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;

0 commit comments

Comments
 (0)