From 41a940392cea497bc5eb627b24083d0211d1eb89 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sun, 13 May 2018 00:48:47 -0700 Subject: [PATCH] RN: Add Missing Events to ViewPropTypes Reviewed By: TheSavior Differential Revision: D7984937 fbshipit-source-id: fc2703e3382a7515b71f8a634aca5b6d7a5b25b4 --- Libraries/Components/View/ViewPropTypes.js | 50 ++++++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/Libraries/Components/View/ViewPropTypes.js b/Libraries/Components/View/ViewPropTypes.js index 1d5f193c62..addbc6e7e8 100644 --- a/Libraries/Components/View/ViewPropTypes.js +++ b/Libraries/Components/View/ViewPropTypes.js @@ -35,7 +35,43 @@ const stylePropType = StyleSheetPropType(ViewStylePropTypes); export type ViewLayout = Layout; export type ViewLayoutEvent = LayoutEvent; +type DirectEventProps = $ReadOnly<{| + onAccessibilityAction?: Function, + onAccessibilityTap?: Function, + onLayout?: ?(event: LayoutEvent) => void, + onMagicTap?: Function, +|}>; + +type TouchEventProps = $ReadOnly<{| + onTouchCancel?: ?Function, + onTouchCancelCapture?: ?Function, + onTouchEnd?: ?Function, + onTouchEndCapture?: ?Function, + onTouchMove?: ?Function, + onTouchMoveCapture?: ?Function, + onTouchStart?: ?Function, + onTouchStartCapture?: ?Function, +|}>; + +type GestureResponderEventProps = $ReadOnly<{| + onMoveShouldSetResponder?: ?Function, + onMoveShouldSetResponderCapture?: ?Function, + onResponderGrant?: ?Function, + onResponderMove?: ?Function, + onResponderReject?: ?Function, + onResponderRelease?: ?Function, + onResponderStart?: ?Function, + onResponderTerminate?: ?Function, + onResponderTerminationRequest?: ?Function, + onStartShouldSetResponder?: ?Function, + onStartShouldSetResponderCapture?: ?Function, +|}>; + export type ViewProps = $ReadOnly<{| + ...DirectEventProps, + ...GestureResponderEventProps, + ...TouchEventProps, + // There's no easy way to create a different type if (Platform.isTVOS): // so we must include TVViewProps ...TVViewProps, @@ -55,22 +91,8 @@ export type ViewProps = $ReadOnly<{| accessibilityViewIsModal?: boolean, accessibilityElementsHidden?: boolean, children?: ?React.Node, - onAccessibilityAction?: Function, - onAccessibilityTap?: Function, - onMagicTap?: Function, testID?: ?string, nativeID?: string, - onLayout?: ?(event: LayoutEvent) => void, - onResponderGrant?: ?Function, - onResponderMove?: ?Function, - onResponderReject?: ?Function, - onResponderRelease?: ?Function, - onResponderTerminate?: ?Function, - onResponderTerminationRequest?: ?Function, - onStartShouldSetResponder?: ?Function, - onStartShouldSetResponderCapture?: ?Function, - onMoveShouldSetResponder?: ?Function, - onMoveShouldSetResponderCapture?: ?Function, hitSlop?: ?EdgeInsetsProp, pointerEvents?: null | 'box-none' | 'none' | 'box-only' | 'auto', style?: stylePropType,