Skip to content

Commit 6e585c9

Browse files
Merge pull request Expensify#65924 from Krishna2323/krishna2323/issue/64948
fix: Web - Subscription- The top of explore plans does not scroll if the screen size is increased.
2 parents e535b64 + 8ad0b65 commit 6e585c9

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

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

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {View} from 'react-native';
33
import HeaderWithBackButton from '@components/HeaderWithBackButton';
44
import Modal from '@components/Modal';
55
import type {AnimationOut} from '@components/Modal/ReanimatedModal/types';
6+
import SafeAreaConsumer from '@components/SafeAreaConsumer';
67
import ScrollView from '@components/ScrollView';
78
import Text from '@components/Text';
89
import TextLink from '@components/TextLink';
910
import useLocalize from '@hooks/useLocalize';
1011
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1112
import useThemeStyles from '@hooks/useThemeStyles';
13+
import useWindowDimensions from '@hooks/useWindowDimensions';
1214
import CONST from '@src/CONST';
1315
import SubscriptionPlanCard from './SubscriptionPlanCard';
1416

@@ -23,6 +25,7 @@ type ComparePlansModalProps = {
2325
function ComparePlansModal({isModalVisible, setIsModalVisible}: ComparePlansModalProps) {
2426
const styles = useThemeStyles();
2527
const {translate} = useLocalize();
28+
const {windowHeight} = useWindowDimensions();
2629
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to be consistent with BaseModal component
2730
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
2831
const {isSmallScreenWidth} = useResponsiveLayout();
@@ -59,23 +62,29 @@ function ComparePlansModal({isModalVisible, setIsModalVisible}: ComparePlansModa
5962
</View>
6063
);
6164

65+
const maxHeight = isSmallScreenWidth ? undefined : windowHeight - 40;
66+
6267
return (
63-
<Modal
64-
isVisible={isModalVisible}
65-
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.CENTERED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
66-
onClose={() => setIsModalVisible(false)}
67-
animationOut={isSmallScreenWidth ? animationOut : undefined}
68-
innerContainerStyle={isSmallScreenWidth ? undefined : styles.workspaceSection}
69-
>
70-
<HeaderWithBackButton
71-
title={translate('subscription.compareModal.comparePlans')}
72-
shouldShowCloseButton
73-
onCloseButtonPress={() => setIsModalVisible(false)}
74-
shouldShowBackButton={false}
75-
style={isSmallScreenWidth ? styles.pl4 : [styles.pr3, styles.pl8]}
76-
/>
77-
{isSmallScreenWidth ? <ScrollView addBottomSafeAreaPadding>{renderPlans()}</ScrollView> : renderPlans()}
78-
</Modal>
68+
<SafeAreaConsumer>
69+
{({safeAreaPaddingBottomStyle}) => (
70+
<Modal
71+
isVisible={isModalVisible}
72+
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.CENTERED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
73+
onClose={() => setIsModalVisible(false)}
74+
animationOut={isSmallScreenWidth ? animationOut : undefined}
75+
innerContainerStyle={isSmallScreenWidth ? {...safeAreaPaddingBottomStyle, maxHeight} : {...styles.workspaceSection, ...safeAreaPaddingBottomStyle, maxHeight}}
76+
>
77+
<HeaderWithBackButton
78+
title={translate('subscription.compareModal.comparePlans')}
79+
shouldShowCloseButton
80+
onCloseButtonPress={() => setIsModalVisible(false)}
81+
shouldShowBackButton={false}
82+
style={isSmallScreenWidth ? styles.pl4 : [styles.pr3, styles.pl8]}
83+
/>
84+
<ScrollView>{renderPlans()}</ScrollView>
85+
</Modal>
86+
)}
87+
</SafeAreaConsumer>
7988
);
8089
}
8190

0 commit comments

Comments
 (0)