Skip to content
Merged
Changes from all commits
Commits
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 @@ -3,12 +3,14 @@ import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Modal from '@components/Modal';
import type {AnimationOut} from '@components/Modal/ReanimatedModal/types';
import SafeAreaConsumer from '@components/SafeAreaConsumer';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import CONST from '@src/CONST';
import SubscriptionPlanCard from './SubscriptionPlanCard';

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

const maxHeight = isSmallScreenWidth ? undefined : windowHeight - 40;

return (
<Modal
isVisible={isModalVisible}
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.CENTERED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
onClose={() => setIsModalVisible(false)}
animationOut={isSmallScreenWidth ? animationOut : undefined}
innerContainerStyle={isSmallScreenWidth ? undefined : styles.workspaceSection}
>
<HeaderWithBackButton
title={translate('subscription.compareModal.comparePlans')}
shouldShowCloseButton
onCloseButtonPress={() => setIsModalVisible(false)}
shouldShowBackButton={false}
style={isSmallScreenWidth ? styles.pl4 : [styles.pr3, styles.pl8]}
/>
{isSmallScreenWidth ? <ScrollView addBottomSafeAreaPadding>{renderPlans()}</ScrollView> : renderPlans()}
</Modal>
<SafeAreaConsumer>
{({safeAreaPaddingBottomStyle}) => (
<Modal
isVisible={isModalVisible}
type={isSmallScreenWidth ? CONST.MODAL.MODAL_TYPE.CENTERED : CONST.MODAL.MODAL_TYPE.CENTERED_SMALL}
onClose={() => setIsModalVisible(false)}
animationOut={isSmallScreenWidth ? animationOut : undefined}
innerContainerStyle={isSmallScreenWidth ? {...safeAreaPaddingBottomStyle, maxHeight} : {...styles.workspaceSection, ...safeAreaPaddingBottomStyle, maxHeight}}
>
<HeaderWithBackButton
title={translate('subscription.compareModal.comparePlans')}
shouldShowCloseButton
onCloseButtonPress={() => setIsModalVisible(false)}
shouldShowBackButton={false}
style={isSmallScreenWidth ? styles.pl4 : [styles.pr3, styles.pl8]}
/>
<ScrollView>{renderPlans()}</ScrollView>
</Modal>
)}
</SafeAreaConsumer>
);
}

Expand Down
Loading