Skip to content

Commit 5f9028b

Browse files
authored
Merge pull request Expensify#68729 from software-mansion-labs/chore/centered-modals-migration-cleanup
Centered modals migration cleanup
2 parents 19c88b2 + c1d9ebf commit 5f9028b

8 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/components/ConnectToQuickbooksOnlineFlow/index.native.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function ConnectToQuickbooksOnlineFlow({policyID}: ConnectToQuickbooksOnlineFlow
3535
fullscreen
3636
isVisible={isWebViewOpen}
3737
type={CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE}
38-
shouldUseReanimatedModal
3938
>
4039
<HeaderWithBackButton
4140
title={translate('workspace.accounting.title')}

src/components/ConnectToXeroFlow/index.native.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function ConnectToXeroFlow({policyID}: ConnectToXeroFlowProps) {
5656
fullscreen
5757
isVisible={isWebViewOpen}
5858
type={CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE}
59-
shouldUseReanimatedModal
6059
>
6160
<HeaderWithBackButton
6261
title={translate('workspace.accounting.title')}

src/components/FeatureTrainingModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ function FeatureTrainingModal({
420420
}
421421
onHelp();
422422
}}
423-
shouldUseReanimatedModal
424423
shouldDisableBottomSafeAreaPadding={shouldUseScrollView}
425424
>
426425
<Wrapper

src/components/Modal/BaseModal.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ import type ReanimatedModalProps from './ReanimatedModal/types';
3333
import type BaseModalProps from './types';
3434
import type {FocusTrapOptions} from './types';
3535

36-
const REANIMATED_MODAL_TYPES: Array<ValueOf<typeof CONST.MODAL.MODAL_TYPE>> = [CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED, CONST.MODAL.MODAL_TYPE.FULLSCREEN, CONST.MODAL.MODAL_TYPE.POPOVER];
36+
const REANIMATED_MODAL_TYPES: Array<ValueOf<typeof CONST.MODAL.MODAL_TYPE>> = [
37+
CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED,
38+
CONST.MODAL.MODAL_TYPE.FULLSCREEN,
39+
CONST.MODAL.MODAL_TYPE.POPOVER,
40+
CONST.MODAL.MODAL_TYPE.CENTERED,
41+
CONST.MODAL.MODAL_TYPE.CENTERED_SMALL,
42+
CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE,
43+
CONST.MODAL.MODAL_TYPE.CENTERED_SWIPEABLE_TO_RIGHT,
44+
];
3745

3846
type ModalComponentProps = (ReactNativeModalProps | ReanimatedModalProps) & {
3947
type?: ValueOf<typeof CONST.MODAL.MODAL_TYPE>;
@@ -374,7 +382,9 @@ function BaseModal(
374382
);
375383

376384
const animationInProps = useMemo(() => {
377-
if (disableAnimationIn) {
385+
// disableAnimationIn applies only to legacy modals. This should be removed once we fully migrate to `reanimated-modal`.
386+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
387+
if (disableAnimationIn && ((type && !REANIMATED_MODAL_TYPES.includes(type)) || !shouldUseReanimatedModal)) {
378388
// We need to apply these animation props to completely disable the "animation in". Simply setting it to 0 and undefined will not work.
379389
// Based on: https://github.com/react-native-modal/react-native-modal/issues/191
380390
return {
@@ -388,7 +398,7 @@ function BaseModal(
388398
animationInDelay,
389399
animationInTiming,
390400
};
391-
}, [animationIn, animationInDelay, animationInTiming, disableAnimationIn, modalStyleAnimationIn]);
401+
}, [animationIn, animationInDelay, animationInTiming, disableAnimationIn, modalStyleAnimationIn, shouldUseReanimatedModal, type]);
392402

393403
// In Modals we need to reset the ScreenWrapperOfflineIndicatorContext to allow nested ScreenWrapper components to render offline indicators,
394404
// except if we are in a narrow pane navigator. In this case, we use the narrow pane's original values.

src/components/Search/SearchRouter/SearchRouterModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Modal from '@components/Modal';
44
import ScreenWrapperContainer from '@components/ScreenWrapper/ScreenWrapperContainer';
55
import useResponsiveLayout from '@hooks/useResponsiveLayout';
66
import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
7-
import {isMobileChrome, isMobileIOS} from '@libs/Browser';
7+
import {isMobileIOS} from '@libs/Browser';
88
import CONST from '@src/CONST';
99
import SearchRouter from './SearchRouter';
1010
import {useSearchRouterContext} from './SearchRouterContext';
@@ -35,7 +35,6 @@ function SearchRouterModal() {
3535
onModalShow={() => setShouldHideInputCaret(false)}
3636
shouldApplySidePanelOffset={!shouldUseNarrowLayout}
3737
enableEdgeToEdgeBottomSafeAreaPadding
38-
shouldUseReanimatedModal={shouldUseNarrowLayout && !isMobileChrome()}
3938
>
4039
<ScreenWrapperContainer
4140
testID={SearchRouterModal.displayName}

src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ function AttachmentModalContainer({contentProps, modalType, onShow, onClose, sho
6262
}}
6363
shouldHandleNavigationBack={shouldHandleNavigationBack}
6464
onClose={closeModal}
65-
shouldUseReanimatedModal
6665
enableEdgeToEdgeBottomSafeAreaPadding
6766
>
6867
<AttachmentModalBaseContent

src/pages/settings/Subscription/CardAuthenticationModal/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModa
6767
type={CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE}
6868
isVisible={isVisible}
6969
onClose={onModalClose}
70-
onModalHide={onModalClose}
71-
shouldUseReanimatedModal
7270
>
7371
<ScreenWrapper
7472
style={styles.pb0}

src/pages/settings/Subscription/SubscriptionPlan/ComparePlansModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function ComparePlansModal({isModalVisible, setIsModalVisible}: ComparePlansModa
7272
onClose={onClose}
7373
animationOut={isSmallScreenWidth ? animationOut : undefined}
7474
innerContainerStyle={isSmallScreenWidth ? {...safeAreaPaddingBottomStyle, maxHeight} : {...styles.workspaceSection, ...safeAreaPaddingBottomStyle, maxHeight}}
75-
shouldUseReanimatedModal
7675
>
7776
<HeaderWithBackButton
7877
title={translate('subscription.compareModal.comparePlans')}

0 commit comments

Comments
 (0)