Skip to content

Commit 82ab88b

Browse files
kligarskikkafar
authored andcommitted
feat(iOS, Tabs): add tabBarTintColor (#144)
This prop is useful for iOS 26, where `tabBarItemIconColor` is not enough - Liquid Glass tab bar has a glow that uses tintColor. Even though `tintColor` is marked in [`UITabBar` docs](https://developer.apple.com/documentation/uikit/uitabbar/tintcolor?language=objc) as "Legacy customization", I haven't found other way to change the color and `tintColor` is a normal property of [`UIView`](https://developer.apple.com/documentation/uikit/uiview/tintcolor?language=objc).
1 parent a684d5f commit 82ab88b

File tree

7 files changed

+17
-0
lines changed

7 files changed

+17
-0
lines changed

android/src/main/java/com/swmansion/rnscreens/gamma/tabs/TabsHostViewManager.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class TabsHostViewManager :
7878
value: String?,
7979
) = Unit
8080

81+
override fun setTabBarTintColor(
82+
view: TabsHost,
83+
value: Int?
84+
) = Unit
85+
8186
override fun setTabBarItemTitleFontSize(
8287
view: TabsHost?,
8388
value: Float,

apps/src/shared/gamma/containers/bottom-tabs/BottomTabsContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function BottomTabsContainer(props: BottomTabsContainerProps) {
8585
<BottomTabs
8686
onNativeFocusChange={onNativeFocusChangeCallback}
8787
tabBarBackgroundColor={Colors.NavyLight100}
88+
tabBarTintColor={Colors.YellowLight100}
8889
tabBarItemBadgeBackgroundColor={Colors.GreenDark100}
8990
tabBarItemIconColor={Colors.BlueLight40}
9091
experimentalControlNavigationStateInJS={

ios/bottom-tabs/RNSBottomTabsHostComponentView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
2727

2828
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarBackgroundColor;
2929
@property (nonatomic, strong, readonly, nullable) UIBlurEffect *tabBarBlurEffect;
30+
@property (nonatomic, strong, readonly, nullable) UIColor *tabBarTintColor;
3031

3132
@property (nonatomic, strong, readonly, nullable) NSString *tabBarItemTitleFontFamily;
3233
@property (nonatomic, strong, readonly, nullable) NSNumber *tabBarItemTitleFontSize;

ios/bottom-tabs/RNSBottomTabsHostComponentView.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ - (void)resetProps
6161
_props = defaultProps;
6262
_tabBarBlurEffect = nil;
6363
_tabBarBackgroundColor = nil;
64+
_tabBarTintColor = nil;
6465

6566
_tabBarItemTitleFontFamily = nil;
6667
_tabBarItemTitleFontSize = nil;
@@ -181,6 +182,11 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props
181182
_tabBarBlurEffect =
182183
rnscreens::conversion::RNSUIBlurEffectFromRNSBottomTabsTabBarBlurEffect(newComponentProps.tabBarBlurEffect);
183184
}
185+
186+
if (newComponentProps.tabBarTintColor != oldComponentProps.tabBarTintColor) {
187+
_needsTabBarAppearanceUpdate = YES;
188+
_tabBarTintColor = RCTUIColorFromSharedColor(newComponentProps.tabBarTintColor);
189+
}
184190

185191
if (newComponentProps.tabBarItemTitleFontFamily != oldComponentProps.tabBarItemTitleFontFamily) {
186192
_tabBarItemTitleFontFamily = RCTNSStringFromStringNilIfEmpty(newComponentProps.tabBarItemTitleFontFamily);

ios/bottom-tabs/RNSTabBarAppearanceCoordinator.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ - (void)updateAppearanceOfTabBar:(nullable UITabBar *)tabBar
3030
tabBar.standardAppearance = appearance;
3131
tabBar.scrollEdgeAppearance = appearance;
3232

33+
tabBar.tintColor = hostComponentView.tabBarTintColor;
34+
3335
// Step 4 - build the appearance object for each tab & apply it
3436
if (tabScreenCtrls == nil) {
3537
return;

src/components/BottomTabs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface BottomTabsProps extends ViewProps {
2626
// tabBarAppearance?: TabBarAppearance; // Does not work due to codegen issue.
2727
tabBarBackgroundColor?: ColorValue;
2828
tabBarBlurEffect?: BlurEffect; // defaults to 'none'
29+
tabBarTintColor?: ColorValue;
2930

3031
tabBarItemTitleFontFamily?: TextStyle['fontFamily'];
3132
tabBarItemTitleFontSize?: TextStyle['fontSize'];

src/fabric/BottomTabsNativeComponent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface NativeProps extends ViewProps {
5050
// tabBarAppearance?: TabBarAppearance; // Does not work due to codegen issue.
5151
tabBarBackgroundColor?: ColorValue;
5252
tabBarBlurEffect?: WithDefault<BlurEffect, 'none'>;
53+
tabBarTintColor?: ColorValue;
5354

5455
tabBarItemTitleFontFamily?: string;
5556
tabBarItemTitleFontSize?: Float;

0 commit comments

Comments
 (0)