Skip to content

Commit 56ec5f8

Browse files
Fix iOS bottom tab text colors regression (#8255)
Co-authored-by: mark.dev <50657916+markdevocht@users.noreply.github.com>
1 parent d16f85b commit 56ec5f8

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

ios/BottomTabsAppearancePresenter.mm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,6 @@ - (void)applyTabBarAppearance:(UITabBarAppearance *)appearance {
111111
self.tabBar.scrollEdgeAppearance = [appearance copy];
112112
}
113113
#endif
114-
115-
for (UIViewController *childViewController in self.tabBarController.childViewControllers) {
116-
childViewController.tabBarItem.standardAppearance = [appearance copy];
117-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
118-
if (@available(iOS 15.0, *)) {
119-
childViewController.tabBarItem.scrollEdgeAppearance = [appearance copy];
120-
}
121-
#endif
122-
}
123114
}
124115

125116
@end

playground/ios/NavigationTests/RNNBottomTabsAppearancePresenterTest.mm

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,46 @@ - (void)testBackgroundColor_validColor {
117117
- (void)testTabBarBackgroundColor {
118118
UIColor *tabBarBackgroundColor = [UIColor redColor];
119119
[self.uut setTabBarBackgroundColor:tabBarBackgroundColor];
120-
XCTAssertTrue([self.children.lastObject.tabBarItem.standardAppearance.backgroundColor
121-
isEqual:tabBarBackgroundColor]);
120+
XCTAssertTrue(
121+
[((UITabBarController *)self.boundViewController).tabBar.standardAppearance.backgroundColor
122+
isEqual:tabBarBackgroundColor]);
123+
}
124+
125+
- (void)testSetTabBarBackgroundColor_shouldPreserveBottomTabTitleColors {
126+
RNNNavigationOptions *options = [RNNNavigationOptions emptyOptions];
127+
options.bottomTab = [[RNNBottomTabOptions alloc] initWithDict:@{
128+
@"text" : @"Home",
129+
@"textColor" : @(0xFFFF0000),
130+
@"selectedTextColor" : @(0xFF00FF00)
131+
}];
132+
133+
BottomTabPresenter *bottomTabPresenter =
134+
[BottomTabPresenterCreator createWithDefaultOptions:nil];
135+
UIViewController *child = self.children.lastObject;
136+
[bottomTabPresenter applyOptions:options child:child];
137+
138+
[self.uut setTabBarBackgroundColor:UIColor.blueColor];
139+
140+
UIColor *normalColor = child.tabBarItem.standardAppearance.stackedLayoutAppearance.normal
141+
.titleTextAttributes[NSForegroundColorAttributeName];
142+
UIColor *selectedColor = child.tabBarItem.standardAppearance.stackedLayoutAppearance.selected
143+
.titleTextAttributes[NSForegroundColorAttributeName];
144+
145+
XCTAssertTrue([normalColor isEqual:UIColor.redColor]);
146+
XCTAssertTrue([selectedColor isEqual:UIColor.greenColor]);
147+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
148+
if (@available(iOS 15.0, *)) {
149+
UIColor *scrollEdgeNormalColor =
150+
child.tabBarItem.scrollEdgeAppearance.stackedLayoutAppearance.normal
151+
.titleTextAttributes[NSForegroundColorAttributeName];
152+
UIColor *scrollEdgeSelectedColor =
153+
child.tabBarItem.scrollEdgeAppearance.stackedLayoutAppearance.selected
154+
.titleTextAttributes[NSForegroundColorAttributeName];
155+
156+
XCTAssertTrue([scrollEdgeNormalColor isEqual:UIColor.redColor]);
157+
XCTAssertTrue([scrollEdgeSelectedColor isEqual:UIColor.greenColor]);
158+
}
159+
#endif
122160
}
123161

124162
- (void)testApplyOptions_applyTabBarShadowDefaultValues {

0 commit comments

Comments
 (0)