@@ -25,6 +25,7 @@ const StyleSheetPropType = require('StyleSheetPropType');
2525const View = require ( 'View' ) ;
2626const ViewPropTypes = require ( 'ViewPropTypes' ) ;
2727const ViewStylePropTypes = require ( 'ViewStylePropTypes' ) ;
28+ const InternalScrollViewType = require ( 'InternalScrollViewType' ) ;
2829
2930const createReactClass = require ( 'create-react-class' ) ;
3031const dismissKeyboard = require ( 'dismissKeyboard' ) ;
@@ -38,7 +39,104 @@ const requireNativeComponent = require('requireNativeComponent');
3839const warning = require ( 'fbjs/lib/warning' ) ;
3940const resolveAssetSource = require ( 'resolveAssetSource' ) ;
4041
42+ import type { PressEvent } from 'CoreEventTypes' ;
43+ import type { EdgeInsetsProp } from 'EdgeInsetsPropType' ;
4144import type { NativeMethodsMixinType } from 'ReactNativeTypes' ;
45+ import type { ViewStyleProp } from 'StyleSheet' ;
46+ import type { ViewProps } from 'ViewPropTypes' ;
47+ import type { PointProp } from 'PointPropType' ;
48+
49+ import type { ColorValue } from 'StyleSheetTypes' ;
50+
51+ type TouchableProps = $ReadOnly < { |
52+ onTouchStart ?: ( event : PressEvent ) => void ,
53+ onTouchMove ?: ( event : PressEvent ) => void ,
54+ onTouchEnd ?: ( event : PressEvent ) => void ,
55+ onTouchCancel ?: ( event : PressEvent ) => void ,
56+ onTouchEndCapture ?: ( event : PressEvent ) => void ,
57+ | } > ;
58+
59+ type IOSProps = $ReadOnly < { |
60+ automaticallyAdjustContentInsets ?: ?boolean ,
61+ contentInset ?: ?EdgeInsetsProp ,
62+ contentOffset ?: ?PointProp ,
63+ bounces ?: ?boolean ,
64+ bouncesZoom ?: ?boolean ,
65+ alwaysBounceHorizontal ?: ?boolean ,
66+ alwaysBounceVertical ?: ?boolean ,
67+ centerContent ?: ?boolean ,
68+ decelerationRate ?: ?( 'fast' | 'normal' | number ) ,
69+ indicatorStyle ?: ?( 'default' | 'black' | 'white' ) ,
70+ directionalLockEnabled ?: ?boolean ,
71+ canCancelContentTouches ?: ?boolean ,
72+ maintainVisibleContentPosition ?: ?$ReadOnly < { |
73+ minIndexForVisible : number ,
74+ autoscrollToTopThreshold ?: ?number ,
75+ | } > ,
76+ maximumZoomScale ?: ?number ,
77+ minimumZoomScale ?: ?number ,
78+ pinchGestureEnabled ?: ?boolean ,
79+ scrollEventThrottle ?: ?number ,
80+ scrollIndicatorInsets ?: ?EdgeInsetsProp ,
81+ scrollsToTop ?: ?boolean ,
82+ showsHorizontalScrollIndicator ?: ?boolean ,
83+ snapToAlignment ?: ?( 'start' | 'center' | 'end' ) ,
84+ zoomScale ?: ?number ,
85+ contentInsetAdjustmentBehavior ?: ?(
86+ | 'automatic'
87+ | 'scrollableAxes'
88+ | 'never'
89+ | 'always'
90+ ) ,
91+ DEPRECATED_sendUpdatedChildFrames ?: ?boolean ,
92+ | } > ;
93+
94+ type AndroidProps = $ReadOnly < { |
95+ nestedScrollEnabled ?: ?boolean ,
96+ endFillColor ?: ?ColorValue ,
97+ scrollPerfTag ?: ?string ,
98+ overScrollMode ?: ?( 'auto' | 'always' | 'never' ) ,
99+ | } > ;
100+
101+ type VRProps = $ReadOnly < { |
102+ scrollBarThumbImage ?: ?( $ReadOnly < { || } > | number ) ,
103+ | } > ;
104+
105+ type Props = $ReadOnly < { |
106+ ...ViewProps ,
107+ ...TouchableProps ,
108+ ...IOSProps ,
109+ ...AndroidProps ,
110+ ...VRProps ,
111+
112+ contentContainerStyle ?: ?ViewStyleProp ,
113+ horizontal ?: ?boolean ,
114+ invertStickyHeaders ?: ?boolean ,
115+ keyboardDismissMode ?: ?(
116+ | 'none' // default
117+ | 'on-drag' // cross-platform
118+ | 'interactive'
119+ ) , // ios only
120+ // $FlowFixMe Issues found when typing ScrollView
121+ keyboardShouldPersistTaps ?: ?( 'always' | 'never' | 'handled' | false | true ) ,
122+ onMomentumScrollBegin ?: ?Function ,
123+ onMomentumScrollEnd ?: ?Function ,
124+
125+ onScroll ?: ?Function ,
126+ onScrollBeginDrag ?: ?Function ,
127+ onScrollEndDrag ?: ?Function ,
128+ onContentSizeChange ?: ?Function ,
129+ onKeyboardDidShow ?: ( event : PressEvent ) => void ,
130+ pagingEnabled ?: ?boolean ,
131+ scrollEnabled ?: ?boolean ,
132+ showsVerticalScrollIndicator ?: ?boolean ,
133+ stickyHeaderIndices ?: ?$ReadOnlyArray < number > ,
134+ snapToInterval ?: ?number ,
135+ removeClippedSubviews ?: ?boolean ,
136+ refreshControl ?: ?React . Element < any > ,
137+ style ?: ?ViewStyleProp ,
138+ children ?: React . Node ,
139+ | } > ;
42140
43141/**
44142 * Component that wraps platform ScrollView while providing
@@ -75,7 +173,6 @@ import type {NativeMethodsMixinType} from 'ReactNativeTypes';
75173 * multiple columns, infinite scroll loading, or any number of other features it
76174 * supports out of the box.
77175 */
78- // $FlowFixMe(>=0.41.0)
79176const ScrollView = createReactClass ( {
80177 displayName : 'ScrollView' ,
81178 propTypes : {
@@ -806,8 +903,8 @@ const ScrollView = createReactClass({
806903 // $FlowFixMe Invalid prop usage
807904 hasStickyHeaders && React . Children . toArray ( this . props . children ) ;
808905 const children = hasStickyHeaders
809- // $FlowFixMe Invalid prop usage
810- ? childArray . map ( ( child , index ) => {
906+ ? // $FlowFixMe Invalid prop usage
907+ childArray . map ( ( child , index ) => {
811908 // $FlowFixMe Invalid prop usage
812909 const indexOfIndex = child ? stickyHeaderIndices . indexOf ( index ) : - 1 ;
813910 if ( indexOfIndex > - 1 ) {
@@ -834,8 +931,8 @@ const ScrollView = createReactClass({
834931 return child ;
835932 }
836933 } )
837- // $FlowFixMe Invalid prop usage
838- : this . props . children ;
934+ : // $FlowFixMe Invalid prop usage
935+ this . props . children ;
839936 const contentContainer = (
840937 < ScrollContentContainerViewClass
841938 { ...contentSizeChangeProps }
@@ -884,6 +981,7 @@ const ScrollView = createReactClass({
884981 onResponderGrant : this . scrollResponderHandleResponderGrant ,
885982 onResponderReject : this . scrollResponderHandleResponderReject ,
886983 onResponderRelease : this . scrollResponderHandleResponderRelease ,
984+ // $FlowFixMe
887985 onResponderTerminate : this . scrollResponderHandleTerminate ,
888986 onResponderTerminationRequest : this
889987 . scrollResponderHandleTerminationRequest ,
@@ -958,6 +1056,10 @@ const ScrollView = createReactClass({
9581056 } ,
9591057} ) ;
9601058
1059+ const TypedScrollView = ( ( ScrollView : any ) : Class <
1060+ InternalScrollViewType < Props > ,
1061+ > ) ;
1062+
9611063const styles = StyleSheet . create ( {
9621064 baseVertical : {
9631065 flexGrow : 1 ,
@@ -1028,4 +1130,4 @@ if (Platform.OS === 'android') {
10281130 RCTScrollContentView = requireNativeComponent ( 'RCTScrollContentView' , View ) ;
10291131}
10301132
1031- module . exports = ScrollView ;
1133+ module . exports = TypedScrollView ;
0 commit comments