Skip to content
Merged

fix #8258

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
5 changes: 4 additions & 1 deletion ios/BottomTabPresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ - (void)mergeOptions:(RNNNavigationOptions *)mergeOptions

- (void)createTabBarItem:(UIViewController *)child
bottomTabOptions:(RNNBottomTabOptions *)bottomTabOptions {
child.tabBarItem = [_tabCreator createTabBarItem:bottomTabOptions mergeItem:child.tabBarItem];
UITabBarItem *updatedItem = [_tabCreator createTabBarItem:bottomTabOptions mergeItem:child.tabBarItem];
if (updatedItem != child.tabBarItem) {
child.tabBarItem = updatedItem;
}
}

@end
2 changes: 1 addition & 1 deletion ios/RNNTabBarItemCreator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@implementation RNNTabBarItemCreator

- (UITabBarItem *)createTabBarItem:(UITabBarItem *)mergeItem {
return [UITabBarItem new];
return mergeItem ?: [UITabBarItem new];
}

- (UITabBarItem *)createTabBarItem:(RNNBottomTabOptions *)bottomTabOptions
Expand Down
6 changes: 3 additions & 3 deletions playground/ios/NavigationTests/BottomTabPresenterTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (void)testMergeOptions_shouldSetTabBarItemColorWithDefaultOptions {
XCTAssertEqual(self.componentViewController.tabBarItem.title, @"title");
}

- (void)testMergeOptions_shouldCreateNewTabBarItemInstance {
- (void)testMergeOptions_shouldReuseExistingTabBarItemInstance {
RNNNavigationOptions *defaultOptions = [RNNNavigationOptions emptyOptions];
defaultOptions.bottomTab.selectedIconColor = [Color withColor:UIColor.greenColor];
self.uut.defaultOptions = defaultOptions;
Expand All @@ -69,8 +69,8 @@ - (void)testMergeOptions_shouldCreateNewTabBarItemInstance {
[self.uut mergeOptions:mergeOptions
resolvedOptions:self.options
child:self.componentViewController];
UITabBarItem *newTabBarItem = self.componentViewController.tabBarItem;
XCTAssertNotEqual(currentTabBarItem, newTabBarItem);
UITabBarItem *updatedTabBarItem = self.componentViewController.tabBarItem;
XCTAssertEqual(currentTabBarItem, updatedTabBarItem);
}

@end