// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {memo} from 'react'; import {PanResponder, Touchable, TouchableHighlight, TouchableOpacity, TouchableWithoutFeedback, View} from 'react-native'; type TouchableProps = Touchable & { cancelTouchOnPanning: boolean; children: React.ReactNode | React.ReactNode[]; testID: string; type: 'native' | 'opacity' | 'none'; } const TouchableWithFeedbackIOS = ({testID, children, type = 'native', cancelTouchOnPanning, ...props}: TouchableProps) => { const panResponder = React.useRef(PanResponder.create({ onMoveShouldSetPanResponderCapture: (evt, gestureState) => { return cancelTouchOnPanning && (gestureState.dx >= 5 || gestureState.dy >= 5 || gestureState.vx > 5); }, })); switch (type) { case 'native': return ( {children} ); case 'opacity': return ( {children} ); default: return ( {children} ); } }; export default memo(TouchableWithFeedbackIOS);