Skip to content

Commit f9a685c

Browse files
Refactor: Update getTabIconFill function to accept an object for parameters and simplify last route retrieval logic
1 parent 0a15436 commit f9a685c

5 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/components/Navigation/NavigationTabBar/SearchTabButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function SearchTabButton({selectedTab, isWideLayout}: SearchTabButtonProps) {
105105
<View>
106106
<Icon
107107
src={expensifyIcons.MoneySearch}
108-
fill={getTabIconFill(theme, selectedTab === NAVIGATION_TABS.SEARCH, hovered)}
108+
fill={getTabIconFill(theme, {isSelected: selectedTab === NAVIGATION_TABS.SEARCH, isHovered: hovered})}
109109
width={variables.iconBottomBar}
110110
height={variables.iconBottomBar}
111111
/>

src/components/Navigation/NavigationTabBar/WorkspacesTabButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function WorkspacesTabButton({selectedTab, isWideLayout}: WorkspacesTabButtonPro
109109
<View>
110110
<Icon
111111
src={expensifyIcons.Buildings}
112-
fill={getTabIconFill(theme, selectedTab === NAVIGATION_TABS.WORKSPACES, hovered)}
112+
fill={getTabIconFill(theme, {isSelected: selectedTab === NAVIGATION_TABS.WORKSPACES, isHovered: hovered})}
113113
width={variables.iconBottomBar}
114114
height={variables.iconBottomBar}
115115
/>

src/components/Navigation/NavigationTabBar/getLastRoute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {Screen} from '@src/SCREENS';
66

77
function getLastRoute(rootState: NavigationState, navigator: ValueOf<typeof NAVIGATORS>, screen: Screen) {
88
const lastNavigator = rootState.routes.findLast((route) => route.name === navigator);
9-
const lastNavigatorState = lastNavigator && lastNavigator.key ? getPreservedNavigatorState(lastNavigator?.key) : undefined;
9+
const lastNavigatorState = lastNavigator?.key ? getPreservedNavigatorState(lastNavigator.key) : undefined;
1010
const lastRoute = lastNavigatorState?.routes.findLast((route) => route.name === screen);
1111
return lastRoute;
1212
}

src/components/Navigation/NavigationTabBar/getTabIconFill.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type {ThemeColors} from '@styles/theme/types';
22

3-
function getTabIconFill(theme: ThemeColors, isSelected: boolean, isHovered: boolean): string {
3+
type GetTabIconFillConfig = {
4+
isSelected: boolean;
5+
isHovered: boolean;
6+
};
7+
8+
function getTabIconFill(theme: ThemeColors, {isSelected, isHovered}: GetTabIconFillConfig): string {
49
if (isSelected) {
510
return theme.iconMenu;
611
}

src/components/Navigation/NavigationTabBar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function NavigationTabBar({selectedTab, isTopLevelBar = false, shouldShowFloatin
178178
<View>
179179
<Icon
180180
src={expensifyIcons.Home}
181-
fill={getTabIconFill(theme, selectedTab === NAVIGATION_TABS.HOME, hovered)}
181+
fill={getTabIconFill(theme, {isSelected: selectedTab === NAVIGATION_TABS.HOME, isHovered: hovered})}
182182
width={variables.iconBottomBar}
183183
height={variables.iconBottomBar}
184184
/>
@@ -211,7 +211,7 @@ function NavigationTabBar({selectedTab, isTopLevelBar = false, shouldShowFloatin
211211
<View>
212212
<Icon
213213
src={expensifyIcons.Inbox}
214-
fill={getTabIconFill(theme, selectedTab === NAVIGATION_TABS.INBOX, hovered)}
214+
fill={getTabIconFill(theme, {isSelected: selectedTab === NAVIGATION_TABS.INBOX, isHovered: hovered})}
215215
width={variables.iconBottomBar}
216216
height={variables.iconBottomBar}
217217
/>

0 commit comments

Comments
 (0)