From 2958fd1021d81fb8bb107b1edb97d6463c2ecd85 Mon Sep 17 00:00:00 2001 From: Lidor Dafna Date: Tue, 26 Apr 2022 12:02:38 +0300 Subject: [PATCH] Fix/ TabBar backgroundColor --- src/components/tabController/TabBar.tsx | 10 +++++++++- src/components/tabController/TabBarItem.tsx | 7 ++++++- .../tabController/apis/tabBarItem.api.json | 16 ++++++++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/components/tabController/TabBar.tsx b/src/components/tabController/TabBar.tsx index d170a54798..17ae2b07f0 100644 --- a/src/components/tabController/TabBar.tsx +++ b/src/components/tabController/TabBar.tsx @@ -5,7 +5,13 @@ import _ from 'lodash'; import TabBarContext from './TabBarContext'; import TabBarItem, {TabControllerItemProps} from './TabBarItem'; -import {Constants, asBaseComponent, forwardRef, BaseComponentInjectedProps, ForwardRefInjectedProps} from '../../commons/new'; +import { + Constants, + asBaseComponent, + forwardRef, + BaseComponentInjectedProps, + ForwardRefInjectedProps +} from '../../commons/new'; import View from '../view'; import {Colors, Spacings, Typography} from '../../style'; import FadedScrollView from '../fadedScrollView'; @@ -210,6 +216,7 @@ const TabBar = (props: Props) => { uppercase={uppercase} iconColor={iconColor} selectedIconColor={selectedIconColor} + backgroundColor={backgroundColor} activeBackgroundColor={activeBackgroundColor} {...item} {...context} @@ -228,6 +235,7 @@ const TabBar = (props: Props) => { uppercase, iconColor, selectedIconColor, + backgroundColor, activeBackgroundColor, centerSelected, onItemLayout diff --git a/src/components/tabController/TabBarItem.tsx b/src/components/tabController/TabBarItem.tsx index aaad870e74..04ed9f2f6b 100644 --- a/src/components/tabController/TabBarItem.tsx +++ b/src/components/tabController/TabBarItem.tsx @@ -78,6 +78,10 @@ export interface TabControllerItemProps { * The active opacity when pressing a tab */ activeOpacity?: number; + /** + * Apply background color for the tab bar item + */ + backgroundColor?: string; /** * TODO: rename to feedbackColor * Apply background color on press for TouchableOpacity @@ -118,6 +122,7 @@ export default function TabBarItem({ trailingAccessory, uppercase, activeOpacity = 0.9, + backgroundColor = Colors.$backgroundElevated, activeBackgroundColor, testID, ignore, @@ -192,8 +197,8 @@ export default function TabBarItem({ // @ts-expect-error ref={itemRef} style={_style} - bg-$backgroundElevated onLayout={onLayout} + backgroundColor={backgroundColor} activeBackgroundColor={activeBackgroundColor} activeOpacity={activeOpacity} onPress={onPress} diff --git a/src/components/tabController/apis/tabBarItem.api.json b/src/components/tabController/apis/tabBarItem.api.json index 925aa537d9..932b249243 100644 --- a/src/components/tabController/apis/tabBarItem.api.json +++ b/src/components/tabController/apis/tabBarItem.api.json @@ -9,7 +9,12 @@ {"name": "labelStyle;", "type": "TextStyle", "description": "Custom label style"}, {"name": "selectedLabelStyle", "type": "TextStyle", "description": "Custom selected label style"}, {"name": "labelColor", "type": "string", "description": "The default label color", "default": "Colors.black"}, - {"name": "selectedLabelColor", "type": "string", "description": "The selected label color", "default": "Colors.primary"}, + { + "name": "selectedLabelColor", + "type": "string", + "description": "The selected label color", + "default": "Colors.primary" + }, {"name": "icon", "type": "number", "description": "Icon of the tab"}, {"name": "iconColor", "type": "string", "description": "Icon tint color"}, {"name": "selectedIconColor", "type": "string", "description": "Icon selected tint color"}, @@ -21,6 +26,11 @@ {"name": "onPress", "type": "(index: number) => void", "description": "Callback for when pressing a tab"}, {"name": "uppercase", "type": "boolean", "description": "Whether to change the text to uppercase"}, {"name": "activeOpacity", "type": "number", "description": "The active opacity when pressing a tab"}, + { + "name": "backgroundColor", + "type": "string", + "description": " Apply background color for the tab bar item" + }, { "name": "activeBackgroundColor", "type": "string", @@ -29,7 +39,5 @@ {"name": "style", "type": "ViewStyle", "description": "Pass custom style"}, {"name": "testID", "type": "string", "description": "Used as a testing identifier"} ], - "snippet": [ - "" - ] + "snippet": [""] }