Skip to content

Commit bcf8dbb

Browse files
authored
Merge pull request Expensify#66868 from software-mansion-labs/feat/reanimated-modal-for-compare-plans-modal
Migrate ComparePlansModal
2 parents 198d552 + 50c1875 commit bcf8dbb

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
55
import Modal from '@components/Modal';
66
import ScreenWrapper from '@components/ScreenWrapper';
77
import useOnyx from '@hooks/useOnyx';
8+
import useResponsiveLayout from '@hooks/useResponsiveLayout';
89
import useThemeStyles from '@hooks/useThemeStyles';
910
import {clearPaymentCard3dsVerification, verifySetupIntent} from '@userActions/PaymentMethods';
1011
import {verifySetupIntentAndRequestPolicyOwnerChange} from '@userActions/Policy/Policy';
@@ -19,6 +20,9 @@ type CardAuthenticationModalProps = {
1920
};
2021
function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModalProps) {
2122
const styles = useThemeStyles();
23+
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to be consistent with BaseModal component
24+
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
25+
const {isSmallScreenWidth} = useResponsiveLayout();
2226
const [authenticationLink] = useOnyx(ONYXKEYS.VERIFY_3DS_SUBSCRIPTION, {canBeMissing: true});
2327
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
2428
const [isLoading, setIsLoading] = useState(true);
@@ -75,9 +79,10 @@ function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModa
7579
<HeaderWithBackButton
7680
title={headerTitle}
7781
shouldShowBorderBottom
78-
shouldShowCloseButton
82+
shouldShowCloseButton={!isSmallScreenWidth}
7983
onCloseButtonPress={onModalClose}
80-
shouldShowBackButton={false}
84+
shouldShowBackButton={isSmallScreenWidth}
85+
onBackButtonPress={onModalClose}
8186
shouldDisplayHelpButton={false}
8287
/>
8388
{isLoading && <FullScreenLoadingIndicator />}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ function ComparePlansModal({isModalVisible, setIsModalVisible}: ComparePlansModa
4040
setIsModalVisible(false);
4141
};
4242

43+
const onClose = () => setIsModalVisible(false);
44+
4345
const renderPlans = () => (
4446
<View style={isSmallScreenWidth ? [styles.ph4, styles.pb8] : [styles.ph8, styles.pb8]}>
4547
<Text style={[styles.textLabelSupporting, styles.textNormal]}>
@@ -70,15 +72,17 @@ function ComparePlansModal({isModalVisible, setIsModalVisible}: ComparePlansModa
7072
<Modal
7173
isVisible={isModalVisible}
7274
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.CENTERED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
73-
onClose={() => setIsModalVisible(false)}
75+
onClose={onClose}
7476
animationOut={isSmallScreenWidth ? animationOut : undefined}
7577
innerContainerStyle={isSmallScreenWidth ? {...safeAreaPaddingBottomStyle, maxHeight} : {...styles.workspaceSection, ...safeAreaPaddingBottomStyle, maxHeight}}
78+
shouldUseReanimatedModal
7679
>
7780
<HeaderWithBackButton
7881
title={translate('subscription.compareModal.comparePlans')}
79-
shouldShowCloseButton
80-
onCloseButtonPress={() => setIsModalVisible(false)}
81-
shouldShowBackButton={false}
82+
shouldShowCloseButton={!isSmallScreenWidth}
83+
onCloseButtonPress={onClose}
84+
shouldShowBackButton={isSmallScreenWidth}
85+
onBackButtonPress={onClose}
8286
style={isSmallScreenWidth ? styles.pl4 : [styles.pr3, styles.pl8]}
8387
shouldDisplayHelpButton={false}
8488
/>

src/styles/utils/generators/ModalStyleUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ const createModalStyleUtils: StyleUtilGenerator<GetModalStylesStyleUtil> = ({the
208208
boxShadow: theme.shadow,
209209
borderRadius: variables.componentBorderRadiusLarge,
210210
borderWidth: 0,
211+
marginTop: 'auto',
212+
marginBottom: 'auto',
211213
};
212214

213215
// Allow this modal to be dismissed with a swipe down or swipe right

0 commit comments

Comments
 (0)