From 714f8acf15da31db5ccb05d7957b5a392a6cbb4b Mon Sep 17 00:00:00 2001 From: Yedidya Kennard Date: Thu, 19 Mar 2026 18:53:50 +0200 Subject: [PATCH] Fix iOS bottom tab text colors regression --- ios/BottomTabsAppearancePresenter.mm | 9 ---- .../RNNBottomTabsAppearancePresenterTest.mm | 42 ++++++++++++++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ios/BottomTabsAppearancePresenter.mm b/ios/BottomTabsAppearancePresenter.mm index a92ff16fcd..20abab9004 100644 --- a/ios/BottomTabsAppearancePresenter.mm +++ b/ios/BottomTabsAppearancePresenter.mm @@ -111,15 +111,6 @@ - (void)applyTabBarAppearance:(UITabBarAppearance *)appearance { self.tabBar.scrollEdgeAppearance = [appearance copy]; } #endif - - for (UIViewController *childViewController in self.tabBarController.childViewControllers) { - childViewController.tabBarItem.standardAppearance = [appearance copy]; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 - if (@available(iOS 15.0, *)) { - childViewController.tabBarItem.scrollEdgeAppearance = [appearance copy]; - } -#endif - } } @end diff --git a/playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.mm b/playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.mm index a4c8973e16..46cd89f0e4 100644 --- a/playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.mm +++ b/playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.mm @@ -117,8 +117,46 @@ - (void)testBackgroundColor_validColor { - (void)testTabBarBackgroundColor { UIColor *tabBarBackgroundColor = [UIColor redColor]; [self.uut setTabBarBackgroundColor:tabBarBackgroundColor]; - XCTAssertTrue([self.children.lastObject.tabBarItem.standardAppearance.backgroundColor - isEqual:tabBarBackgroundColor]); + XCTAssertTrue( + [((UITabBarController *)self.boundViewController).tabBar.standardAppearance.backgroundColor + isEqual:tabBarBackgroundColor]); +} + +- (void)testSetTabBarBackgroundColor_shouldPreserveBottomTabTitleColors { + RNNNavigationOptions *options = [RNNNavigationOptions emptyOptions]; + options.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:@{ + @"text" : @"Home", + @"textColor" : @(0xFFFF0000), + @"selectedTextColor" : @(0xFF00FF00) + }]; + + BottomTabPresenter *bottomTabPresenter = + [BottomTabPresenterCreator createWithDefaultOptions:nil]; + UIViewController *child = self.children.lastObject; + [bottomTabPresenter applyOptions:options child:child]; + + [self.uut setTabBarBackgroundColor:UIColor.blueColor]; + + UIColor *normalColor = child.tabBarItem.standardAppearance.stackedLayoutAppearance.normal + .titleTextAttributes[NSForegroundColorAttributeName]; + UIColor *selectedColor = child.tabBarItem.standardAppearance.stackedLayoutAppearance.selected + .titleTextAttributes[NSForegroundColorAttributeName]; + + XCTAssertTrue([normalColor isEqual:UIColor.redColor]); + XCTAssertTrue([selectedColor isEqual:UIColor.greenColor]); +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 + if (@available(iOS 15.0, *)) { + UIColor *scrollEdgeNormalColor = + child.tabBarItem.scrollEdgeAppearance.stackedLayoutAppearance.normal + .titleTextAttributes[NSForegroundColorAttributeName]; + UIColor *scrollEdgeSelectedColor = + child.tabBarItem.scrollEdgeAppearance.stackedLayoutAppearance.selected + .titleTextAttributes[NSForegroundColorAttributeName]; + + XCTAssertTrue([scrollEdgeNormalColor isEqual:UIColor.redColor]); + XCTAssertTrue([scrollEdgeSelectedColor isEqual:UIColor.greenColor]); + } +#endif } - (void)testApplyOptions_applyTabBarShadowDefaultValues {