Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/Navigation/NavigationTabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ import NAVIGATION_TABS from './NAVIGATION_TABS';
type NavigationTabBarProps = {
selectedTab: ValueOf<typeof NAVIGATION_TABS>;
isTooltipAllowed?: boolean;
isTopLevelBar?: boolean;
};

function NavigationTabBar({selectedTab, isTooltipAllowed = false}: NavigationTabBarProps) {
function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar = false}: NavigationTabBarProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -69,6 +70,9 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false}: NavigationTab
const StyleUtils = useStyleUtils();
const {canUseLeftHandBar} = usePermissions();

// On a wide layout DebugTabView should be rendered only within the navigation tab bar displayed directly on screens.
const shouldRenderDebugTabViewOnWideLayout = !!user?.isDebugModeEnabled && !isTopLevelBar;

useEffect(() => {
setChatTabBrickRoad(getChatTabBrickRoad(activeWorkspaceID, reports));
// We need to get a new brick road state when report actions are updated, otherwise we'll be showing an outdated brick road.
Expand Down Expand Up @@ -202,7 +206,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false}: NavigationTab
if (!shouldUseNarrowLayout && canUseLeftHandBar) {
return (
<>
{!!user?.isDebugModeEnabled && (
{shouldRenderDebugTabViewOnWideLayout && (
<DebugTabView
selectedTab={selectedTab}
chatTabBrickRoad={chatTabBrickRoad}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function TopLevelNavigationTabBar({state}: TopLevelNavigationTabBarProps) {
<NavigationTabBar
selectedTab={selectedTab}
isTooltipAllowed={isReadyToDisplayBottomBar}
isTopLevelBar
/>
</View>
);
Expand Down
30 changes: 13 additions & 17 deletions src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ type ScreenWrapperProps = {
children: ReactNode | React.FC<ScreenWrapperChildrenProps>;

/** Content to display under the offline indicator */
extraContent?: ReactNode;

/** Additional styles for extra content */
extraContentStyles?: StyleProp<ViewStyle>;
bottomContent?: ReactNode;

/** A unique ID to find the screen wrapper in tests */
testID: string;
Expand Down Expand Up @@ -175,8 +172,7 @@ function ScreenWrapper(
shouldShowOfflineIndicatorInWideScreen = false,
shouldUseCachedViewportHeight = false,
focusTrapSettings,
extraContent,
extraContentStyles,
bottomContent,
enableEdgeToEdgeBottomSafeAreaPadding: enableEdgeToEdgeBottomSafeAreaPaddingProp,
shouldMobileOfflineIndicatorStickToBottom: shouldMobileOfflineIndicatorStickToBottomProp,
shouldKeyboardOffsetBottomSafeAreaPadding: shouldKeyboardOffsetBottomSafeAreaPaddingProp,
Expand Down Expand Up @@ -336,9 +332,9 @@ function ScreenWrapper(
return {paddingTop};
}, [isUsingEdgeToEdgeMode, ignoreInsetsConsumption, includePaddingTop, paddingTop, unmodifiedPaddings.top]);

const showExtraContent = isUsingEdgeToEdgeMode ? !!extraContent : true;
const edgeToEdgeExtraContentStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: true});
const legacyExtraContentStyle: StyleProp<ViewStyle> = useMemo(() => {
const showBottomContent = isUsingEdgeToEdgeMode ? !!bottomContent : true;
const edgeToEdgeBottomContentStyle = useBottomSafeSafeAreaPaddingStyle({addBottomSafeAreaPadding: true});
const legacyBottomContentStyle: StyleProp<ViewStyle> = useMemo(() => {
const shouldUseUnmodifiedPaddings = includeSafeAreaPaddingBottom && ignoreInsetsConsumption;
if (shouldUseUnmodifiedPaddings) {
return {
Expand All @@ -352,9 +348,9 @@ function ScreenWrapper(
};
}, [ignoreInsetsConsumption, includeSafeAreaPaddingBottom, paddingBottom, unmodifiedPaddings.bottom]);

const extraContentStyle = useMemo(
() => [isUsingEdgeToEdgeMode ? edgeToEdgeExtraContentStyle : legacyExtraContentStyle, extraContentStyles],
[isUsingEdgeToEdgeMode, edgeToEdgeExtraContentStyle, legacyExtraContentStyle, extraContentStyles],
const bottomContentStyle = useMemo(
() => (isUsingEdgeToEdgeMode ? edgeToEdgeBottomContentStyle : legacyBottomContentStyle),
[isUsingEdgeToEdgeMode, edgeToEdgeBottomContentStyle, legacyBottomContentStyle],
);

/**
Expand All @@ -365,12 +361,12 @@ function ScreenWrapper(
* If `isOfflineIndicatorTranslucent` is set to true, a translucent background color is applied.
*/
const mobileOfflineIndicatorBackgroundStyle = useMemo(() => {
const showOfflineIndicatorBackground = !extraContent && isOffline;
const showOfflineIndicatorBackground = !bottomContent && isOffline;
if (!showOfflineIndicatorBackground) {
return undefined;
}
return isOfflineIndicatorTranslucent ? styles.translucentNavigationBarBG : styles.appBG;
}, [extraContent, isOffline, isOfflineIndicatorTranslucent, styles.appBG, styles.translucentNavigationBarBG]);
}, [bottomContent, isOffline, isOfflineIndicatorTranslucent, styles.appBG, styles.translucentNavigationBarBG]);

/** In edge-to-edge mode, we always want to apply the bottom safe area padding to the mobile offline indicator. */
const hasMobileOfflineIndicatorBottomSafeAreaPadding = isUsingEdgeToEdgeMode ? enableEdgeToEdgeBottomSafeAreaPadding : !includeSafeAreaPaddingBottom;
Expand All @@ -389,7 +385,7 @@ function ScreenWrapper(
});

/** If there is no bottom content, the mobile offline indicator will stick to the bottom of the screen by default. */
const displayStickyMobileOfflineIndicator = shouldMobileOfflineIndicatorStickToBottom && !extraContent;
const displayStickyMobileOfflineIndicator = shouldMobileOfflineIndicatorStickToBottom && !bottomContent;

/**
* This style includes all styles applied to the container of the mobile offline indicator.
Expand Down Expand Up @@ -479,7 +475,7 @@ function ScreenWrapper(
<>
<OfflineIndicator
style={[styles.pl5, offlineIndicatorStyle]}
addBottomSafeAreaPadding={isUsingEdgeToEdgeMode ? !extraContent : true}
addBottomSafeAreaPadding={isUsingEdgeToEdgeMode ? !bottomContent : true}
/>
{/* Since import state is tightly coupled to the offline state, it is safe to display it when showing offline indicator */}
<ImportedStateIndicator />
Expand All @@ -489,7 +485,7 @@ function ScreenWrapper(
</PickerAvoidingView>
</KeyboardAvoidingView>
</View>
{showExtraContent && <View style={extraContentStyle}>{extraContent}</View>}
{showBottomContent && <View style={bottomContentStyle}>{bottomContent}</View>}
</View>
</FocusTrapForScreens>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Search/SearchPageNarrow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function SearchPageNarrow({queryJSON, policyID, searchName, headerButtonsOptions
testID={SearchPageNarrow.displayName}
shouldEnableMaxHeight
offlineIndicatorStyle={styles.mtAuto}
extraContent={<NavigationTabBar selectedTab={NAVIGATION_TABS.SEARCH} />}
bottomContent={<NavigationTabBar selectedTab={NAVIGATION_TABS.SEARCH} />}
headerGapStyles={styles.searchHeaderGap}
shouldShowOfflineIndicator={!!searchResults}
>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/home/sidebar/BaseSidebarScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function BaseSidebarScreen() {
const {activeWorkspaceID} = useActiveWorkspace();
const {translate} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [activeWorkspace, activeWorkspaceResult] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID ?? CONST.DEFAULT_NUMBER_ID}`);
const [activeWorkspace, activeWorkspaceResult] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`, {canBeMissing: true});
const currentRoute = useRoute();
const isLoading = isLoadingOnyxValue(activeWorkspaceResult);
const {canUseLeftHandBar} = usePermissions();
const shouldDisplayLHB = canUseLeftHandBar && !shouldUseNarrowLayout;
const shouldDisplayLHB = !!canUseLeftHandBar && !shouldUseNarrowLayout;

useEffect(() => {
Performance.markStart(CONST.TIMING.SIDEBAR_LOADED);
Expand Down Expand Up @@ -74,8 +74,7 @@ function BaseSidebarScreen() {
shouldEnableKeyboardAvoidingView={false}
style={[styles.sidebar, isMobile() ? styles.userSelectNone : {}]}
testID={BaseSidebarScreen.displayName}
extraContent={<NavigationTabBar selectedTab={NAVIGATION_TABS.HOME} />}
extraContentStyles={shouldDisplayLHB && styles.leftNavigationTabBarPosition}
bottomContent={!shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.HOME} />}
>
{({insets}) => (
<>
Expand All @@ -88,6 +87,7 @@ function BaseSidebarScreen() {
<View style={[styles.flex1]}>
<SidebarLinksData insets={insets} />
</View>
{shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.HOME} />}
</>
)}
</ScreenWrapper>
Expand Down
32 changes: 16 additions & 16 deletions src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ type MenuData = {
type Menu = {sectionStyle: StyleProp<ViewStyle>; sectionTranslationKey: TranslationPaths; items: MenuData[]};

function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPageProps) {
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET);
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST);
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS);
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST);
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS);
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT);
const [allCards] = useOnyx(`${ONYXKEYS.CARD_LIST}`);
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET, {canBeMissing: true});
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true});
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {canBeMissing: true});
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS, {canBeMissing: true});
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true});
const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS, {canBeMissing: true});
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});
const [allCards] = useOnyx(`${ONYXKEYS.CARD_LIST}`, {canBeMissing: true});

