From dd7bbd9fd7172bcbaf0bbdc17aa61ffcc4c3b05a Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 17 Nov 2023 08:43:45 +0100 Subject: [PATCH 01/21] Create a useResponsiveLayout hook --- .../BaseAnchorForCommentsOnly.js | 6 +- .../AttachmentPicker/index.native.js | 6 +- .../AttachmentCarouselCellRenderer.js | 6 +- .../AttachmentCarousel/CarouselButtons.js | 8 +-- src/components/EmojiPicker/EmojiPicker.js | 8 ++- .../EmojiPicker/EmojiPickerMenu/index.js | 6 +- src/components/HeaderPageLayout.js | 6 +- src/components/LHNOptionsList/OptionRowLHN.js | 6 +- src/components/MenuItem.js | 6 +- src/components/Modal/BaseModal.tsx | 9 ++- src/components/MoneyRequestHeader.js | 6 +- src/components/PDFView/PDFPasswordForm.js | 6 +- src/components/PopoverMenu/index.js | 6 +- .../ReportActionItem/MoneyRequestPreview.js | 7 ++- .../ReportActionItem/MoneyRequestView.js | 8 +-- src/components/ScreenWrapper/index.js | 6 +- src/hooks/useResponsiveLayout.ts | 24 ++++++++ .../AppNavigator/ModalStackNavigators.js | 1 + src/pages/NewChatPage.js | 6 +- .../report/AnimatedEmptyStateBackground.js | 8 ++- .../ComposerWithSuggestions.js | 12 ++-- .../ReportActionCompose.js | 10 ++-- .../report/ReportActionItemMessageEdit.js | 10 ++-- src/pages/home/sidebar/SidebarLinks.js | 18 +++--- src/pages/iou/ReceiptSelector/index.js | 10 ++-- .../settings/Wallet/WalletPage/WalletPage.js | 10 ++-- src/pages/signin/ChooseSSOOrMagicCode.js | 8 +-- src/pages/signin/LoginForm/BaseLoginForm.js | 8 +-- src/pages/signin/SignInModal.js | 2 +- src/pages/signin/SignInPage.js | 31 ++++------- src/pages/signin/SignInPageLayout/index.js | 6 +- src/pages/workspace/WorkspaceNewRoomPage.js | 6 +- src/styles/getModalStyles.ts | 55 ++++++++++--------- src/styles/styles.ts | 4 +- 34 files changed, 188 insertions(+), 147 deletions(-) create mode 100644 src/hooks/useResponsiveLayout.ts diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js index fc9cd1d7a043..a7a455a6a33f 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js @@ -7,7 +7,7 @@ import _ from 'underscore'; import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction'; import Text from '@components/Text'; import Tooltip from '@components/Tooltip'; -import useWindowDimensions from '@hooks/useWindowDimensions'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as ContextMenuActions from '@pages/home/report/ContextMenu/ContextMenuActions'; import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu'; @@ -40,7 +40,7 @@ function BaseAnchorForCommentsOnly({onPressIn, onPressOut, href = '', rel = '', [], ); - const {isSmallScreenWidth} = useWindowDimensions(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); let linkRef; @@ -50,7 +50,7 @@ function BaseAnchorForCommentsOnly({onPressIn, onPressOut, href = '', rel = '', } else { linkProps.href = href; } - const defaultTextStyle = DeviceCapabilities.canUseTouchScreen() || isSmallScreenWidth ? {} : {...styles.userSelectText, ...styles.cursorPointer}; + const defaultTextStyle = DeviceCapabilities.canUseTouchScreen() || shouldUseNarrowLayout ? {} : {...styles.userSelectText, ...styles.cursorPointer}; const isEmail = Str.isValidEmailMarkdown(href.replace(/mailto:/i, '')); return ( diff --git a/src/components/AttachmentPicker/index.native.js b/src/components/AttachmentPicker/index.native.js index 5b955ee69dd3..3e9562fa56d9 100644 --- a/src/components/AttachmentPicker/index.native.js +++ b/src/components/AttachmentPicker/index.native.js @@ -12,7 +12,7 @@ import Popover from '@components/Popover'; import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager'; import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useLocalize from '@hooks/useLocalize'; -import useWindowDimensions from '@hooks/useWindowDimensions'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import * as FileUtils from '@libs/fileDownload/FileUtils'; import useThemeStyles from '@styles/useThemeStyles'; import CONST from '@src/CONST'; @@ -109,7 +109,7 @@ function AttachmentPicker({type, children, shouldHideCameraOption}) { const onCanceled = useRef(); const {translate} = useLocalize(); - const {isSmallScreenWidth} = useWindowDimensions(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); /** * A generic handling when we don't know the exact reason for an error @@ -313,7 +313,7 @@ function AttachmentPicker({type, children, shouldHideCameraOption}) { anchorPosition={styles.createMenuPosition} onModalHide={onModalHide.current} > - + {_.map(menuItemData, (item, menuIndex) => ( {!isBackDisabled && ( - +