Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ public void setStyleFromScreen(StyleParams params) {
}

public void setTabButton(ScreenParams params, Integer index) {
if (params.tabIcon != null) {
if (params.tabIcon != null || params.tabLabel != null) {
AHBottomNavigationItem item = this.getItem(index);
item.setDrawable(params.tabIcon);
refresh();
boolean tabNeedsRefresh = false;

if (params.tabIcon != null) {
item.setDrawable(params.tabIcon);
tabNeedsRefresh = true;
}
if (params.tabLabel != null) {
item.setTitle(params.tabLabel);
tabNeedsRefresh = true;
}

if (tabNeedsRefresh) {
this.refresh();
}
}
}

Expand All @@ -76,7 +88,7 @@ private void setTitlesDisplayState() {

private boolean hasTabsWithLabels() {
for (int i = 0; i < getItemsCount(); i++) {
String title = getItem(0).getTitle(getContext());
String title = getItem(i).getTitle(getContext());
if (!TextUtils.isEmpty(title)) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions docs/screen-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ this.props.navigator.setTabButton({
tabIndex: 0, // (optional) if missing, the icon will be added to this screen's tab
icon: require('../img/one.png'), // local image asset for the tab icon unselected state (optional)
selectedIcon: require('../img/one_selected.png'), // local image asset for the tab icon selected state (optional, iOS only)
label: 'New Label' // tab label that appears under the icon (optional)
});
```

Expand Down
8 changes: 7 additions & 1 deletion ios/RCCTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,21 @@ - (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actio
iconImage = [RCTConvert UIImage:icon];
iconImage = [[self image:iconImage withColor:self.tabBar.tintColor] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
viewController.tabBarItem.image = iconImage;

}

UIImage *iconImageSelected = nil;
id selectedIcon = actionParams[@"selectedIcon"];
if (selectedIcon && selectedIcon != (id)[NSNull null])
{
iconImageSelected = [RCTConvert UIImage:selectedIcon];
viewController.tabBarItem.selectedImage = iconImageSelected;
}

id label = actionParams[@"label"];
if (label && label != (id)[NSNull null])
{
viewController.tabBarItem.title = label;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/deprecated/platformSpecificDeprecated.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,16 @@ function navigatorSetTabButton(navigator, params) {
Controllers.TabBarControllerIOS(controllerID + '_tabs').setTabButton({
tabIndex: params.tabIndex,
icon: params.icon,
selectedIcon: params.selectedIcon
selectedIcon: params.selectedIcon,
label: params.label,
});
} else {
Controllers.TabBarControllerIOS(controllerID + '_tabs').setTabButton({
contentId: navigator.navigatorID,
contentType: 'NavigationControllerIOS',
icon: params.icon,
selectedIcon: params.selectedIcon
selectedIcon: params.selectedIcon,
label: params.label,
});
}
}
Expand Down