From e91fbb0ec5fd94bbf4b2c733086b1e4ab7817d8b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 22 Jan 2025 16:10:00 +0800 Subject: [PATCH 1/4] prevent tooltip from showing when a fullscreen is visible --- src/ONYXKEYS.ts | 4 ++++ src/components/LHNOptionsList/OptionRowLHN.tsx | 5 +++-- src/libs/FullscreenVisibility.ts | 8 ++++++++ src/libs/Navigation/AppNavigator/AuthScreens.tsx | 12 ++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/libs/FullscreenVisibility.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index d39213943c82..0bb3b30447de 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -46,6 +46,9 @@ const ONYXKEYS = { /** Keeps track if there is modal currently visible or not */ MODAL: 'modal', + /** Keeps track if there is a full screen currently visible or not */ + FULLSCREEN_VISIBILITY: 'fullscreenVisibility', + /** Has information about the network status (offline/online) */ NETWORK: 'network', @@ -910,6 +913,7 @@ type OnyxValuesMapping = { [ONYXKEYS.CREDENTIALS]: OnyxTypes.Credentials; [ONYXKEYS.STASHED_CREDENTIALS]: OnyxTypes.Credentials; [ONYXKEYS.MODAL]: OnyxTypes.Modal; + [ONYXKEYS.FULLSCREEN_VISIBILITY]: boolean; [ONYXKEYS.NETWORK]: OnyxTypes.Network; [ONYXKEYS.NEW_GROUP_CHAT_DRAFT]: OnyxTypes.NewGroupChatDraft; [ONYXKEYS.CUSTOM_STATUS_DRAFT]: OnyxTypes.CustomStatusDraft; diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 2dc93aa8c9c1..555ba33937dc 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -59,6 +59,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY); const session = useSession(); const shouldShowWokspaceChatTooltip = isPolicyExpenseChat(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID; const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); @@ -68,11 +69,11 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const {tooltipToRender, shouldShowTooltip} = useMemo(() => { const tooltip = shouldShowGetStartedTooltip ? CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.CONCEIRGE_LHN_GBR : CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.LHN_WORKSPACE_CHAT_TOOLTIP; const shouldShowTooltips = shouldShowWokspaceChatTooltip || shouldShowGetStartedTooltip; - const shouldTooltipBeVisible = shouldUseNarrowLayout ? isScreenFocused && isActiveRouteHome : isActiveRouteHome; + const shouldTooltipBeVisible = shouldUseNarrowLayout ? isScreenFocused && isActiveRouteHome : isActiveRouteHome && !isFullscreenVisible; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing return {tooltipToRender: tooltip, shouldShowTooltip: shouldShowTooltips && shouldTooltipBeVisible}; - }, [shouldShowGetStartedTooltip, shouldShowWokspaceChatTooltip, isScreenFocused, shouldUseNarrowLayout, isActiveRouteHome]); + }, [shouldShowGetStartedTooltip, shouldShowWokspaceChatTooltip, isScreenFocused, shouldUseNarrowLayout, isActiveRouteHome, isFullscreenVisible]); const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(tooltipToRender, shouldShowTooltip); diff --git a/src/libs/FullscreenVisibility.ts b/src/libs/FullscreenVisibility.ts new file mode 100644 index 000000000000..360e1550f436 --- /dev/null +++ b/src/libs/FullscreenVisibility.ts @@ -0,0 +1,8 @@ +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; + +function setFullscreenVisibility(isVisible: boolean) { + Onyx.merge(ONYXKEYS.FULLSCREEN_VISIBILITY, isVisible); +} + +export {setFullscreenVisibility}; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 8832a3b4287c..10e4329de04c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -19,6 +19,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {READ_COMMANDS} from '@libs/API/types'; +import {setFullscreenVisibility} from '@libs/FullscreenVisibility'; import HttpUtils from '@libs/HttpUtils'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import Log from '@libs/Log'; @@ -220,6 +221,15 @@ const modalScreenListeners = { }, }; +const fullScreenListeners = { + focus: () => { + setFullscreenVisibility(true); + }, + beforeRemove: () => { + setFullscreenVisibility(false); + }, +}; + // Extended modal screen listeners with additional cancellation of pending requests const modalScreenListenersWithCancelSearch = { ...modalScreenListeners, @@ -460,6 +470,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie headerShown: false, title: 'New Expensify', }} + listeners={fullScreenListeners} getComponent={loadValidateLoginPage} /> Date: Wed, 22 Jan 2025 16:13:00 +0800 Subject: [PATCH 2/4] move to actions folder --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- src/libs/{ => actions}/FullscreenVisibility.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/libs/{ => actions}/FullscreenVisibility.ts (100%) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 10e4329de04c..c7d3425fe424 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -19,7 +19,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {READ_COMMANDS} from '@libs/API/types'; -import {setFullscreenVisibility} from '@libs/FullscreenVisibility'; +import {setFullscreenVisibility} from '@libs/actions/FullscreenVisibility'; import HttpUtils from '@libs/HttpUtils'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import Log from '@libs/Log'; diff --git a/src/libs/FullscreenVisibility.ts b/src/libs/actions/FullscreenVisibility.ts similarity index 100% rename from src/libs/FullscreenVisibility.ts rename to src/libs/actions/FullscreenVisibility.ts From 98b21803ea1d40e60abfd6d92898d0c54b0105f0 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 22 Jan 2025 16:13:42 +0800 Subject: [PATCH 3/4] prefer default export --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- .../{FullscreenVisibility.ts => setFullscreenVisibility.ts} | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) rename src/libs/actions/{FullscreenVisibility.ts => setFullscreenVisibility.ts} (60%) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index c7d3425fe424..82678d322e64 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -19,7 +19,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {READ_COMMANDS} from '@libs/API/types'; -import {setFullscreenVisibility} from '@libs/actions/FullscreenVisibility'; +import setFullscreenVisibility from '@libs/actions/setFullscreenVisibility'; import HttpUtils from '@libs/HttpUtils'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import Log from '@libs/Log'; diff --git a/src/libs/actions/FullscreenVisibility.ts b/src/libs/actions/setFullscreenVisibility.ts similarity index 60% rename from src/libs/actions/FullscreenVisibility.ts rename to src/libs/actions/setFullscreenVisibility.ts index 360e1550f436..db2be3123a1f 100644 --- a/src/libs/actions/FullscreenVisibility.ts +++ b/src/libs/actions/setFullscreenVisibility.ts @@ -1,8 +1,6 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; -function setFullscreenVisibility(isVisible: boolean) { +export default function setFullscreenVisibility(isVisible: boolean) { Onyx.merge(ONYXKEYS.FULLSCREEN_VISIBILITY, isVisible); } - -export {setFullscreenVisibility}; From 72c2b6d0486201189f2abaee666b6779e3ba72c8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 22 Jan 2025 16:17:26 +0800 Subject: [PATCH 4/4] prettier --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 82678d322e64..701042b93aae 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -18,8 +18,8 @@ import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {READ_COMMANDS} from '@libs/API/types'; import setFullscreenVisibility from '@libs/actions/setFullscreenVisibility'; +import {READ_COMMANDS} from '@libs/API/types'; import HttpUtils from '@libs/HttpUtils'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import Log from '@libs/Log';