const {shouldUseNarrowLayout} = useResponsiveLayout();
const network = useNetwork();
Expand All @@ -102,12 +102,12 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
const {translate} = useLocalize();
const focusedRouteName = useNavigationState((state) => findFocusedRoute(state)?.name);
const emojiCode = currentUserPersonalDetails?.status?.emojiCode ?? '';
const [allConnectionSyncProgresses] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}`);
const [allConnectionSyncProgresses] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}`, {canBeMissing: true});
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
const {canUseLeftHandBar} = usePermissions();
const shouldDisplayLHB = canUseLeftHandBar && !shouldUseNarrowLayout;
const shouldDisplayLHB = !!canUseLeftHandBar && !shouldUseNarrowLayout;

const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION);
const [privateSubscription] = useOnyx(ONYXKEYS.NVP_PRIVATE_SUBSCRIPTION, {canBeMissing: true});
const subscriptionPlan = useSubscriptionPlan();
const hasBrokenFeedConnection = checkIfFeedConnectionIsBroken(allCards, CONST.EXPENSIFY_CARD.BANK);
const walletBrickRoadIndicator =
Expand Down Expand Up @@ -381,11 +381,11 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
const workspaceMenuItems = useMemo(() => getMenuItemsSection(workspaceMenuItemsData), [workspaceMenuItemsData, getMenuItemsSection]);

