import * as React from 'react' ; import { PropsWithChildren , ForwardedRef , RefAttributes , ReactElement , } from 'react' ; import { ScrollView as RNScrollView , ScrollViewProps as RNScrollViewProps , Switch as RNSwitch , SwitchProps as RNSwitchProps , TextInput as RNTextInput , TextInputProps as RNTextInputProps , DrawerLayoutAndroid as RNDrawerLayoutAndroid , DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps , FlatList as RNFlatList , FlatListProps as RNFlatListProps , } from 'react-native' ; import createNativeWrapper from '../handlers/createNativeWrapper' ; import { NativeViewGestureHandlerProps , nativeViewProps , } from '../handlers/NativeViewGestureHandler' ; export const ScrollView = createNativeWrapper < PropsWithChildren < RNScrollViewProps > > ( RNScrollView , { disallowInterruption : true , shouldCancelWhenOutside : false , } ) ; export type ScrollView = typeof ScrollView & RNScrollView ; export const Switch = createNativeWrapper < RNSwitchProps > ( RNSwitch , { shouldCancelWhenOutside : false , shouldActivateOnStart : true , disallowInterruption : true , } ) ; export type Switch = typeof Switch & RNSwitch ; export const TextInput = createNativeWrapper < RNTextInputProps > ( RNTextInput ) ; export type TextInput = typeof TextInput & RNTextInput ; export const DrawerLayoutAndroid = createNativeWrapper < PropsWithChildren < RNDrawerLayoutAndroidProps > > ( RNDrawerLayoutAndroid , { disallowInterruption : true } ) ; export type DrawerLayoutAndroid = typeof DrawerLayoutAndroid & RNDrawerLayoutAndroid ; export const FlatList = React . forwardRef ( ( props , ref ) => { const flatListProps = { } ; const scrollViewProps = { } ; for ( const [ propName , value ] of Object . entries ( props ) ) { if ( ( nativeViewProps as readonly string [ ] ) . includes ( propName ) ) { scrollViewProps [ propName ] = value ; } else { flatListProps [ propName ] = value ; } } return ( < RNFlatList ref = { ref } { ... flatListProps } renderScrollComponent = { ( scrollProps ) => ( < ScrollView { ... { ... scrollProps , ... scrollViewProps } } / > ) } />); } ) as < ItemT = any > ( props : PropsWithChildren < RNFlatListProps < ItemT > & RefAttributes < FlatList < ItemT > > & NativeViewGestureHandlerProps > , ref : ForwardedRef < FlatList < ItemT > > ) => ReactElement | null ; export type FlatList < ItemT = any > = typeof FlatList & RNFlatList < ItemT > ;