import * as React from 'react'; import type { PropsWithChildren } from 'react'; import type { ViewProps } from 'react-native'; import Animated, { AnimateProps } from 'react-native-reanimated'; import { AnimatedEntryViewStyle, AnimatedExitViewStyle, ToAnimation, useReanimatedAnimationBuilder, } from '../hooks/useReanimatedAnimationBuilder'; import { AutofocusContainer } from './AutofocusContainer'; type UseReanimated = Omit, 'entering' | 'exiting'> & { autofocus?: boolean; duration?: number; from: AnimatedEntryViewStyle; exitFrom?: AnimatedExitViewStyle; exitTo?: ToAnimation; to: ToAnimation; style?: Pick; }; export const AnimatedContainer = React.forwardRef< Animated.View, PropsWithChildren >( ( { from, to, exitFrom, exitTo, duration = 300, style, autofocus, children, ...rest }, forwardRef, ) => { const { entering, exiting } = useReanimatedAnimationBuilder({ from, to, exitFrom, exitTo, duration, }); const Wrapper = autofocus ? AutofocusContainer : React.Fragment; return ( {children} ); }, );