@@ -2,14 +2,26 @@ import React, {useEffect, useMemo, useRef} from 'react';
22import Animated , { Easing , Keyframe , useAnimatedStyle , useSharedValue , withTiming } from 'react-native-reanimated' ;
33import type ReanimatedModalProps from '@components/Modal/ReanimatedModal/types' ;
44import type { ContainerProps } from '@components/Modal/ReanimatedModal/types' ;
5+ import { getModalInAnimationStyle , getModalOutAnimation } from '@components/Modal/ReanimatedModal/utils' ;
56import useThemeStyles from '@hooks/useThemeStyles' ;
7+ import CONST from '@src/CONST' ;
68
79const easing = Easing . bezier ( 0.76 , 0.0 , 0.24 , 1.0 ) . factory ( ) ;
810
9- function Container ( { style, animationInTiming = 300 , animationOutTiming = 300 , onOpenCallBack, onCloseCallBack, ...props } : ReanimatedModalProps & ContainerProps ) {
11+ function Container ( {
12+ style,
13+ animationIn,
14+ animationOut,
15+ animationInTiming = CONST . MODAL . ANIMATION_TIMING . DEFAULT_IN ,
16+ animationOutTiming = CONST . MODAL . ANIMATION_TIMING . DEFAULT_OUT ,
17+ onOpenCallBack,
18+ onCloseCallBack,
19+ type,
20+ ...props
21+ } : ReanimatedModalProps & ContainerProps ) {
1022 const styles = useThemeStyles ( ) ;
1123 const onCloseCallbackRef = useRef ( onCloseCallBack ) ;
12- const opacity = useSharedValue ( 0 ) ;
24+ const initProgress = useSharedValue ( 0 ) ;
1325 const isInitiated = useSharedValue ( false ) ;
1426
1527 useEffect ( ( ) => {
@@ -21,27 +33,22 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on
2133 return ;
2234 }
2335 isInitiated . set ( true ) ;
24- opacity . set ( withTiming ( 1 , { duration : animationInTiming , easing} , onOpenCallBack ) ) ;
25- } , [ animationInTiming , onOpenCallBack , opacity , isInitiated ] ) ;
36+ initProgress . set ( withTiming ( 1 , { duration : animationInTiming , easing} , onOpenCallBack ) ) ;
37+ } , [ animationInTiming , onOpenCallBack , initProgress , isInitiated ] ) ;
2638
27- const animatedStyles = useAnimatedStyle ( ( ) => ( { opacity : opacity . get ( ) } ) , [ opacity ] ) ;
39+ // instead of an entering transition since keyframe animations break keyboard on mWeb Chrome (#62799)
40+ const animatedStyles = useAnimatedStyle ( ( ) => getModalInAnimationStyle ( animationIn ) ( initProgress . get ( ) ) , [ initProgress ] ) ;
2841
2942 const Exiting = useMemo ( ( ) => {
30- const FadeOut = new Keyframe ( {
31- from : { opacity : 1 } ,
32- to : {
33- opacity : 0 ,
34- easing,
35- } ,
36- } ) ;
43+ const AnimationOut = new Keyframe ( getModalOutAnimation ( animationOut ) ) ;
3744
3845 // eslint-disable-next-line react-compiler/react-compiler
39- return FadeOut . duration ( animationOutTiming ) . withCallback ( ( ) => onCloseCallbackRef . current ( ) ) ;
40- } , [ animationOutTiming ] ) ;
46+ return AnimationOut . duration ( animationOutTiming ) . withCallback ( ( ) => onCloseCallbackRef . current ( ) ) ;
47+ } , [ animationOutTiming , animationOut ] ) ;
4148
4249 return (
4350 < Animated . View
44- style = { [ style , styles . modalContainer , styles . modalAnimatedContainer , animatedStyles ] }
51+ style = { [ style , styles . modalContainer , type !== CONST . MODAL . MODAL_TYPE . RIGHT_DOCKED && styles . modalAnimatedContainer , animatedStyles , { zIndex : 1 } ] }
4552 exiting = { Exiting }
4653 // eslint-disable-next-line react/jsx-props-no-spreading
4754 { ...props }
0 commit comments