import { Platform , TouchableNativeFeedbackProps , ColorValue , } from 'react-native' ; import * as React from 'react' ; import { Component } from 'react' ; import GenericTouchable , { GenericTouchableProps } from './GenericTouchable' ; export type TouchableNativeFeedbackExtraProps = { borderless ? : boolean ; rippleColor ? : number | null ; rippleRadius ? : number | null ; foreground ? : boolean ; } ; /**
 * TouchableNativeFeedback behaves slightly different than RN's TouchableNativeFeedback.
 * There's small difference with handling long press ripple since RN's implementation calls
 * ripple animation via bridge. This solution leaves all animations' handling for native components so
 * it follows native behaviours.
 */ export default class TouchableNativeFeedback extends Component < TouchableNativeFeedbackProps & GenericTouchableProps > { static defaultProps = { ... GenericTouchable . defaultProps , useForeground : true , extraButtonProps : { rippleColor : null , } , } ; static SelectableBackground = ( rippleRadius ? ) => ( { type : 'ThemeAttrAndroid' , attribute : 'selectableItemBackground' , rippleRadius , } ) ; static SelectableBackgroundBorderless = ( rippleRadius ? ) => ( { type : 'ThemeAttrAndroid' , attribute : 'selectableItemBackgroundBorderless' , rippleRadius , } ) ; static Ripple = ( color , borderless , rippleRadius ? ) => ( { type : 'RippleAndroid' , color , borderless , rippleRadius , } ) ; static canUseNativeForeground = ( ) => Platform . Version >= 23 ; getExtraButtonProps ( ) { const extraProps = { } ; const { background } = this . props ; if ( background ) { if ( background . type === 'RippleAndroid' ) { extraProps [ 'borderless' ] = background . borderless ; extraProps [ 'rippleColor' ] = background . color ; } else if ( background . type === 'ThemeAttrAndroid' ) { extraProps [ 'borderless' ] = background . attribute === 'selectableItemBackgroundBorderless' ; } extraProps [ 'rippleRadius' ] = background . rippleRadius ; } extraProps [ 'foreground' ] = this . props . useForeground ; return extraProps ; } render ( ) { const { style = { } , ... rest } = this . props ; return ( < GenericTouchable { ... rest } style = { style } extraButtonProps = { this . getExtraButtonProps ( ) } / > ) ; } }