diff --git a/src/components/FeatureTrainingModal.tsx b/src/components/FeatureTrainingModal.tsx index 221a582af75d..d204567eee31 100644 --- a/src/components/FeatureTrainingModal.tsx +++ b/src/components/FeatureTrainingModal.tsx @@ -5,8 +5,8 @@ import {GestureHandlerRootView} from 'react-native-gesture-handler'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useOnboardingLayout from '@hooks/useOnboardingLayout'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import * as User from '@userActions/User'; @@ -85,13 +85,13 @@ function FeatureTrainingModal({ }: FeatureTrainingModalProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); const [isModalVisible, setIsModalVisible] = useState(true); const [willShowAgain, setWillShowAgain] = useState(true); const [videoStatus, setVideoStatus] = useState('video'); const [isVideoStatusLocked, setIsVideoStatusLocked] = useState(false); const [videoAspectRatio, setVideoAspectRatio] = useState(videoAspectRatioProp ?? VIDEO_ASPECT_RATIO); - const {isSmallScreenWidth} = useWindowDimensions(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); const {isOffline} = useNetwork(); useEffect(() => { @@ -148,7 +148,7 @@ function FeatureTrainingModal({ @@ -156,7 +156,7 @@ function FeatureTrainingModal({ )} ); - }, [animation, videoURL, videoAspectRatio, videoStatus, isSmallScreenWidth, styles]); + }, [animation, videoURL, videoAspectRatio, videoStatus, shouldUseNarrowLayout, styles]); const toggleWillShowAgain = useCallback(() => setWillShowAgain((prevWillShowAgain) => !prevWillShowAgain), []); @@ -178,14 +178,14 @@ function FeatureTrainingModal({ {({safeAreaPaddingBottomStyle}) => ( - - {renderIllustration()} + + {renderIllustration()} {title && description && ( - + {title} {description} {secondaryDescription.length > 0 && {secondaryDescription}} diff --git a/src/hooks/useIsReportOpenInRHP.ts b/src/hooks/useIsReportOpenInRHP.ts deleted file mode 100644 index d452a82615c4..000000000000 --- a/src/hooks/useIsReportOpenInRHP.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {useNavigationState} from '@react-navigation/native'; -import getTopmostRouteName from '@libs/Navigation/getTopmostRouteName'; -import SCREENS from '@src/SCREENS'; - -// This hook checks if the currently open route is ReportScreen in RHP. -export default function useIsReportOpenInRHP() { - const activeRoute = useNavigationState(getTopmostRouteName); - return activeRoute === SCREENS.SEARCH.REPORT_RHP; -} diff --git a/src/hooks/useOnboardingLayout.ts b/src/hooks/useOnboardingLayout.ts index 512482340bb2..1b66c2fb2b64 100644 --- a/src/hooks/useOnboardingLayout.ts +++ b/src/hooks/useOnboardingLayout.ts @@ -3,7 +3,7 @@ import {useWindowDimensions} from 'react-native'; import variables from '@styles/variables'; type OnboardingLayout = { - shouldUseNarrowLayout: boolean; + isMediumOrLargerScreenWidth: boolean; }; /** @@ -15,5 +15,5 @@ type OnboardingLayout = { export default function useOnboardingLayout(): OnboardingLayout { const {width: windowWidth} = useWindowDimensions(); - return {shouldUseNarrowLayout: windowWidth > variables.mobileResponsiveWidthBreakpoint}; + return {isMediumOrLargerScreenWidth: windowWidth > variables.mobileResponsiveWidthBreakpoint}; } diff --git a/src/hooks/useThumbnailDimensions.ts b/src/hooks/useThumbnailDimensions.ts index 21e711f64166..85c5703861b4 100644 --- a/src/hooks/useThumbnailDimensions.ts +++ b/src/hooks/useThumbnailDimensions.ts @@ -2,7 +2,7 @@ import {useMemo} from 'react'; import type {StyleProp, ViewStyle} from 'react-native'; import type {DimensionValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; import CONST from '@src/CONST'; -import useIsReportOpenInRHP from './useIsReportOpenInRHP'; +import useResponsiveLayout from './useResponsiveLayout'; import useWindowDimensions from './useWindowDimensions'; type ThumbnailDimensions = { @@ -14,9 +14,9 @@ type ThumbnailDimensions = { }; export default function useThumbnailDimensions(width: number, height: number): ThumbnailDimensions { - const isReportOpenInRHP = useIsReportOpenInRHP(); + const {isInNarrowPaneModal} = useResponsiveLayout(); const {isSmallScreenWidth} = useWindowDimensions(); - const shouldUseNarrowLayout = isSmallScreenWidth || isReportOpenInRHP; + const shouldUseNarrowLayout = isSmallScreenWidth || isInNarrowPaneModal; const fixedDimension = shouldUseNarrowLayout ? CONST.THUMBNAIL_IMAGE.SMALL_SCREEN.SIZE : CONST.THUMBNAIL_IMAGE.WIDE_SCREEN.SIZE; const thumbnailDimensionsStyles = useMemo(() => { if (!width || !height) { diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index a43199c50439..d3bee5021988 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -201,14 +201,14 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {isSmallScreenWidth} = useWindowDimensions(); - const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); const screenOptions = getRootNavigatorScreenOptions(isSmallScreenWidth, styles, StyleUtils); const {canUseDefaultRooms} = usePermissions(); const {activeWorkspaceID} = useActiveWorkspace(); - const onboardingModalScreenOptions = useMemo(() => screenOptions.onboardingModalNavigator(shouldUseNarrowLayout), [screenOptions, shouldUseNarrowLayout]); + const onboardingModalScreenOptions = useMemo(() => screenOptions.onboardingModalNavigator(isMediumOrLargerScreenWidth), [screenOptions, isMediumOrLargerScreenWidth]); const onboardingScreenOptions = useMemo( - () => getOnboardingModalScreenOptions(isSmallScreenWidth, styles, StyleUtils, shouldUseNarrowLayout), - [StyleUtils, isSmallScreenWidth, shouldUseNarrowLayout, styles], + () => getOnboardingModalScreenOptions(isSmallScreenWidth, styles, StyleUtils, isMediumOrLargerScreenWidth), + [StyleUtils, isSmallScreenWidth, isMediumOrLargerScreenWidth, styles], ); let initialReportID: string | undefined; diff --git a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx index 61adcd77da76..64f827f3ddba 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/OnboardingModalNavigator.tsx @@ -26,7 +26,7 @@ const Stack = createStackNavigator(); function OnboardingModalNavigator() { const styles = useThemeStyles(); - const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); const [hasCompletedGuidedSetupFlow] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { selector: hasCompletedGuidedSetupFlowSelector, }); @@ -67,7 +67,7 @@ function OnboardingModalNavigator() { e.stopPropagation()} - style={styles.OnboardingNavigatorInnerView(shouldUseNarrowLayout)} + style={styles.OnboardingNavigatorInnerView(isMediumOrLargerScreenWidth)} >
- + diff --git a/src/pages/GetAssistancePage.tsx b/src/pages/GetAssistancePage.tsx index ac623bcc0115..90b7ccbb28d8 100644 --- a/src/pages/GetAssistancePage.tsx +++ b/src/pages/GetAssistancePage.tsx @@ -12,8 +12,8 @@ import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import * as Link from '@userActions/Link'; @@ -35,7 +35,7 @@ function GetAssistancePage({route, account}: GetAssistancePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const navigateBackTo = route?.params.backTo || ROUTES.SETTINGS_CONTACT_METHODS.getRoute(); - const {isLargeScreenWidth} = useWindowDimensions(); + const {isLargeScreenWidth} = useResponsiveLayout(); const menuItems: MenuItemWithLink[] = [ { title: translate('getAssistancePage.chatWithConcierge'), diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 17baddd39251..f4f525f1b60c 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -17,10 +17,10 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' import useDebouncedState from '@hooks/useDebouncedState'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useScreenWrapperTranstionStatus from '@hooks/useScreenWrapperTransitionStatus'; import useStyledSafeAreaInsets from '@hooks/useStyledSafeAreaInsets'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; @@ -147,7 +147,7 @@ function useOptions({isGroupChat}: NewChatPageProps) { function NewChatPage({isGroupChat}: NewChatPageProps) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); - const {isSmallScreenWidth} = useWindowDimensions(); + const {isSmallScreenWidth} = useResponsiveLayout(); const styles = useThemeStyles(); const personalData = useCurrentUserPersonalDetails(); const {insets} = useStyledSafeAreaInsets(); diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 4c79138d83fd..d0ed1302f91f 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -40,7 +40,7 @@ function BaseOnboardingPersonalDetails({ const styles = useThemeStyles(); const {translate} = useLocalize(); const {isSmallScreenWidth} = useWindowDimensions(); - const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); const {inputCallbackRef} = useAutoFocusInput(); const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false); const {accountID} = useSession(); @@ -143,7 +143,7 @@ function BaseOnboardingPersonalDetails({ onBackButtonPress={Navigation.goBack} /> - + {translate('onboarding.whatsYourName')} diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 509ad28e645e..d91110db62f8 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -15,6 +15,7 @@ import SafeAreaConsumer from '@components/SafeAreaConsumer'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useOnboardingLayout from '@hooks/useOnboardingLayout'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -41,9 +42,11 @@ const menuIcons = { function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: BaseOnboardingPurposeProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {shouldUseNarrowLayout} = useOnboardingLayout(); + const {isMediumOrLargerScreenWidth} = useOnboardingLayout(); const [selectedPurpose, setSelectedPurpose] = useState(undefined); - const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); + const {windowHeight} = useWindowDimensions(); + const {isSmallScreenWidth} = useResponsiveLayout(); + const theme = useTheme(); const [onboardingPurposeSelected, onboardingPurposeSelectedResult] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); const [onboardingErrorMessage, onboardingErrorMessageResult] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE); @@ -56,7 +59,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: B const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined; - const paddingHorizontal = shouldUseNarrowLayout ? styles.ph8 : styles.ph5; + const paddingHorizontal = isMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5; const selectedCheckboxIcon = useMemo( () => ( @@ -126,16 +129,16 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: B {({safeAreaPaddingBottomStyle}) => ( - + - + - + {translate('onboarding.purpose.title')} ) => { @@ -82,9 +82,9 @@ function BaseOnboardingWork({shouldUseNativeStyles, onboardingPurposeSelected, o onBackButtonPress={Navigation.goBack} /> - + {translate('onboarding.whereYouWork')} diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 15dd063ec6ee..2a1fca17abbf 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -19,9 +19,9 @@ import TableListItem from '@components/SelectionList/TableListItem'; import type {ListItem, SelectionListHandle} from '@components/SelectionList/types'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import * as Report from '@libs/actions/Report'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; @@ -52,7 +52,7 @@ function ReportParticipantsPage({report, personalDetails, session}: ReportPartic const {translate, formatPhoneNumber} = useLocalize(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {isSmallScreenWidth} = useWindowDimensions(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); const selectionListRef = useRef(null); const textInputRef = useRef(null); const currentUserAccountID = Number(session?.accountID); @@ -272,7 +272,7 @@ function ReportParticipantsPage({report, personalDetails, session}: ReportPartic buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM} onPress={() => null} options={bulkActionsButtonOptions} - style={[isSmallScreenWidth && styles.flexGrow1]} + style={[shouldUseNarrowLayout && styles.flexGrow1]} /> ) : (