import * as _ from 'lodash' ; import * as React from 'react' ; import { ScrollView , ScrollViewProperties } from 'react-native' ; import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view' ; import { FixedTouchableWithoutFeedback } from './FixedTouchableWithoutFeedback' ; class DecorateScrollView extends React . Component < ScrollViewProperties & { forwardedRef ? : any ; keyboardAware ? : boolean ; fixScrollingInsideTouchable ? : boolean ; } > { private renderChildren ( ) { if ( typeof this . props . fixScrollingInsideTouchable === 'undefined' || this . props . fixScrollingInsideTouchable === true ) { if ( this . props . horizontal === true && _ . isArray ( this . props . children ) ) { return ( < React . Fragment > { this . props . children . map ( ( child , index ) : React . ReactElement < any > => { return ( < FixedTouchableWithoutFeedback key = { _ . get ( child , 'key' ) || index } > { child } < /FixedTouchableWithoutFeedback>); } ) } < /React.Fragment>); } else { return ( < FixedTouchableWithoutFeedback > { this . props . children } < /FixedTouchableWithoutFeedback>); } } else { return this . props . children ; } } public render ( ) { const { forwardedRef , ... rest } = this . props ; const children = this . renderChildren ( ) ; if ( this . props . keyboardAware === true ) { return ( < KeyboardAwareScrollView enableOnAndroid = { true } ref = { forwardedRef } { ... rest } > { children } < /KeyboardAwareScrollView>); } else { return ( < ScrollView ref = { forwardedRef } { ... rest } > { children } < /ScrollView>); } } } export const SmartScrollView = React . forwardRef ( function decorateScrollView ( props , ref ) : React . ReactElement < any > { return ( < DecorateScrollView forwardedRef = { ref } { ... props } > { props . children } < /DecorateScrollView>); } ) ;