Skip to content

Commit

Permalink
badgeColor property
Browse files Browse the repository at this point in the history
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
  • Loading branch information
skv-headless authored and Facebook Github Bot committed Nov 29, 2016
1 parent 065af66 commit a50bafa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Examples/UIExplorer/js/TabBarIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class TabBarExample extends React.Component {
<TabBarIOS.Item
systemIcon="history"
badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
badgeColor="black"
selected={this.state.selectedTab === 'redTab'}
onPress={() => {
this.setState({
Expand Down
5 changes: 5 additions & 0 deletions Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var React = require('React');
var StaticContainer = require('StaticContainer.react');
var StyleSheet = require('StyleSheet');
var View = require('View');
var ColorPropType = require('ColorPropType');

var requireNativeComponent = require('requireNativeComponent');

Expand All @@ -29,6 +30,10 @@ class TabBarItemIOS extends React.Component {
React.PropTypes.string,
React.PropTypes.number,
]),
/**
* Background color for the badge. Available since iOS 10.
*/
badgeColor: ColorPropType,
/**
* Items comes with a few predefined system icons. Note that if you are
* using them, the title and selectedIcon will be overridden with the
Expand Down
7 changes: 7 additions & 0 deletions React/Views/RCTTabBarItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ - (void)setSelectedIcon:(UIImage *)selectedIcon
}
}

- (void)setBadgeColor:(UIColor *)bagdeColor
{
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
_barItem.badgeColor = bagdeColor;
#endif
}

- (UIViewController *)reactViewController
{
return self.superview.reactViewController;
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTTabBarItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage)
RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
{
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;
Expand Down

0 comments on commit a50bafa

Please sign in to comment.