-
Notifications
You must be signed in to change notification settings - Fork 3.9k
NavigationTabBar: Add dummy component #63242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 6 commits into
Expensify:main
from
callstack-internal:perf/navigation-tab-bar-dummy
Jun 5, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf201b1
NavigationTabBar: add dummy component
kacper-mikolajczak a0346fa
NavigationTabBar: use memo for dummy
kacper-mikolajczak 13a055a
NavigationTabBarDummy: remove tooltips
kacper-mikolajczak 8af225a
Merge branch 'main' into perf/navigation-tab-bar-dummy
kacper-mikolajczak 82d4501
NavigationTabBarDummy: add RBR indicator support
kacper-mikolajczak c4d5a6a
WorkspacesListPage: fix prettier
kacper-mikolajczak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
299 changes: 299 additions & 0 deletions
299
src/components/Navigation/NavigationTabBar/NavigationTabBarDummy.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,299 @@ | ||
| import React, {memo, useEffect, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {ValueOf} from 'type-fest'; | ||
| import FloatingActionButton from '@components/FloatingActionButton'; | ||
| import HeaderGap from '@components/HeaderGap'; | ||
| import Icon from '@components/Icon'; | ||
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import ImageSVG from '@components/ImageSVG'; | ||
| import {PressableWithFeedback} from '@components/Pressable'; | ||
| import Text from '@components/Text'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import {useSidebarOrderedReports} from '@hooks/useSidebarOrderedReports'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus'; | ||
| import type {BrickRoad} from '@libs/WorkspacesSettingsUtils'; | ||
| import {getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils'; | ||
| import NavigationTabBarAvatar from '@pages/home/sidebar/NavigationTabBarAvatar'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import NAVIGATION_TABS from './NAVIGATION_TABS'; | ||
|
|
||
| const noop = () => undefined; | ||
|
|
||
| function NavigationTabBarWideDummy({selectedTab}: {selectedTab: ValueOf<typeof NAVIGATION_TABS>}) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const {translate} = useLocalize(); | ||
| const {indicatorColor: workspacesTabIndicatorColor, status: workspacesTabIndicatorStatus} = useWorkspacesTabIndicatorStatus(); | ||
| const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(undefined); | ||
| const {orderedReports} = useSidebarOrderedReports(); | ||
| const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (value) => value?.reports, canBeMissing: true}); | ||
|
|
||
| useEffect(() => { | ||
| setChatTabBrickRoad(getChatTabBrickRoad(orderedReports)); | ||
| // We need to get a new brick road state when report attributes are updated, otherwise we'll be showing an outdated brick road. | ||
| // That's why reportAttributes is added as a dependency here | ||
| }, [orderedReports, reportAttributes]); | ||
|
|
||
| return ( | ||
| <View style={styles.leftNavigationTabBarContainer}> | ||
| <HeaderGap /> | ||
| <View style={styles.flex1}> | ||
| <PressableWithFeedback | ||
| accessibilityRole={CONST.ROLE.BUTTON} | ||
| accessibilityLabel="Home" | ||
| accessible={false} | ||
| testID="ExpensifyLogoButton" | ||
| onPress={noop} | ||
| wrapperStyle={styles.leftNavigationTabBarItem} | ||
| > | ||
| <ImageSVG | ||
| style={StyleUtils.getAvatarStyle(CONST.AVATAR_SIZE.DEFAULT)} | ||
| src={Expensicons.ExpensifyAppIcon} | ||
| /> | ||
| </PressableWithFeedback> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.inbox')} | ||
| style={styles.leftNavigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.Inbox} | ||
| fill={selectedTab === NAVIGATION_TABS.HOME ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| {!!chatTabBrickRoad && ( | ||
| <View style={styles.navigationTabBarStatusIndicator(chatTabBrickRoad === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO ? theme.iconSuccessFill : theme.danger)} /> | ||
| )} | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.HOME ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.inbox')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.reports')} | ||
| style={styles.leftNavigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.MoneySearch} | ||
| fill={selectedTab === NAVIGATION_TABS.SEARCH ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.SEARCH ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.reports')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.workspacesTabTitle')} | ||
| style={styles.leftNavigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.Buildings} | ||
| fill={selectedTab === NAVIGATION_TABS.WORKSPACES ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| {!!workspacesTabIndicatorStatus && <View style={styles.navigationTabBarStatusIndicator(workspacesTabIndicatorColor)} />} | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.WORKSPACES ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.workspacesTabTitle')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <NavigationTabBarAvatar | ||
| style={styles.leftNavigationTabBarItem} | ||
| isSelected={selectedTab === NAVIGATION_TABS.SETTINGS} | ||
| onPress={noop} | ||
| /> | ||
| </View> | ||
| <View style={styles.leftNavigationTabBarItem}> | ||
| <FloatingActionButton | ||
| onPress={noop} | ||
| isActive={false} | ||
| accessibilityLabel={translate('sidebarScreen.fabNewChatExplained')} | ||
| role={CONST.ROLE.BUTTON} | ||
| isTooltipAllowed={false} | ||
| /> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| function NavigationTabBarNarrowDummy({selectedTab}: {selectedTab: ValueOf<typeof NAVIGATION_TABS>}) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const {indicatorColor: workspacesTabIndicatorColor, status: workspacesTabIndicatorStatus} = useWorkspacesTabIndicatorStatus(); | ||
| const [chatTabBrickRoad, setChatTabBrickRoad] = useState<BrickRoad>(undefined); | ||
| const {orderedReports} = useSidebarOrderedReports(); | ||
| const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: (value) => value?.reports, canBeMissing: true}); | ||
|
|
||
| useEffect(() => { | ||
| setChatTabBrickRoad(getChatTabBrickRoad(orderedReports)); | ||
| // We need to get a new brick road state when report attributes are updated, otherwise we'll be showing an outdated brick road. | ||
| // That's why reportAttributes is added as a dependency here | ||
| }, [orderedReports, reportAttributes]); | ||
|
|
||
| return ( | ||
| <View style={styles.navigationTabBarContainer}> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.inbox')} | ||
| wrapperStyle={styles.flex1} | ||
| style={styles.navigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.Inbox} | ||
| fill={selectedTab === NAVIGATION_TABS.HOME ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| {!!chatTabBrickRoad && ( | ||
| <View style={styles.navigationTabBarStatusIndicator(chatTabBrickRoad === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO ? theme.iconSuccessFill : theme.danger)} /> | ||
| )} | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.HOME ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.inbox')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.reports')} | ||
| wrapperStyle={styles.flex1} | ||
| style={styles.navigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.MoneySearch} | ||
| fill={selectedTab === NAVIGATION_TABS.SEARCH ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.SEARCH ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.reports')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <View style={[styles.flex1, styles.navigationTabBarItem]}> | ||
| <FloatingActionButton | ||
| onPress={noop} | ||
| isActive={false} | ||
| accessibilityLabel={translate('sidebarScreen.fabNewChatExplained')} | ||
| role={CONST.ROLE.BUTTON} | ||
| isTooltipAllowed={false} | ||
| /> | ||
| </View> | ||
| <PressableWithFeedback | ||
| onPress={noop} | ||
| role={CONST.ROLE.BUTTON} | ||
| accessibilityLabel={translate('common.workspacesTabTitle')} | ||
| wrapperStyle={styles.flex1} | ||
| style={styles.navigationTabBarItem} | ||
| > | ||
| <View> | ||
| <Icon | ||
| src={Expensicons.Buildings} | ||
| fill={selectedTab === NAVIGATION_TABS.WORKSPACES ? theme.iconMenu : theme.icon} | ||
| width={variables.iconBottomBar} | ||
| height={variables.iconBottomBar} | ||
| /> | ||
| {!!workspacesTabIndicatorStatus && <View style={styles.navigationTabBarStatusIndicator(workspacesTabIndicatorColor)} />} | ||
| </View> | ||
| <Text | ||
| style={[ | ||
| styles.textSmall, | ||
| styles.textAlignCenter, | ||
| styles.mt1Half, | ||
| selectedTab === NAVIGATION_TABS.WORKSPACES ? styles.textBold : styles.textSupporting, | ||
| styles.navigationTabBarLabel, | ||
| ]} | ||
| > | ||
| {translate('common.workspacesTabTitle')} | ||
| </Text> | ||
| </PressableWithFeedback> | ||
| <NavigationTabBarAvatar | ||
| style={styles.navigationTabBarItem} | ||
| isSelected={selectedTab === NAVIGATION_TABS.SETTINGS} | ||
| onPress={noop} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * This is a dummy component for the NavigationTabBar created for performance reasons. | ||
| * It is used to render the dummy NavigationTabBar in a wide or narrow layout. | ||
| * @param selectedTab - The selected tab. | ||
| * @returns The NavigationTabBarDummy component. | ||
| */ | ||
| function NavigationTabBarDummy({selectedTab}: {selectedTab: ValueOf<typeof NAVIGATION_TABS>}) { | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
|
|
||
| if (shouldUseNarrowLayout) { | ||
| return <NavigationTabBarNarrowDummy selectedTab={selectedTab} />; | ||
| } | ||
|
|
||
| return <NavigationTabBarWideDummy selectedTab={selectedTab} />; | ||
| } | ||
|
|
||
| export default memo(NavigationTabBarDummy); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Display name |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case do we need this in the Wide layout? Could we not render this at all in wide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! It is there to make dummy counterpart 1:1 match with regular component, but we can investigate it further to see how it behaves on wider screens 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to see the navigation bar under the overlay (the one from RHP), we need to render it per screen on the wide layout. The top level is displayed over everything else. It wouldn't be covered by the overlay.