@@ -25,6 +25,9 @@ const View = require('View');
25
25
const createReactClass = require ( 'create-react-class' ) ;
26
26
const emptyFunction = require ( 'fbjs/lib/emptyFunction' ) ;
27
27
28
+ import type { LayoutEvent , PressEvent } from 'CoreEventTypes' ;
29
+ import type { GestureState } from 'PanResponder' ;
30
+
28
31
const IS_RTL = I18nManager . isRTL ;
29
32
30
33
// NOTE: Eventually convert these consts to an input object of configurations
@@ -204,24 +207,27 @@ const SwipeableRow = createReactClass({
204
207
this . _animateToClosedPosition ( ) ;
205
208
} ,
206
209
207
- _onSwipeableViewLayout ( event : Object ) : void {
210
+ _onSwipeableViewLayout ( event : LayoutEvent ) : void {
208
211
this . setState ( {
209
212
isSwipeableViewRendered : true ,
210
213
rowHeight : event . nativeEvent . layout . height ,
211
214
} ) ;
212
215
} ,
213
216
214
217
_handleMoveShouldSetPanResponderCapture (
215
- event : Object ,
216
- gestureState : Object ,
218
+ event : PressEvent ,
219
+ gestureState : GestureState ,
217
220
) : boolean {
218
221
// Decides whether a swipe is responded to by this component or its child
219
222
return gestureState . dy < 10 && this . _isValidSwipe ( gestureState ) ;
220
223
} ,
221
224
222
- _handlePanResponderGrant ( event : Object , gestureState : Object ) : void { } ,
225
+ _handlePanResponderGrant (
226
+ event : PressEvent ,
227
+ gestureState : GestureState ,
228
+ ) : void { } ,
223
229
224
- _handlePanResponderMove ( event : Object , gestureState : Object ) : void {
230
+ _handlePanResponderMove ( event : PressEvent , gestureState : GestureState ) : void {
225
231
if ( this . _isSwipingExcessivelyRightFromClosedPosition ( gestureState ) ) {
226
232
return ;
227
233
}
@@ -235,22 +241,24 @@ const SwipeableRow = createReactClass({
235
241
}
236
242
} ,
237
243
238
- _isSwipingRightFromClosed ( gestureState : Object ) : boolean {
244
+ _isSwipingRightFromClosed ( gestureState : GestureState ) : boolean {
239
245
const gestureStateDx = IS_RTL ? - gestureState . dx : gestureState . dx ;
240
246
return this . _previousLeft === CLOSED_LEFT_POSITION && gestureStateDx > 0 ;
241
247
} ,
242
248
243
- _swipeFullSpeed ( gestureState : Object ) : void {
249
+ _swipeFullSpeed ( gestureState : GestureState ) : void {
244
250
this . state . currentLeft . setValue ( this . _previousLeft + gestureState . dx ) ;
245
251
} ,
246
252
247
- _swipeSlowSpeed ( gestureState : Object ) : void {
253
+ _swipeSlowSpeed ( gestureState : GestureState ) : void {
248
254
this . state . currentLeft . setValue (
249
255
this . _previousLeft + gestureState . dx / SLOW_SPEED_SWIPE_FACTOR ,
250
256
) ;
251
257
} ,
252
258
253
- _isSwipingExcessivelyRightFromClosedPosition ( gestureState : Object ) : boolean {
259
+ _isSwipingExcessivelyRightFromClosedPosition (
260
+ gestureState : GestureState ,
261
+ ) : boolean {
254
262
/**
255
263
* We want to allow a BIT of right swipe, to allow users to know that
256
264
* swiping is available, but swiping right does not do anything
@@ -264,8 +272,8 @@ const SwipeableRow = createReactClass({
264
272
} ,
265
273
266
274
_onPanResponderTerminationRequest (
267
- event : Object ,
268
- gestureState : Object ,
275
+ event : PressEvent ,
276
+ gestureState : GestureState ,
269
277
) : boolean {
270
278
return false ;
271
279
} ,
@@ -338,7 +346,7 @@ const SwipeableRow = createReactClass({
338
346
} ,
339
347
340
348
// Ignore swipes due to user's finger moving slightly when tapping
341
- _isValidSwipe ( gestureState : Object ) : boolean {
349
+ _isValidSwipe ( gestureState : GestureState ) : boolean {
342
350
if (
343
351
this . props . preventSwipeRight &&
344
352
this . _previousLeft === CLOSED_LEFT_POSITION &&
@@ -350,7 +358,7 @@ const SwipeableRow = createReactClass({
350
358
return Math . abs ( gestureState . dx ) > HORIZONTAL_SWIPE_DISTANCE_THRESHOLD ;
351
359
} ,
352
360
353
- _shouldAnimateRemainder ( gestureState : Object ) : boolean {
361
+ _shouldAnimateRemainder ( gestureState : GestureState ) : boolean {
354
362
/**
355
363
* If user has swiped past a certain distance, animate the rest of the way
356
364
* if they let go
@@ -361,7 +369,7 @@ const SwipeableRow = createReactClass({
361
369
) ;
362
370
} ,
363
371
364
- _handlePanResponderEnd ( event : Object , gestureState : Object ) : void {
372
+ _handlePanResponderEnd ( event : PressEvent , gestureState : GestureState ) : void {
365
373
const horizontalDistance = IS_RTL ? - gestureState . dx : gestureState . dx ;
366
374
if ( this . _isSwipingRightFromClosed ( gestureState ) ) {
367
375
this . props . onOpen ( ) ;
0 commit comments