|
1 | 1 | import _ from 'lodash'; |
2 | | -import React, {BaseSyntheticEvent, PureComponent} from 'react'; |
3 | | -import {TouchableOpacity as RNTouchableOpacity, TouchableOpacityProps as RNTouchableOpacityProps} from 'react-native'; |
| 2 | +import React, {PureComponent} from 'react'; |
| 3 | +import { |
| 4 | + GestureResponderEvent, |
| 5 | + TouchableOpacity as RNTouchableOpacity, |
| 6 | + TouchableOpacityProps as RNTouchableOpacityProps |
| 7 | +} from 'react-native'; |
4 | 8 | import { |
5 | 9 | asBaseComponent, |
6 | 10 | forwardRef, |
@@ -43,10 +47,16 @@ export interface TouchableOpacityProps |
43 | 47 | */ |
44 | 48 | customValue?: any; |
45 | 49 | style?: ViewProps['style']; |
46 | | - onPress?: (props?: TouchableOpacityProps | any) => void; |
47 | | - onPressIn?: (props?: TouchableOpacityProps | any) => void | RNTouchableOpacityProps['onPressIn']; |
48 | | - onPressOut?: (props?: TouchableOpacityProps | any) => void | RNTouchableOpacityProps['onPressOut']; |
49 | | - onLongPress?: (props?: TouchableOpacityProps | any) => void | RNTouchableOpacityProps['onLongPress']; |
| 50 | + onPress?: (props?: (TouchableOpacityProps & {event: GestureResponderEvent}) | any) => void; |
| 51 | + onPressIn?: ( |
| 52 | + props?: TouchableOpacityProps | GestureResponderEvent | any |
| 53 | + ) => void | RNTouchableOpacityProps['onPressIn']; |
| 54 | + onPressOut?: ( |
| 55 | + props?: TouchableOpacityProps | GestureResponderEvent | any |
| 56 | + ) => void | RNTouchableOpacityProps['onPressOut']; |
| 57 | + onLongPress?: ( |
| 58 | + props?: (TouchableOpacityProps & {event: GestureResponderEvent}) | any |
| 59 | + ) => void | RNTouchableOpacityProps['onLongPress']; |
50 | 60 | } |
51 | 61 |
|
52 | 62 | type Props = BaseComponentInjectedProps & ForwardRefInjectedProps & TouchableOpacityProps; |
@@ -155,12 +165,12 @@ class TouchableOpacity extends PureComponent<Props, {active: boolean}> { |
155 | 165 | ); |
156 | 166 | } |
157 | 167 |
|
158 | | - onPress(event: BaseSyntheticEvent) { |
159 | | - this.props.onPress?.({...this.props, ...event}); |
| 168 | + onPress(event: GestureResponderEvent) { |
| 169 | + this.props.onPress?.({...this.props, event}); |
160 | 170 | } |
161 | 171 |
|
162 | | - onLongPress = (event: BaseSyntheticEvent) => { |
163 | | - this.props.onLongPress?.({...this.props, ...event}); |
| 172 | + onLongPress = (event: GestureResponderEvent) => { |
| 173 | + this.props.onLongPress?.({...this.props, event}); |
164 | 174 | }; |
165 | 175 | } |
166 | 176 |
|
|
0 commit comments