const headerContent = (
<View style={[styles.ph5, !canUseLeftHandBar && styles.pv5]}>
<View style={[styles.ph5, canUseLeftHandBar ? styles.pv4 : styles.pv5]}>
{isEmptyObject(currentUserPersonalDetails) || currentUserPersonalDetails.displayName === undefined ? (
<AccountSwitcherSkeletonView avatarSize={CONST.AVATAR_SIZE.DEFAULT} />
) : (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.gap3, canUseLeftHandBar ? [styles.headerBarDesktopHeight(true)] : []]}>
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.gap3]}>
<AccountSwitcher />
<Tooltip text={translate('statusPage.status')}>
<PressableWithFeedback
Expand Down Expand Up @@ -441,8 +441,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
<ScreenWrapper
includeSafeAreaPaddingBottom
testID={InitialSettingsPage.displayName}
extraContent={<NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
extraContentStyles={shouldDisplayLHB && styles.leftNavigationTabBarPosition}
bottomContent={!shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
shouldEnableKeyboardAvoidingView={false}
>
{headerContent}
Expand All @@ -467,6 +466,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
onCancel={() => toggleSignoutConfirmModal(false)}
/>
</ScrollView>
{shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
</ScreenWrapper>
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
const policy = policyDraft?.id ? policyDraft : policyProp;
const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID;
const hasPolicyCreationError = policy?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && !isEmptyObject(policy.errors);
const [allFeedsCards] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}`);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route.params?.policyID}`);
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [allFeedsCards] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}`, {canBeMissing: true});
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email, canBeMissing: false});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${route.params?.policyID}`, {canBeMissing: true});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false});
const {login, accountID} = useCurrentUserPersonalDetails();
const hasSyncError = shouldShowSyncError(policy, isConnectionInProgress(connectionSyncProgress, policy));
const waitForNavigate = useWaitForNavigation();
Expand All @@ -122,12 +122,12 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
const {isOffline} = useNetwork();
const wasRendered = useRef(false);
const currentUserPolicyExpenseChatReportID = getPolicyExpenseChat(accountID, policy?.id)?.reportID;
const [currentUserPolicyExpenseChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${currentUserPolicyExpenseChatReportID}`);
const [currentUserPolicyExpenseChat] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${currentUserPolicyExpenseChatReportID}`, {canBeMissing: true});
const {reportPendingAction} = getReportOfflinePendingActionAndErrors(currentUserPolicyExpenseChat);
const isPolicyExpenseChatEnabled = !!policy?.isPolicyExpenseChatEnabled;
const prevPendingFields = usePrevious(policy?.pendingFields);
const {canUseLeftHandBar} = usePermissions();
const shouldDisplayLHB = canUseLeftHandBar && !shouldUseNarrowLayout;
const shouldDisplayLHB = !!canUseLeftHandBar && !shouldUseNarrowLayout;
const policyFeatureStates = useMemo(
() => ({
[CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED]: policy?.areDistanceRatesEnabled,
Expand Down Expand Up @@ -436,8 +436,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
<ScreenWrapper
testID={WorkspaceInitialPage.displayName}
enableEdgeToEdgeBottomSafeAreaPadding={false}
extraContent={shouldShowNavigationTabBar ? <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} /> : null}
extraContentStyles={shouldDisplayLHB && styles.leftNavigationTabBarPosition}
bottomContent={shouldShowNavigationTabBar && !shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
>
<FullPageNotFoundView
onBackButtonPress={Navigation.dismissModal}
Expand Down Expand Up @@ -503,6 +502,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
</View>
)}
</ScrollView>
{shouldShowNavigationTabBar && shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
</FullPageNotFoundView>
</ScreenWrapper>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ function WorkspacesListPage() {
shouldEnableMaxHeight
testID={WorkspacesListPage.displayName}
shouldShowOfflineIndicatorInWideScreen
extraContent={shouldUseNarrowLayout && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
bottomContent={shouldUseNarrowLayout && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
enableEdgeToEdgeBottomSafeAreaPadding={false}
>
<HeaderWithBackButton
Expand Down Expand Up @@ -542,7 +542,7 @@ function WorkspacesListPage() {
shouldShowOfflineIndicatorInWideScreen
testID={WorkspacesListPage.displayName}
enableEdgeToEdgeBottomSafeAreaPadding={false}
extraContent={shouldUseNarrowLayout && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
bottomContent={shouldUseNarrowLayout && <NavigationTabBar selectedTab={NAVIGATION_TABS.SETTINGS} />}
>
<View style={styles.flex1}>
<HeaderWithBackButton
Expand Down