diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index 328c53d8e87e..c95e26e21823 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -23,20 +23,27 @@ import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import {areAllModalsHidden, closeTop, onModalDidClose, setCloseModal, setModalVisibility, willAlertModalBecomeVisible} from '@userActions/Modal'; import CONST from '@src/CONST'; -import BottomDockedModal from './BottomDockedModal'; -import type ModalProps from './BottomDockedModal/types'; import ModalContent from './ModalContent'; import ModalContext from './ModalContext'; +import ReanimatedModal from './ReanimatedModal'; +import type ReanimatedModalProps from './ReanimatedModal/types'; import type BaseModalProps from './types'; -type ModalComponentProps = (ReactNativeModalProps | ModalProps) & { +const REANIMATED_MODAL_TYPES: Array> = [CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED, CONST.MODAL.MODAL_TYPE.FULLSCREEN]; + +type ModalComponentProps = (ReactNativeModalProps | ReanimatedModalProps) & { type?: ValueOf; }; function ModalComponent({type, ...props}: ModalComponentProps) { - if (type === CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED) { - // eslint-disable-next-line react/jsx-props-no-spreading - return ; + if (type && REANIMATED_MODAL_TYPES.includes(type)) { + return ( + + ); } // eslint-disable-next-line react/jsx-props-no-spreading return ; diff --git a/src/components/Modal/BottomDockedModal/Backdrop/index.tsx b/src/components/Modal/ReanimatedModal/Backdrop/index.tsx similarity index 96% rename from src/components/Modal/BottomDockedModal/Backdrop/index.tsx rename to src/components/Modal/ReanimatedModal/Backdrop/index.tsx index 0acc7423505f..629350ccb0a9 100644 --- a/src/components/Modal/BottomDockedModal/Backdrop/index.tsx +++ b/src/components/Modal/ReanimatedModal/Backdrop/index.tsx @@ -1,6 +1,6 @@ import React, {useMemo} from 'react'; import Animated, {Easing, Keyframe} from 'react-native-reanimated'; -import type {BackdropProps} from '@components/Modal/BottomDockedModal/types'; +import type {BackdropProps} from '@components/Modal/ReanimatedModal/types'; import {PressableWithoutFeedback} from '@components/Pressable'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; diff --git a/src/components/Modal/BottomDockedModal/Backdrop/index.web.tsx b/src/components/Modal/ReanimatedModal/Backdrop/index.web.tsx similarity index 97% rename from src/components/Modal/BottomDockedModal/Backdrop/index.web.tsx rename to src/components/Modal/ReanimatedModal/Backdrop/index.web.tsx index ac3e3032b594..6341e86862a5 100644 --- a/src/components/Modal/BottomDockedModal/Backdrop/index.web.tsx +++ b/src/components/Modal/ReanimatedModal/Backdrop/index.web.tsx @@ -1,7 +1,7 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import Animated, {Easing, Keyframe} from 'react-native-reanimated'; -import type {BackdropProps} from '@components/Modal/BottomDockedModal/types'; +import type {BackdropProps} from '@components/Modal/ReanimatedModal/types'; import {PressableWithoutFeedback} from '@components/Pressable'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; diff --git a/src/components/Modal/BottomDockedModal/Container/index.tsx b/src/components/Modal/ReanimatedModal/Container/index.tsx similarity index 80% rename from src/components/Modal/BottomDockedModal/Container/index.tsx rename to src/components/Modal/ReanimatedModal/Container/index.tsx index 475cc615c18a..d9035f20a078 100644 --- a/src/components/Modal/BottomDockedModal/Container/index.tsx +++ b/src/components/Modal/ReanimatedModal/Container/index.tsx @@ -1,13 +1,14 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import Animated, {Easing, Keyframe, runOnJS} from 'react-native-reanimated'; -import type ModalProps from '@components/Modal/BottomDockedModal/types'; -import type {ContainerProps} from '@components/Modal/BottomDockedModal/types'; +import type ReanimatedModalProps from '@components/Modal/ReanimatedModal/types'; +import type {ContainerProps} from '@components/Modal/ReanimatedModal/types'; import useThemeStyles from '@hooks/useThemeStyles'; +import CONST from '@src/CONST'; const easing = Easing.bezier(0.76, 0.0, 0.24, 1.0).factory(); -function Container({style, animationInTiming = 300, animationOutTiming = 300, onCloseCallBack, onOpenCallBack, ...props}: Partial & ContainerProps) { +function Container({style, animationInTiming = 300, animationOutTiming = 300, onCloseCallBack, onOpenCallBack, type, ...props}: Partial & ContainerProps) { const styles = useThemeStyles(); const Entering = useMemo(() => { @@ -49,7 +50,7 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on {...props} > diff --git a/src/components/Modal/BottomDockedModal/Container/index.web.tsx b/src/components/Modal/ReanimatedModal/Container/index.web.tsx similarity index 87% rename from src/components/Modal/BottomDockedModal/Container/index.web.tsx rename to src/components/Modal/ReanimatedModal/Container/index.web.tsx index 6a04310d3275..deebf5e65fb4 100644 --- a/src/components/Modal/BottomDockedModal/Container/index.web.tsx +++ b/src/components/Modal/ReanimatedModal/Container/index.web.tsx @@ -1,12 +1,12 @@ import React, {useEffect, useMemo, useRef} from 'react'; import Animated, {Easing, Keyframe, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; -import type ModalProps from '@components/Modal/BottomDockedModal/types'; -import type {ContainerProps} from '@components/Modal/BottomDockedModal/types'; +import type ReanimatedModalProps from '@components/Modal/ReanimatedModal/types'; +import type {ContainerProps} from '@components/Modal/ReanimatedModal/types'; import useThemeStyles from '@hooks/useThemeStyles'; const easing = Easing.bezier(0.76, 0.0, 0.24, 1.0).factory(); -function Container({style, animationInTiming = 300, animationOutTiming = 300, onOpenCallBack, onCloseCallBack, ...props}: ModalProps & ContainerProps) { +function Container({style, animationInTiming = 300, animationOutTiming = 300, onOpenCallBack, onCloseCallBack, ...props}: ReanimatedModalProps & ContainerProps) { const styles = useThemeStyles(); const onCloseCallbackRef = useRef(onCloseCallBack); const opacity = useSharedValue(0); diff --git a/src/components/Modal/BottomDockedModal/index.tsx b/src/components/Modal/ReanimatedModal/index.tsx similarity index 97% rename from src/components/Modal/BottomDockedModal/index.tsx rename to src/components/Modal/ReanimatedModal/index.tsx index 27d16d12abc6..ba611581f75e 100644 --- a/src/components/Modal/BottomDockedModal/index.tsx +++ b/src/components/Modal/ReanimatedModal/index.tsx @@ -9,9 +9,9 @@ import getPlatform from '@libs/getPlatform'; import CONST from '@src/CONST'; import Backdrop from './Backdrop'; import Container from './Container'; -import type ModalProps from './types'; +import type ReanimatedModalProps from './types'; -function BottomDockedModal({ +function ReanimatedModal({ testID, animationInDelay, animationInTiming = 300, @@ -32,9 +32,10 @@ function BottomDockedModal({ onBackdropPress = noop, onBackButtonPress = noop, style, + type, statusBarTranslucent = false, ...props -}: ModalProps) { +}: ReanimatedModalProps) { const [isVisibleState, setIsVisibleState] = useState(isVisible); const [isContainerOpen, setIsContainerOpen] = useState(false); const [isTransitioning, setIsTransitioning] = useState(false); @@ -141,6 +142,7 @@ function BottomDockedModal({ onOpenCallBack={onOpenCallBack} onCloseCallBack={onCloseCallBack} style={style} + type={type} > {children} @@ -207,6 +209,6 @@ function BottomDockedModal({ ); } -BottomDockedModal.displayName = 'BottomDockedModal'; +ReanimatedModal.displayName = 'ReanimatedModal'; -export default BottomDockedModal; +export default ReanimatedModal; diff --git a/src/components/Modal/BottomDockedModal/types.ts b/src/components/Modal/ReanimatedModal/types.ts similarity index 96% rename from src/components/Modal/BottomDockedModal/types.ts rename to src/components/Modal/ReanimatedModal/types.ts index 89f28a2873ab..1eaf8d5898e6 100644 --- a/src/components/Modal/BottomDockedModal/types.ts +++ b/src/components/Modal/ReanimatedModal/types.ts @@ -3,6 +3,7 @@ import type {NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle} from 'react- import type {ModalProps as ReactNativeModalProps} from 'react-native-modal'; import type {SharedValue} from 'react-native-reanimated'; import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; type GestureProps = { /** Height of the device (used for positioning) */ @@ -14,7 +15,7 @@ type GestureProps = { type AnimationOut = ValueOf>; -type ModalProps = ViewProps & +type ReanimatedModalProps = ViewProps & GestureProps & { /** Content inside the modal */ children: ReactNode; @@ -115,6 +116,9 @@ type ModalProps = ViewProps & supportedOrientations?: Array<'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right'>; navigationBarTranslucent?: boolean; + + /** Modal type */ + type?: ValueOf; }; type BackdropProps = { @@ -154,5 +158,5 @@ type ContainerProps = { panPosition?: {translateX: SharedValue; translateY: SharedValue}; }; -export default ModalProps; +export default ReanimatedModalProps; export type {BackdropProps, ContainerProps, AnimationOut}; diff --git a/src/components/Modal/types.ts b/src/components/Modal/types.ts index fe387dd50175..87dc9af1609c 100644 --- a/src/components/Modal/types.ts +++ b/src/components/Modal/types.ts @@ -3,7 +3,7 @@ import type {GestureResponderEvent, PanResponderGestureState, ViewStyle} from 'r import type {Direction, ModalProps as ReactNativeModalProps} from 'react-native-modal'; import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; -import type BottomDockedModalProps from './BottomDockedModal/types'; +import type ReanimatedModalProps from './ReanimatedModal/types'; type FocusTrapOptions = Exclude; @@ -19,7 +19,7 @@ type WindowState = { }; type BaseModalProps = Partial & - Partial & { + Partial & { /** Decides whether the modal should cover fullscreen. FullScreen modal has backdrop */ fullscreen?: boolean; diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx index b5e7eff18aee..d0b725933b12 100644 --- a/src/components/PopoverMenu.tsx +++ b/src/components/PopoverMenu.tsx @@ -25,7 +25,7 @@ import FocusTrapForModal from './FocusTrap/FocusTrapForModal'; import * as Expensicons from './Icon/Expensicons'; import type {MenuItemProps} from './MenuItem'; import MenuItem from './MenuItem'; -import type BottomDockedModalProps from './Modal/BottomDockedModal/types'; +import type ReanimatedModalProps from './Modal/ReanimatedModal/types'; import type BaseModalProps from './Modal/types'; import OfflineWithFeedback from './OfflineWithFeedback'; import PopoverWithMeasuredContent from './PopoverWithMeasuredContent'; @@ -69,7 +69,7 @@ type PopoverMenuItem = MenuItemProps & { testID?: string; }; -type PopoverModalProps = Pick & Pick; +type PopoverModalProps = Pick & Pick; type PopoverMenuProps = Partial & { /** Callback method fired when the user requests to close the modal */ diff --git a/src/pages/settings/Subscription/SubscriptionPlan/ComparePlansModal.tsx b/src/pages/settings/Subscription/SubscriptionPlan/ComparePlansModal.tsx index 32da7f04a9b9..048c3cf933fa 100644 --- a/src/pages/settings/Subscription/SubscriptionPlan/ComparePlansModal.tsx +++ b/src/pages/settings/Subscription/SubscriptionPlan/ComparePlansModal.tsx @@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import Modal from '@components/Modal'; -import type {AnimationOut} from '@components/Modal/BottomDockedModal/types'; +import type {AnimationOut} from '@components/Modal/ReanimatedModal/types'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; diff --git a/src/styles/utils/generators/ModalStyleUtils.ts b/src/styles/utils/generators/ModalStyleUtils.ts index 2b9684622bc7..a3561ee7621c 100644 --- a/src/styles/utils/generators/ModalStyleUtils.ts +++ b/src/styles/utils/generators/ModalStyleUtils.ts @@ -66,6 +66,7 @@ const createModalStyleUtils: StyleUtilGenerator = ({the switch (type) { case CONST.MODAL.MODAL_TYPE.FULLSCREEN: + modalStyle = {...modalStyle, height: '100%'}; modalContainerStyle = {}; swipeDirection = 'down'; animationIn = 'slideInUp';