Skip to content
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

[No QA] Replace usages of useWindowDimensions with useResponsiveLayout in components folder #36292

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
faa938d
Merge branch 'replace-usages-of-isInModal-and-shouldShowSmallScreen-p…
rayane-d Feb 10, 2024
c8776e4
replace usages of isSmallScreenWidt from useWindowDimensions with sho…
rayane-d Feb 10, 2024
976a6f4
fix lint error
rayane-d Feb 10, 2024
35d0a79
fix lint error
rayane-d Feb 10, 2024
00a3afb
revert an error
rayane-d Feb 10, 2024
e85c492
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Feb 13, 2024
e940509
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Feb 22, 2024
b5d2d3c
Fix https://github.com/Expensify/App/pull/36292#issuecomment-19685095…
rayane-d Mar 3, 2024
d7bc533
Fix https://github.com/Expensify/App/pull/36292#issuecomment-1968517716
rayane-d Mar 3, 2024
238eff3
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 3, 2024
86cd6b9
Replace usages of isSmallScreenWidth from useWindowDimensions with sh…
rayane-d Mar 3, 2024
7cdb097
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 5, 2024
01b50b5
fix https://github.com/Expensify/App/pull/36292#discussion_r1514224267
rayane-d Mar 6, 2024
66c933f
fix https://github.com/Expensify/App/pull/36292#discussion_r1514244896
rayane-d Mar 6, 2024
6ef709b
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 8, 2024
794218f
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 13, 2024
0de9f19
Fix https://github.com/Expensify/App/pull/36292#issuecomment-1985925977
rayane-d Mar 13, 2024
6ed428c
correct usage of useResponsiveLayout
rayane-d Mar 15, 2024
6ccad0a
Replace usages of isSmallScreenWidth, isExtraSmallScreenHeight, isExt…
rayane-d Mar 15, 2024
470d280
fix typescript error
rayane-d Mar 15, 2024
7b43675
fix lint error
rayane-d Mar 15, 2024
5d98499
fix lint error
rayane-d Mar 15, 2024
8d9fd9f
prettier
rayane-d Mar 15, 2024
a7e05b6
revert edit
rayane-d Mar 21, 2024
a3062f7
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 21, 2024
f173097
revert: change by error
rayane-d Mar 23, 2024
0dd9d8c
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 23, 2024
47baf2b
replace usage of useWindowDimensions with useResponsiveLayout
rayane-d Mar 23, 2024
5ec872a
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Mar 23, 2024
5cd3ce8
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 26, 2024
aa0f753
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 28, 2024
4d9b6d2
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 28, 2024
186a83f
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Mar 28, 2024
ef3d93a
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 28, 2024
cd5f8cc
Replace usages of useWindowDimensions with useResponsiveLayout in Mon…
rayane-d Mar 28, 2024
cff4c5b
mock isNavigationReady ot fix failing perf-test
rayane-d Mar 28, 2024
ebec06a
mock isNavigationReady to fix failing perf-tests
rayane-d Mar 28, 2024
335159b
Navigation mocks to fix failing perf-tests
rayane-d Mar 29, 2024
a48a8ca
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Mar 30, 2024
42dd5db
Navigation mocks
rayane-d Mar 31, 2024
52dcf81
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Mar 31, 2024
c694a2d
optimize useResponsive hook by removing unnecessary state updates
rayane-d Apr 2, 2024
15372b7
Revert "optimize useResponsive hook by removing unnecessary state upd…
rayane-d Apr 2, 2024
2467cbb
optimize useResponsive hook by removing unnecessary state updates
rayane-d Apr 2, 2024
edbef2c
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 2, 2024
29e0047
revert the change
rayane-d Apr 2, 2024
37b7420
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 7, 2024
8414202
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 9, 2024
cccfdb1
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 9, 2024
e57fb1d
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Apr 9, 2024
874e26c
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Apr 12, 2024
625331e
optimize performance of useResponsiveLayout hook
rayane-d Apr 13, 2024
28480b0
replace remaining usages of useWindowDimensions in components
rayane-d Apr 13, 2024
87db3cf
further optimize hook performance
rayane-d Apr 16, 2024
6393009
Fix lint error
rayane-d Apr 16, 2024
52e835e
Merge branch 'Expensify:main' into replace-usages-of-isSmallScreenWid…
rayane-d Apr 16, 2024
0353e51
Prettier
rayane-d Apr 16, 2024
311f4fe
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 18, 2024
6c6084f
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 18, 2024
075117e
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 21, 2024
eea701a
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 25, 2024
d262668
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 25, 2024
7fbe82f
revert changes made by error during merge
rayane-d Apr 25, 2024
46f64e3
fix lint errors
rayane-d Apr 25, 2024
89e84de
Adding an automatic check for the modal type to safely use shouldUseN…
rayane-d Apr 25, 2024
7b3fd5c
prettier
rayane-d Apr 25, 2024
8ae236f
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d Apr 30, 2024
60b9c89
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 3, 2024
4b6c14f
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 3, 2024
584d2a4
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 6, 2024
29ba49e
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 10, 2024
501e619
use selector in useOnyx usage
rayane-d May 11, 2024
3323d3e
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 15, 2024
3e2d18a
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 17, 2024
64d56bf
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 28, 2024
e8f9e79
Merge branch 'main' into replace-usages-of-isSmallScreenWidth-from-us…
rayane-d May 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {StyleSheet} from 'react-native';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import CONST from '@src/CONST';
Expand All @@ -30,15 +30,15 @@ function BaseAnchorForCommentsOnly({onPressIn, onPressOut, href = '', rel = '',
[],
);

const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

const linkProps: LinkProps = {};
if (onPress) {
linkProps.onPress = onPress;
} 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.isValidEmail(href.replace(/mailto:/i, ''));

return (
Expand Down
12 changes: 7 additions & 5 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {OnyxEntry} from 'react-native-onyx';
import {useSharedValue} from 'react-native-reanimated';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand Down Expand Up @@ -170,8 +171,9 @@ function AttachmentModal({
const [isConfirmButtonDisabled, setIsConfirmButtonDisabled] = useState(false);
const [confirmButtonFadeAnimation] = useState(() => new Animated.Value(1));
const [isDownloadButtonReadyToBeShown, setIsDownloadButtonReadyToBeShown] = React.useState(true);
const {windowWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const nope = useSharedValue(false);
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
const isOverlayModalVisible = (isReceiptAttachment && isDeleteReceiptConfirmModalVisible) || (!isReceiptAttachment && isAttachmentInvalid);
const iouType = useMemo(() => (isTrackExpenseAction ? CONST.IOU.TYPE.TRACK : CONST.IOU.TYPE.SUBMIT), [isTrackExpenseAction]);

Expand Down Expand Up @@ -486,14 +488,14 @@ function AttachmentModal({
propagateSwipe
>
<GestureHandlerRootView style={styles.flex1}>
{isSmallScreenWidth && <HeaderGap />}
{shouldUseNarrowLayout && <HeaderGap />}
<HeaderWithBackButton
title={headerTitleNew}
shouldShowBorderBottom
shouldShowDownloadButton={shouldShowDownloadButton}
onDownloadButtonPress={() => downloadAttachment()}
shouldShowCloseButton={!isSmallScreenWidth}
shouldShowBackButton={isSmallScreenWidth}
shouldShowCloseButton={!shouldUseNarrowLayout}
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={closeModal}
onCloseButtonPress={closeModal}
shouldShowThreeDotsButton={shouldShowThreeDotsButton}
Expand Down Expand Up @@ -553,7 +555,7 @@ function AttachmentModal({
<Button
success
large
style={[styles.buttonConfirm, isSmallScreenWidth ? {} : styles.attachmentButtonBigScreen]}
style={[styles.buttonConfirm, shouldUseNarrowLayout ? {} : styles.attachmentButtonBigScreen]}
textStyles={[styles.buttonConfirmText]}
text={translate('common.send')}
onPress={submitAndClose}
Expand Down
6 changes: 3 additions & 3 deletions src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Popover from '@components/Popover';
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -120,7 +120,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s
const popoverRef = useRef(null);

const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

/**
* A generic handling when we don't know the exact reason for an error
Expand Down Expand Up @@ -355,7 +355,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s
anchorRef={popoverRef}
onModalHide={onModalHide.current}
>
<View style={!isSmallScreenWidth && styles.createMenuContainer}>
<View style={!shouldUseNarrowLayout && styles.createMenuContainer}>
{menuItemData.map((item, menuIndex) => (
<MenuItem
key={item.textTranslationKey}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Button from '@components/Button';
import * as Expensicons from '@components/Icon/Expensicons';
import Tooltip from '@components/Tooltip';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';

type CarouselButtonsProps = {
/** Where the arrows should be visible */
Expand Down Expand Up @@ -38,13 +38,13 @@ function CarouselButtons({page, attachments, shouldShowArrows, onBack, onForward
const isBackDisabled = page === 0;
const isForwardDisabled = page === attachments.length - 1;
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

return shouldShowArrows ? (
<>
{!isBackDisabled && (
<Tooltip text={translate('common.previous')}>
<View style={[styles.attachmentArrow, isSmallScreenWidth ? styles.l2 : styles.l8]}>
<View style={[styles.attachmentArrow, shouldUseNarrowLayout ? styles.l2 : styles.l8]}>
<Button
small
innerStyles={[styles.arrowIcon]}
Expand All @@ -59,7 +59,7 @@ function CarouselButtons({page, attachments, shouldShowArrows, onBack, onForward
)}
{!isForwardDisabled && (
<Tooltip text={translate('common.next')}>
<View style={[styles.attachmentArrow, isSmallScreenWidth ? styles.r2 : styles.r8]}>
<View style={[styles.attachmentArrow, shouldUseNarrowLayout ? styles.r2 : styles.r8]}>
<Button
small
innerStyles={[styles.arrowIcon]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import VideoPlayer from '@components/VideoPlayer';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import type {AttachmentViewProps} from '..';

type AttachmentViewVideoProps = Pick<AttachmentViewProps, 'duration' | 'isHovered'> & {
Expand All @@ -12,13 +12,13 @@ type AttachmentViewVideoProps = Pick<AttachmentViewProps, 'duration' | 'isHovere
};

function AttachmentViewVideo({source, isHovered = false, shouldUseSharedVideoElement = false, duration = 0}: AttachmentViewVideoProps) {
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const styles = useThemeStyles();

return (
<VideoPlayer
url={source}
shouldUseSharedVideoElement={shouldUseSharedVideoElement && !isSmallScreenWidth}
shouldUseSharedVideoElement={shouldUseSharedVideoElement && !shouldUseNarrowLayout}
isVideoHovered={isHovered}
videoDuration={duration}
style={[styles.w100, styles.h100]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/AvatarCropModal/AvatarCropModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import cropOrRotateImage from '@libs/cropOrRotateImage';
import type {CustomRNImageManipulatorResult} from '@libs/cropOrRotateImage/types';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -65,7 +65,7 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
const isPressableEnabled = useSharedValue(true);

const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

// Check if image cropping, saving or uploading is in progress
const isLoading = useSharedValue(false);
Expand Down Expand Up @@ -350,7 +350,7 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
includeSafeAreaPaddingBottom={false}
testID={AvatarCropModal.displayName}
>
{isSmallScreenWidth && <HeaderGap />}
{shouldUseNarrowLayout && <HeaderGap />}
<HeaderWithBackButton
title={translate('avatarCropModal.title')}
onBackButtonPress={onClose}
Expand Down
4 changes: 2 additions & 2 deletions src/components/BigNumberPad.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useEffect, useRef, useState} from 'react';
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import ControlSelection from '@libs/ControlSelection';
import Button from './Button';

Expand Down Expand Up @@ -32,7 +32,7 @@ function BigNumberPad({numberPressed, longPressHandlerStateChanged = () => {}, i

const styles = useThemeStyles();
const [timer, setTimer] = useState<NodeJS.Timeout | null>(null);
const {isExtraSmallScreenHeight} = useWindowDimensions();
const {isExtraSmallScreenHeight} = useResponsiveLayout();
const numberPressedRef = useRef(numberPressed);

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ConfirmModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {ReactNode} from 'react';
import React from 'react';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import CONST from '@src/CONST';
import type IconAsset from '@src/types/utils/IconAsset';
import ConfirmContent from './ConfirmContent';
Expand Down Expand Up @@ -92,7 +92,7 @@ function ConfirmModal({
onConfirm,
image,
}: ConfirmModalProps) {
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const styles = useThemeStyles();

return (
Expand All @@ -102,7 +102,7 @@ function ConfirmModal({
isVisible={isVisible}
shouldSetModalVisibility={shouldSetModalVisibility}
onModalHide={onModalHide}
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM}
type={shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM}
innerContainerStyle={image ? styles.pt0 : {}}
>
<ConfirmContent
Expand Down
6 changes: 3 additions & 3 deletions src/components/DatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as Expensicons from '@components/Icon/Expensicons';
import TextInput from '@components/TextInput';
import type {BaseTextInputProps, BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as FormActions from '@userActions/FormActions';
import CONST from '@src/CONST';
import type {OnyxFormValuesMapping} from '@src/ONYXKEYS';
Expand Down Expand Up @@ -70,7 +70,7 @@ function DatePicker(
const {translate} = useLocalize();
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const [selectedDate, setSelectedDate] = useState(value || defaultValue || undefined);
const {isSmallScreenWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

const onSelected = (newValue: string) => {
onTouched?.();
Expand All @@ -93,7 +93,7 @@ function DatePicker(

return (
<View style={styles.datePickerRoot}>
<View style={[isSmallScreenWidth ? styles.flex2 : {}, styles.pointerEventsNone]}>
<View style={[shouldUseNarrowLayout ? styles.flex2 : {}, styles.pointerEventsNone]}>
<TextInput
ref={ref}
inputID={inputID}
Expand Down
8 changes: 5 additions & 3 deletions src/components/EmojiPicker/EmojiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {Emoji} from '@assets/emojis/types';
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
import withViewportOffsetTop from '@components/withViewportOffsetTop';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand Down Expand Up @@ -43,7 +44,8 @@ function EmojiPicker({viewportOffsetTop}: EmojiPickerProps, ref: ForwardedRef<Em
const onEmojiSelected = useRef<OnEmojiSelected>(() => {});
const activeEmoji = useRef<string | undefined>();
const emojiSearchInput = useRef<BaseTextInputRef | null>();
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();
const {windowHeight} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

/**
* Get the popover anchor ref
Expand Down Expand Up @@ -160,7 +162,7 @@ function EmojiPicker({viewportOffsetTop}: EmojiPickerProps, ref: ForwardedRef<Em
const emojiPopoverAnchor = getEmojiPopoverAnchor();
if (!emojiPopoverAnchor?.current) {
// In small screen width, the window size change might be due to keyboard open/hide, we should avoid hide EmojiPicker in those cases
if (isEmojiPickerVisible && !isSmallScreenWidth) {
if (isEmojiPickerVisible && !shouldUseNarrowLayout) {
hideEmojiPicker();
}
return;
Expand All @@ -182,7 +184,7 @@ function EmojiPicker({viewportOffsetTop}: EmojiPickerProps, ref: ForwardedRef<Em
}
emojiPopoverDimensionListener.remove();
};
}, [isEmojiPickerVisible, isSmallScreenWidth, emojiPopoverAnchorOrigin, getEmojiPopoverAnchor]);
}, [isEmojiPickerVisible, shouldUseNarrowLayout, emojiPopoverAnchorOrigin, getEmojiPopoverAnchor]);

// There is no way to disable animations, and they are really laggy, because there are so many
// emojis. The best alternative is to set it to 1ms so it just "pops" in and out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CategoryShortcutBar from '@components/EmojiPicker/CategoryShortcutBar';
import EmojiSkinToneList from '@components/EmojiPicker/EmojiSkinToneList';
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 type {EmojiPickerList, EmojiPickerListItem, HeaderIndice} from '@libs/EmojiUtils';
Expand Down Expand Up @@ -83,11 +84,12 @@ function BaseEmojiPickerMenu(
ref: ForwardedRef<FlashList<EmojiPickerListItem>>,
) {
const styles = useThemeStyles();
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
const {windowWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();

// Estimated list size should be a whole integer to avoid floating point precision errors
// More info: https://github.com/Expensify/App/issues/34522
const listWidth = isSmallScreenWidth ? Math.floor(windowWidth) : CONST.EMOJI_PICKER_SIZE.WIDTH;
const listWidth = shouldUseNarrowLayout ? Math.floor(windowWidth) : CONST.EMOJI_PICKER_SIZE.WIDTH;

const flattenListWrapperStyle = useMemo(() => StyleSheet.flatten(listWrapperStyle), [listWrapperStyle]);

Expand Down
6 changes: 4 additions & 2 deletions src/components/EmojiPicker/EmojiPickerMenu/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Text from '@components/Text';
import TextInput from '@components/TextInput';
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSingleExecution from '@hooks/useSingleExecution';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -23,7 +24,8 @@ import useEmojiPickerMenu from './useEmojiPickerMenu';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function EmojiPickerMenu({onEmojiSelected, activeEmoji}: EmojiPickerMenuProps, ref: ForwardedRef<BaseTextInputRef>) {
const styles = useThemeStyles();
const {windowWidth, isSmallScreenWidth} = useWindowDimensions();
const {windowWidth} = useWindowDimensions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {translate} = useLocalize();
const {singleExecution} = useSingleExecution();
const {
Expand Down Expand Up @@ -114,7 +116,7 @@ function EmojiPickerMenu({onEmojiSelected, activeEmoji}: EmojiPickerMenuProps, r
);

return (
<View style={[styles.emojiPickerContainer, StyleUtils.getEmojiPickerStyle(isSmallScreenWidth)]}>
<View style={[styles.emojiPickerContainer, StyleUtils.getEmojiPickerStyle(shouldUseNarrowLayout)]}>
<View style={[styles.ph4, styles.pb1, styles.pt2]}>
<TextInput
label={translate('common.search')}
Expand Down
Loading
Loading