react-native-gesture-handler 2.3.1 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. package/RNGestureHandler.podspec +2 -1
  2. package/android/build.gradle +38 -6
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
  4. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
  5. package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
  11. package/ios/RNGHTouchEventType.h +9 -0
  12. package/ios/RNGestureHandler.h +2 -2
  13. package/ios/RNGestureHandler.m +21 -8
  14. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  15. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +2 -2
  16. package/ios/RNGestureHandlerButton.h +1 -0
  17. package/ios/RNGestureHandlerButton.m +9 -1
  18. package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
  19. package/ios/RNGestureHandlerButtonManager.m +4 -1
  20. package/ios/RNGestureHandlerEvents.h +2 -2
  21. package/ios/RNGestureHandlerEvents.m +2 -2
  22. package/ios/RNGestureHandlerManager.h +2 -0
  23. package/ios/RNGestureHandlerManager.mm +30 -20
  24. package/ios/RNGestureHandlerModule.mm +18 -0
  25. package/ios/RNGestureHandlerPointerTracker.h +2 -2
  26. package/ios/RNGestureHandlerPointerTracker.m +9 -6
  27. package/ios/RNGestureHandlerRegistry.h +1 -0
  28. package/ios/RNGestureHandlerRegistry.m +10 -0
  29. package/jest-utils/package.json +6 -0
  30. package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
  31. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  32. package/lib/commonjs/GestureHandlerRootView.js +6 -0
  33. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  34. package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
  35. package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
  36. package/lib/commonjs/RNGestureHandlerModule.js +5 -0
  37. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  38. package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
  39. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  40. package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
  41. package/lib/commonjs/TouchEventType.js.map +1 -0
  42. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  43. package/lib/commonjs/components/GestureHandlerButton.js +1 -1
  44. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  45. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
  46. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  47. package/lib/commonjs/components/touchables/TouchableOpacity.js +3 -1
  48. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  49. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
  50. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  51. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
  52. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  53. package/lib/commonjs/getShadowNodeFromRef.js +12 -9
  54. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  55. package/lib/commonjs/handlers/createHandler.js +7 -13
  56. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  57. package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
  58. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  59. package/lib/commonjs/handlers/gestures/GestureDetector.js +41 -21
  60. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  61. package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
  62. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  63. package/lib/commonjs/handlers/gestures/gesture.js +11 -2
  64. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  65. package/lib/commonjs/index.js +0 -14
  66. package/lib/commonjs/index.js.map +1 -1
  67. package/lib/commonjs/init.js +10 -1
  68. package/lib/commonjs/init.js.map +1 -1
  69. package/lib/commonjs/jestUtils/index.js +20 -0
  70. package/lib/commonjs/jestUtils/index.js.map +1 -0
  71. package/lib/commonjs/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
  72. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -0
  73. package/lib/commonjs/mocks.js +2 -0
  74. package/lib/commonjs/mocks.js.map +1 -1
  75. package/lib/commonjs/utils.js +23 -1
  76. package/lib/commonjs/utils.js.map +1 -1
  77. package/lib/commonjs/web/GestureHandler.js +4 -1
  78. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  79. package/lib/module/GestureHandlerRootView.android.js +7 -2
  80. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  81. package/lib/module/GestureHandlerRootView.js +5 -0
  82. package/lib/module/GestureHandlerRootView.js.map +1 -1
  83. package/lib/module/GestureHandlerRootView.web.js +6 -0
  84. package/lib/module/GestureHandlerRootView.web.js.map +1 -0
  85. package/lib/module/RNGestureHandlerModule.js +5 -0
  86. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  87. package/lib/module/RNGestureHandlerModule.web.js +4 -1
  88. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  89. package/lib/module/{EventType.js → TouchEventType.js} +2 -2
  90. package/lib/module/TouchEventType.js.map +1 -0
  91. package/lib/module/components/GestureButtons.js.map +1 -1
  92. package/lib/module/components/GestureHandlerButton.js +2 -2
  93. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  94. package/lib/module/components/touchables/GenericTouchable.js +2 -0
  95. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  96. package/lib/module/components/touchables/TouchableOpacity.js +4 -2
  97. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  98. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
  99. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  100. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
  101. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  102. package/lib/module/getShadowNodeFromRef.js +11 -8
  103. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  104. package/lib/module/handlers/createHandler.js +7 -16
  105. package/lib/module/handlers/createHandler.js.map +1 -1
  106. package/lib/module/handlers/gestureHandlerCommon.js +11 -1
  107. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  108. package/lib/module/handlers/gestures/GestureDetector.js +41 -22
  109. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  110. package/lib/module/handlers/gestures/eventReceiver.js +6 -7
  111. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  112. package/lib/module/handlers/gestures/gesture.js +10 -2
  113. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  114. package/lib/module/index.js +0 -1
  115. package/lib/module/index.js.map +1 -1
  116. package/lib/module/init.js +6 -1
  117. package/lib/module/init.js.map +1 -1
  118. package/lib/module/jestUtils/index.js +2 -0
  119. package/lib/module/jestUtils/index.js.map +1 -0
  120. package/lib/module/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
  121. package/lib/module/jestUtils/jestUtils.js.map +1 -0
  122. package/lib/module/mocks.js +2 -0
  123. package/lib/module/mocks.js.map +1 -1
  124. package/lib/module/utils.js +17 -1
  125. package/lib/module/utils.js.map +1 -1
  126. package/lib/module/web/GestureHandler.js +4 -1
  127. package/lib/module/web/GestureHandler.js.map +1 -1
  128. package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
  129. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  130. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  131. package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
  132. package/lib/typescript/components/GestureButtons.d.ts +18 -6
  133. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -1
  134. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
  135. package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
  136. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  137. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +5 -3
  138. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -3
  139. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  140. package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
  141. package/lib/typescript/index.d.ts +0 -1
  142. package/lib/typescript/init.d.ts +1 -0
  143. package/lib/typescript/jestUtils/index.d.ts +1 -0
  144. package/lib/typescript/{jestUtils.d.ts → jestUtils/jestUtils.d.ts} +18 -18
  145. package/lib/typescript/mocks.d.ts +1 -0
  146. package/lib/typescript/utils.d.ts +2 -0
  147. package/lib/typescript/web/GestureHandler.d.ts +1 -1
  148. package/package.json +5 -2
  149. package/src/GestureHandlerRootView.android.tsx +8 -2
  150. package/src/GestureHandlerRootView.tsx +6 -0
  151. package/src/GestureHandlerRootView.web.tsx +12 -0
  152. package/src/RNGestureHandlerModule.ts +7 -0
  153. package/src/RNGestureHandlerModule.web.ts +2 -0
  154. package/src/{EventType.ts → TouchEventType.ts} +2 -2
  155. package/src/components/GestureButtons.tsx +21 -7
  156. package/src/components/GestureHandlerButton.tsx +2 -2
  157. package/src/components/touchables/GenericTouchable.tsx +2 -0
  158. package/src/components/touchables/TouchableOpacity.tsx +6 -2
  159. package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
  160. package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
  161. package/src/getShadowNodeFromRef.ts +12 -9
  162. package/src/handlers/createHandler.ts +6 -16
  163. package/src/handlers/gestureHandlerCommon.ts +19 -2
  164. package/src/handlers/gestures/GestureDetector.tsx +64 -31
  165. package/src/handlers/gestures/eventReceiver.ts +6 -6
  166. package/src/handlers/gestures/gesture.ts +13 -2
  167. package/src/index.ts +0 -1
  168. package/src/init.ts +8 -1
  169. package/src/jestUtils/index.ts +1 -0
  170. package/src/{jestUtils.ts → jestUtils/jestUtils.ts} +21 -21
  171. package/src/mocks.ts +2 -0
  172. package/src/utils.ts +20 -0
  173. package/src/web/GestureHandler.ts +7 -1
  174. package/ios/RNTouchEventType.h +0 -9
  175. package/lib/commonjs/EventType.js.map +0 -1
  176. package/lib/commonjs/jestUtils.js.map +0 -1
  177. package/lib/module/EventType.js.map +0 -1
  178. package/lib/module/jestUtils.js.map +0 -1
  179. package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
  180. package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -48,6 +48,7 @@
48
48
  RCTUIManager *_uiManager;
49
49
  NSHashTable<RNRootViewGestureRecognizer *> *_rootViewGestureRecognizers;
50
50
  RCTEventDispatcher *_eventDispatcher;
51
+ id _reanimatedModule;
51
52
  }
52
53
 
53
54
  - (instancetype)initWithUIManager:(RCTUIManager *)uiManager
@@ -58,6 +59,7 @@
58
59
  _eventDispatcher = eventDispatcher;
59
60
  _registry = [RNGestureHandlerRegistry new];
60
61
  _rootViewGestureRecognizers = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory];
62
+ _reanimatedModule = nil;
61
63
  }
62
64
  return self;
63
65
  }
@@ -139,6 +141,11 @@
139
141
  [_registry dropHandlerWithTag:handlerTag];
140
142
  }
141
143
 
144
+ - (void)dropAllGestureHandlers
145
+ {
146
+ [_registry dropAllHandlers];
147
+ }
148
+
142
149
  - (void)handleSetJSResponder:(NSNumber *)viewTag blockNativeResponder:(NSNumber *)blockNativeResponder
143
150
  {
144
151
  if ([blockNativeResponder boolValue]) {
@@ -210,80 +217,83 @@
210
217
 
211
218
  #pragma mark Events
212
219
 
213
- - (void)sendStateChangeEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGestureHandlerActionType)actionType
220
+ - (void)sendEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGestureHandlerActionType)actionType
214
221
  {
215
222
  switch (actionType) {
216
223
  case RNGestureHandlerActionTypeReanimatedWorklet:
217
- [self sendStateChangeEventForReanimated:event];
224
+ [self sendEventForReanimated:event];
218
225
  break;
219
226
 
220
227
  case RNGestureHandlerActionTypeNativeAnimatedEvent:
221
228
  if ([event.eventName isEqualToString:@"onGestureHandlerEvent"]) {
222
- [self sendStateChangeEventForNativeAnimatedEvent:event];
229
+ [self sendEventForNativeAnimatedEvent:event];
223
230
  } else {
224
231
  // Although onGestureEvent prop is an Animated.event with useNativeDriver: true,
225
232
  // onHandlerStateChange prop is still a regular JS function.
226
233
  // Also, Animated.event is only supported with old API.
227
- [self sendStateChangeEventForJSFunctionOldAPI:event];
234
+ [self sendEventForJSFunctionOldAPI:event];
228
235
  }
229
236
  break;
230
237
 
231
238
  case RNGestureHandlerActionTypeJSFunctionOldAPI:
232
- [self sendStateChangeEventForJSFunctionOldAPI:event];
239
+ [self sendEventForJSFunctionOldAPI:event];
233
240
  break;
234
241
 
235
242
  case RNGestureHandlerActionTypeJSFunctionNewAPI:
236
- [self sendStateChangeEventForJSFunctionNewAPI:event];
243
+ [self sendEventForJSFunctionNewAPI:event];
237
244
  break;
238
245
  }
239
246
  }
240
247
 
241
- - (void)sendStateChangeEventForReanimated:(RNGestureHandlerStateChange *)event
248
+ - (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event
242
249
  {
243
250
  // Delivers the event to Reanimated.
244
251
  #ifdef RN_FABRIC_ENABLED
245
- // TODO: send event directly to Reanimated
246
- // This is already supported in Reanimated with Fabric but let's wait until the official release.
247
- // [_reanimatedModule eventDispatcherWillDispatchEvent:event];
252
+ // Send event directly to Reanimated
253
+ if (_reanimatedModule == nil) {
254
+ _reanimatedModule = [_uiManager.bridge moduleForName:@"ReanimatedModule"];
255
+ }
256
+
257
+ [_reanimatedModule eventDispatcherWillDispatchEvent:event];
248
258
  #else
249
259
  // In the old architecture, Reanimated overwrites RCTEventDispatcher
250
260
  // with REAEventDispatcher and intercepts all direct events.
251
- [self sendStateChangeEventForDirectEvent:event];
261
+ [self sendEventForDirectEvent:event];
252
262
  #endif // RN_FABRIC_ENABLED
253
263
  }
254
264
 
255
- - (void)sendStateChangeEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
265
+ - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
256
266
  {
257
267
  // Delivers the event to NativeAnimatedModule.
258
268
  // Currently, NativeAnimated[Turbo]Module is RCTEventDispatcherObserver so we can
259
269
  // simply send a direct event which is handled by the observer but ignored on JS side.
260
270
  // TODO: send event directly to NativeAnimated[Turbo]Module
261
- [self sendStateChangeEventForDirectEvent:event];
271
+ [self sendEventForDirectEvent:event];
262
272
  }
263
273
 
264
- - (void)sendStateChangeEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
274
+ - (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
265
275
  {
266
276
  // Delivers the event to JS (old RNGH API).
267
277
  #ifdef RN_FABRIC_ENABLED
268
- [self sendStateChangeEventForDeviceEvent:event];
278
+ [self sendEventForDeviceEvent:event];
269
279
  #else
270
- [self sendStateChangeEventForDirectEvent:event];
280
+ [self sendEventForDirectEvent:event];
271
281
  #endif // RN_FABRIC_ENABLED
272
282
  }
273
283
 
274
- - (void)sendStateChangeEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
284
+ - (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
275
285
  {
276
286
  // Delivers the event to JS (new RNGH API).
277
- [self sendStateChangeEventForDeviceEvent:event];
287
+ [self sendEventForDeviceEvent:event];
278
288
  }
279
289
 
280
- - (void)sendStateChangeEventForDirectEvent:(RNGestureHandlerStateChange *)event
290
+ - (void)sendEventForDirectEvent:(RNGestureHandlerStateChange *)event
281
291
  {
282
292
  // Delivers the event to JS as a direct event.
283
293
  [_eventDispatcher sendEvent:event];
284
294
  }
285
295
 
286
- - (void)sendStateChangeEventForDeviceEvent:(RNGestureHandlerStateChange *)event
296
+ - (void)sendEventForDeviceEvent:(RNGestureHandlerStateChange *)event
287
297
  {
288
298
  // Delivers the event to JS as a device event.
289
299
  NSMutableDictionary *body = [[event arguments] objectAtIndex:2];
@@ -60,6 +60,8 @@ RCT_EXPORT_MODULE()
60
60
 
61
61
  - (void)invalidate
62
62
  {
63
+ [_manager dropAllGestureHandlers];
64
+
63
65
  _manager = nil;
64
66
 
65
67
  #ifdef RN_FABRIC_ENABLED
@@ -173,6 +175,22 @@ RCT_EXPORT_METHOD(handleClearJSResponder)
173
175
  }];
174
176
  }
175
177
 
178
+ RCT_EXPORT_METHOD(flushOperations)
179
+ {
180
+ if (_operations.count == 0) {
181
+ return;
182
+ }
183
+
184
+ NSArray<GestureHandlerOperation> *operations = _operations;
185
+ _operations = [NSMutableArray new];
186
+
187
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
188
+ for (GestureHandlerOperation operation in operations) {
189
+ operation(self->_manager);
190
+ }
191
+ }];
192
+ }
193
+
176
194
  - (void)setGestureState:(int)state forHandler:(int)handlerTag
177
195
  {
178
196
  RNGestureHandler *handler = [_manager handlerWithTag:@(handlerTag)];
@@ -1,6 +1,6 @@
1
1
  #import <Foundation/Foundation.h>
2
2
 
3
- #import "RNTouchEventType.h"
3
+ #import "RNGHTouchEventType.h"
4
4
 
5
5
  #define MAX_POINTERS_COUNT 12
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  @interface RNGestureHandlerPointerTracker : NSObject
10
10
 
11
- @property (nonatomic) RNTouchEventType eventType;
11
+ @property (nonatomic) RNGHTouchEventType eventType;
12
12
  @property (nonatomic) NSArray<NSDictionary *> *changedPointersData;
13
13
  @property (nonatomic) NSArray<NSDictionary *> *allPointersData;
14
14
  @property (nonatomic) int trackedPointersCount;
@@ -103,7 +103,7 @@
103
103
  return;
104
104
  }
105
105
 
106
- _eventType = RNTouchEventTypePointerDown;
106
+ _eventType = RNGHTouchEventTypePointerDown;
107
107
 
108
108
  NSDictionary *data[touches.count];
109
109
 
@@ -129,7 +129,7 @@
129
129
  return;
130
130
  }
131
131
 
132
- _eventType = RNTouchEventTypePointerMove;
132
+ _eventType = RNGHTouchEventTypePointerMove;
133
133
 
134
134
  NSDictionary *data[touches.count];
135
135
 
@@ -153,7 +153,7 @@
153
153
  // extract all touches first to include the ones that were just lifted
154
154
  [self extractAllTouches];
155
155
 
156
- _eventType = RNTouchEventTypePointerUp;
156
+ _eventType = RNGHTouchEventTypePointerUp;
157
157
 
158
158
  NSDictionary *data[touches.count];
159
159
 
@@ -188,7 +188,7 @@
188
188
 
189
189
  if (_trackedPointersCount == 0) {
190
190
  // gesture has finished because all pointers were lifted, reset event type to send state change event
191
- _eventType = RNTouchEventTypeUndetermined;
191
+ _eventType = RNGHTouchEventTypeUndetermined;
192
192
  } else {
193
193
  // turns out that the gesture may be made to fail without calling touchesCancelled in that case there
194
194
  // are still tracked pointers but the recognizer state is already set to UIGestureRecognizerStateFailed
@@ -218,7 +218,7 @@
218
218
  }
219
219
  }
220
220
 
221
- _eventType = RNTouchEventTypeCancelled;
221
+ _eventType = RNGHTouchEventTypeCancelled;
222
222
  _changedPointersData = [[NSArray alloc] initWithObjects:data count:registeredTouches];
223
223
  [self sendEvent];
224
224
  _trackedPointersCount = 0;
@@ -227,7 +227,10 @@
227
227
 
228
228
  - (void)sendEvent
229
229
  {
230
- if (!_gestureHandler.needsPointerData) {
230
+ // it may happen that the gesture recognizer is reset after it's been unbound from the view,
231
+ // it that recognizer tried to send event, the app would crash because the target of the event
232
+ // would be nil.
233
+ if (!_gestureHandler.needsPointerData || _gestureHandler.recognizer.view.reactTag == nil) {
231
234
  return;
232
235
  }
233
236
 
@@ -14,5 +14,6 @@
14
14
  - (void)registerGestureHandler:(nonnull RNGestureHandler *)gestureHandler;
15
15
  - (void)attachHandlerWithTag:(nonnull NSNumber *)handlerTag toView:(nonnull UIView *)view withActionType:(RNGestureHandlerActionType)actionType;
16
16
  - (void)dropHandlerWithTag:(nonnull NSNumber *)handlerTag;
17
+ - (void)dropAllHandlers;
17
18
 
18
19
  @end
@@ -48,4 +48,14 @@
48
48
  [_handlers removeObjectForKey:handlerTag];
49
49
  }
50
50
 
51
+ - (void)dropAllHandlers
52
+ {
53
+ for (NSNumber* tag in _handlers) {
54
+ RNGestureHandler *handler = _handlers[tag];
55
+ [handler unbindFromView];
56
+ }
57
+
58
+ [_handlers removeAllObjects];
59
+ }
60
+
51
61
  @end
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/jestUtils/index",
3
+ "module": "../lib/module/jestUtils/index",
4
+ "react-native": "../src/jestUtils/index",
5
+ "types": "../lib/typescript/jestUtils/index.d.ts"
6
+ }
@@ -9,6 +9,8 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
+ var _init = require("./init");
13
+
12
14
  var _utils = require("./utils");
13
15
 
14
16
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -16,9 +18,13 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
16
18
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
19
 
18
20
  /* eslint-disable @typescript-eslint/no-var-requires */
19
- const GestureHandlerRootViewNativeComponent = (0, _utils.isFabric)() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerRootView');
21
+ const GestureHandlerRootViewNativeComponent = (0, _utils.shouldUseCodegenNativeComponent)() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerRootView');
20
22
 
21
23
  function GestureHandlerRootView(props) {
24
+ // try initialize fabric on the first render, at this point we can
25
+ // reliably check if fabric is enabled (the function contains a flag
26
+ // to make sure it's called only once)
27
+ (0, _init.maybeInitializeFabric)();
22
28
  return /*#__PURE__*/React.createElement(GestureHandlerRootViewNativeComponent, props);
23
29
  }
24
30
  //# sourceMappingURL=GestureHandlerRootView.android.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;;;;;AAJA;AAMA,MAAMA,qCAAqC,GAAG,yBAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { isFabric } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = isFabric()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AACA;;;;;;AALA;AAOA,MAAMA,qCAAqC,GAAG,gDAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\nimport { shouldUseCodegenNativeComponent } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
@@ -9,11 +9,17 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
+ var _init = require("./init");
13
+
12
14
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
15
 
14
16
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
17
 
16
18
  function GestureHandlerRootView(props) {
19
+ // try initialize fabric on the first render, at this point we can
20
+ // reliably check if fabric is enabled (the function contains a flag
21
+ // to make sure it's called only once)
22
+ (0, _init.maybeInitializeFabric)();
17
23
  return /*#__PURE__*/React.createElement(_reactNative.View, props);
18
24
  }
19
25
  //# sourceMappingURL=GestureHandlerRootView.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA;AACA;AACA;AACA;AAEA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { maybeInitializeFabric } from './init';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n // try initialize fabric on the first render, at this point we can\n // reliably check if fabric is enabled (the function contains a flag\n // to make sure it's called only once)\n maybeInitializeFabric();\n\n return <View {...props} />;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = GestureHandlerRootView;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
+
14
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function GestureHandlerRootView(props) {
17
+ return /*#__PURE__*/React.createElement(_reactNative.View, props);
18
+ }
19
+ //# sourceMappingURL=GestureHandlerRootView.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["GestureHandlerRootView.web.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
@@ -19,6 +19,11 @@ if (RNGestureHandlerModule == null) {
19
19
  For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`.split('\n').map(line => line.trim()).join('\n')));
20
20
  }
21
21
 
22
+ if (RNGestureHandlerModule.flushOperations === undefined) {
23
+ RNGestureHandlerModule.flushOperations = () => {// NO-OP if not defined
24
+ };
25
+ }
26
+
22
27
  var _default = RNGestureHandlerModule;
23
28
  exports.default = _default;
24
29
  //# sourceMappingURL=RNGestureHandlerModule.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join"],"mappings":";;;;;;;AAAA;;AAEA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,CACE,uBACG;AACP;AACA,gIAFM,CAGGC,KAHH,CAGS,IAHT,EAIGC,GAJH,CAIQC,IAAD,IAAUA,IAAI,CAACC,IAAL,EAJjB,EAKGC,IALH,CAKQ,IALR,CADF,CADF;AAUD;;eAuBcR,sB","sourcesContent":["import { NativeModules } from 'react-native';\nimport { ActionType } from './ActionType';\nimport { tagMessage } from './utils';\nconst { RNGestureHandlerModule } = NativeModules;\n\nif (RNGestureHandlerModule == null) {\n console.error(\n tagMessage(\n `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).\n\n For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n )\n );\n}\n\nexport type RNGestureHandlerModuleProps = {\n handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;\n handleClearJSResponder: () => void;\n createGestureHandler: (\n handlerName: string,\n handlerTag: number,\n config: Readonly<Record<string, unknown>>\n ) => void;\n attachGestureHandler: (\n handlerTag: number,\n newView: number,\n actionType: ActionType\n ) => void;\n updateGestureHandler: (\n handlerTag: number,\n newConfig: Readonly<Record<string, unknown>>\n ) => void;\n dropGestureHandler: (handlerTag: number) => void;\n install: () => void;\n};\n\nexport default RNGestureHandlerModule as RNGestureHandlerModuleProps;\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join","flushOperations","undefined"],"mappings":";;;;;;;AAAA;;AAEA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,CACE,uBACG;AACP;AACA,gIAFM,CAGGC,KAHH,CAGS,IAHT,EAIGC,GAJH,CAIQC,IAAD,IAAUA,IAAI,CAACC,IAAL,EAJjB,EAKGC,IALH,CAKQ,IALR,CADF,CADF;AAUD;;AAED,IAAIR,sBAAsB,CAACS,eAAvB,KAA2CC,SAA/C,EAA0D;AACxDV,EAAAA,sBAAsB,CAACS,eAAvB,GAAyC,MAAM,CAC7C;AACD,GAFD;AAGD;;eAwBcT,sB","sourcesContent":["import { NativeModules } from 'react-native';\nimport { ActionType } from './ActionType';\nimport { tagMessage } from './utils';\nconst { RNGestureHandlerModule } = NativeModules;\n\nif (RNGestureHandlerModule == null) {\n console.error(\n tagMessage(\n `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).\n\n For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n )\n );\n}\n\nif (RNGestureHandlerModule.flushOperations === undefined) {\n RNGestureHandlerModule.flushOperations = () => {\n // NO-OP if not defined\n };\n}\n\nexport type RNGestureHandlerModuleProps = {\n handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;\n handleClearJSResponder: () => void;\n createGestureHandler: (\n handlerName: string,\n handlerTag: number,\n config: Readonly<Record<string, unknown>>\n ) => void;\n attachGestureHandler: (\n handlerTag: number,\n newView: number,\n actionType: ActionType\n ) => void;\n updateGestureHandler: (\n handlerTag: number,\n newConfig: Readonly<Record<string, unknown>>\n ) => void;\n dropGestureHandler: (handlerTag: number) => void;\n install: () => void;\n flushOperations: () => void;\n};\n\nexport default RNGestureHandlerModule as RNGestureHandlerModuleProps;\n"]}
@@ -73,7 +73,10 @@ var _default = {
73
73
 
74
74
  dropGestureHandler(handlerTag) {
75
75
  NodeManager.dropGestureHandler(handlerTag);
76
- }
76
+ },
77
+
78
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
79
+ flushOperations() {}
77
80
 
78
81
  };
79
82
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","getHandler","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;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,SAArB,EAAqC;AACvDR,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCa,mBAAnC,CAAuDD,SAAvD;AACD,GAhCY;;AAiCbE,EAAAA,qBAAqB,CAACd,UAAD,EAAqB;AACxC,WAAOI,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,CAAP;AACD,GAnCY;;AAoCbe,EAAAA,kBAAkB,CAACf,UAAD,EAAqB;AACrCI,IAAAA,WAAW,CAACW,kBAAZ,CAA+Bf,UAA/B;AACD;;AAtCY,C","sourcesContent":["import { ActionType } from './ActionType';\nimport { Direction } from './web/constants';\nimport FlingGestureHandler from './web/FlingGestureHandler';\nimport LongPressGestureHandler from './web/LongPressGestureHandler';\nimport NativeViewGestureHandler from './web/NativeViewGestureHandler';\nimport * as NodeManager from './web/NodeManager';\nimport PanGestureHandler from './web/PanGestureHandler';\nimport PinchGestureHandler from './web/PinchGestureHandler';\nimport RotationGestureHandler from './web/RotationGestureHandler';\nimport TapGestureHandler from './web/TapGestureHandler';\n\nexport const Gestures = {\n PanGestureHandler,\n RotationGestureHandler,\n PinchGestureHandler,\n TapGestureHandler,\n NativeViewGestureHandler,\n LongPressGestureHandler,\n FlingGestureHandler,\n // ForceTouchGestureHandler,\n};\n\nexport default {\n Direction,\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n //TODO(TS) extends config\n if (!(handlerName in Gestures))\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(handlerTag, new GestureClass());\n this.updateGestureHandler(handlerTag, config);\n },\n attachGestureHandler(\n handlerTag: number,\n newView: number,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n NodeManager.getHandler(handlerTag).setView(newView, propsRef);\n },\n updateGestureHandler(handlerTag: number, newConfig: any) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n },\n getGestureHandlerNode(handlerTag: number) {\n return NodeManager.getHandler(handlerTag);\n },\n dropGestureHandler(handlerTag: number) {\n NodeManager.dropGestureHandler(handlerTag);\n },\n};\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","getHandler","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,iBAAiB,EAAjBA,0BADsB;AAEtBC,EAAAA,sBAAsB,EAAtBA,+BAFsB;AAGtBC,EAAAA,mBAAmB,EAAnBA,4BAHsB;AAItBC,EAAAA,iBAAiB,EAAjBA,0BAJsB;AAKtBC,EAAAA,wBAAwB,EAAxBA,iCALsB;AAMtBC,EAAAA,uBAAuB,EAAvBA,gCANsB;AAOtBC,EAAAA,mBAAmB,EAAnBA,4BAPsB,CAQtB;;AARsB,CAAjB;;eAWQ;AACbC,EAAAA,SAAS,EAATA,oBADa;;AAEbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAJY;;AAKbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GAPY;;AAQbE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA;AACA,QAAI,EAAEF,WAAW,IAAIhB,QAAjB,CAAJ,EACE,MAAM,IAAImB,KAAJ,CACH,iCAAgCH,WAAY,2BADzC,CAAN;AAGF,UAAMI,YAAY,GAAGpB,QAAQ,CAACgB,WAAD,CAA7B;AACAK,IAAAA,WAAW,CAACN,oBAAZ,CAAiCE,UAAjC,EAA6C,IAAIG,YAAJ,EAA7C;AACA,SAAKE,oBAAL,CAA0BL,UAA1B,EAAsCC,MAAtC;AACD,GArBY;;AAsBbK,EAAAA,oBAAoB,CAClBN,UADkB,EAElBO,OAFkB,EAGlBC,WAHkB,EAIlBC,QAJkB,EAKlB;AACAL,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCW,OAAnC,CAA2CJ,OAA3C,EAAoDE,QAApD;AACD,GA7BY;;AA8BbJ,EAAAA,oBAAoB,CAACL,UAAD,EAAqBY,SAArB,EAAqC;AACvDR,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCa,mBAAnC,CAAuDD,SAAvD;AACD,GAhCY;;AAiCbE,EAAAA,qBAAqB,CAACd,UAAD,EAAqB;AACxC,WAAOI,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,CAAP;AACD,GAnCY;;AAoCbe,EAAAA,kBAAkB,CAACf,UAAD,EAAqB;AACrCI,IAAAA,WAAW,CAACW,kBAAZ,CAA+Bf,UAA/B;AACD,GAtCY;;AAuCb;AACAgB,EAAAA,eAAe,GAAG,CAAE;;AAxCP,C","sourcesContent":["import { ActionType } from './ActionType';\nimport { Direction } from './web/constants';\nimport FlingGestureHandler from './web/FlingGestureHandler';\nimport LongPressGestureHandler from './web/LongPressGestureHandler';\nimport NativeViewGestureHandler from './web/NativeViewGestureHandler';\nimport * as NodeManager from './web/NodeManager';\nimport PanGestureHandler from './web/PanGestureHandler';\nimport PinchGestureHandler from './web/PinchGestureHandler';\nimport RotationGestureHandler from './web/RotationGestureHandler';\nimport TapGestureHandler from './web/TapGestureHandler';\n\nexport const Gestures = {\n PanGestureHandler,\n RotationGestureHandler,\n PinchGestureHandler,\n TapGestureHandler,\n NativeViewGestureHandler,\n LongPressGestureHandler,\n FlingGestureHandler,\n // ForceTouchGestureHandler,\n};\n\nexport default {\n Direction,\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n //TODO(TS) extends config\n if (!(handlerName in Gestures))\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(handlerTag, new GestureClass());\n this.updateGestureHandler(handlerTag, config);\n },\n attachGestureHandler(\n handlerTag: number,\n newView: number,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n NodeManager.getHandler(handlerTag).setView(newView, propsRef);\n },\n updateGestureHandler(handlerTag: number, newConfig: any) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n },\n getGestureHandlerNode(handlerTag: number) {\n return NodeManager.getHandler(handlerTag);\n },\n dropGestureHandler(handlerTag: number) {\n NodeManager.dropGestureHandler(handlerTag);\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EventType = void 0;
7
- const EventType = {
6
+ exports.TouchEventType = void 0;
7
+ const TouchEventType = {
8
8
  UNDETERMINED: 0,
9
9
  TOUCHES_DOWN: 1,
10
10
  TOUCHES_MOVE: 2,
@@ -12,5 +12,5 @@ const EventType = {
12
12
  TOUCHES_CANCELLED: 4
13
13
  }; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
14
14
 
15
- exports.EventType = EventType;
16
- //# sourceMappingURL=EventType.js.map
15
+ exports.TouchEventType = TouchEventType;
16
+ //# sourceMappingURL=TouchEventType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TouchEventType.ts"],"names":["TouchEventType","UNDETERMINED","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED"],"mappings":";;;;;;AAAO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,YAAY,EAAE,CADc;AAE5BC,EAAAA,YAAY,EAAE,CAFc;AAG5BC,EAAAA,YAAY,EAAE,CAHc;AAI5BC,EAAAA,UAAU,EAAE,CAJgB;AAK5BC,EAAAA,iBAAiB,EAAE;AALS,CAAvB,C,CAQP","sourcesContent":["export const TouchEventType = {\n UNDETERMINED: 0,\n TOUCHES_DOWN: 1,\n TOUCHES_MOVE: 2,\n TOUCHES_UP: 3,\n TOUCHES_CANCELLED: 4,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureButtons.tsx"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","CANCELLED","onPress","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","RectButton","Platform","OS","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","BorderlessButton","borderless"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AACA;;;;;;;;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Z;AAAmB,SAAGrB;AAAtB,QAA+B,KAAKlB,KAA1C;AAEA,wBACE,oBAAC,kBAAD,eACMkB,IADN;AAEE,MAAA,mBAAmB,EAAE,KAAKT,mBAF5B;AAGE,MAAA,KAAK,EAAE,CAAC8B,KAAD,EAAQP,sBAASC,EAAT,KAAgB,KAAhB,IAAyB;AAAEC,QAAAA,OAAO,EAAE,KAAKA;AAAhB,OAAjC;AAHT,QAIGI,QAJH,CADF;AAQD;;AAhC0E;;;;gBAAhEW,gB,kBACW;AACpBb,EAAAA,aAAa,EAAE,GADK;AAEpBc,EAAAA,UAAU,EAAE;AAFQ,C","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n Platform,\n processColor,\n StyleSheet,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from '../handlers/NativeViewGestureHandler';\n\nexport interface RawButtonProps extends NativeViewGestureHandlerProps {\n /**\n * Defines if more than one button could be pressed simultaneously. By default\n * set true.\n */\n exclusive?: boolean;\n // TODO: we should transform props in `createNativeWrapper`\n\n /**\n * Android only.\n *\n * Defines color of native ripple animation used since API level 21.\n */\n rippleColor?: any; // it was present in BaseButtonProps before but is used here in code\n}\n\nexport interface BaseButtonProps extends RawButtonProps {\n /**\n * Called when the button gets pressed (analogous to `onPress` in\n * `TouchableHighlight` from RN core).\n */\n onPress?: (pointerInside: boolean) => void;\n\n /**\n * Called when button changes from inactive to active and vice versa. It\n * passes active state as a boolean variable as a first parameter for that\n * method.\n */\n onActiveStateChange?: (active: boolean) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}\n\nexport interface RectButtonProps extends BaseButtonProps {\n /**\n * Background color that will be dimmed when button is in active state.\n */\n underlayColor?: string;\n\n /**\n * iOS only.\n *\n * Opacity applied to the underlay when button is in active state.\n */\n activeOpacity?: number;\n}\n\nexport interface BorderlessButtonProps extends BaseButtonProps {\n /**\n * Android only.\n *\n * Set this to false if you want the ripple animation to render only within view bounds.\n */\n borderless?: boolean;\n\n /**\n * iOS only.\n *\n * Opacity applied to the button when it is in an active state.\n */\n activeOpacity?: number;\n}\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nexport class BaseButton extends React.Component<BaseButtonProps> {\n private lastActive: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n this.lastActive = active;\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, ...rest } = this.props;\n\n return (\n <RawButton\n rippleColor={processColor(rippleColor)}\n {...rest}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}\n />\n );\n }\n}\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nexport class RectButton extends React.Component<RectButtonProps> {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n <BaseButton\n {...rest}\n style={resolvedStyle}\n onActiveStateChange={this.onActiveStateChange}>\n <Animated.View\n style={[\n btnStyles.underlay,\n {\n opacity: this.opacity,\n backgroundColor: this.props.underlayColor,\n borderRadius: resolvedStyle.borderRadius,\n borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,\n borderTopRightRadius: resolvedStyle.borderTopRightRadius,\n borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,\n borderBottomRightRadius: resolvedStyle.borderBottomRightRadius,\n },\n ]}\n />\n {children}\n </BaseButton>\n );\n }\n}\n\nexport class BorderlessButton extends React.Component<BorderlessButtonProps> {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n onActiveStateChange={this.onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}
1
+ {"version":3,"sources":["GestureButtons.tsx"],"names":["RawButton","GestureHandlerButton","shouldCancelWhenOutside","shouldActivateOnStart","BaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","CANCELLED","onPress","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","RectButton","Platform","OS","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","BorderlessButton","borderless"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AACA;;;;;;;;;;;;AAwFO,MAAMA,SAAS,GAAG,kCAAoBC,6BAApB,EAA0C;AACjEC,EAAAA,uBAAuB,EAAE,KADwC;AAEjEC,EAAAA,qBAAqB,EAAE;AAF0C,CAA1C,CAAlB;;;AAKA,MAAMC,UAAN,SAAyBC,KAAK,CAACC,SAA/B,CAA0D;AAG/DC,EAAAA,WAAW,CAACC,KAAD,EAAyB;AAClC,UAAMA,KAAN;;AADkC;;AAAA,yCAKd,CAAC;AACrBC,MAAAA;AADqB,KAAD,KAE0C;AAC9D,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA,QAAT;AAAmBC,QAAAA;AAAnB,UAAqCH,WAA3C;AACA,YAAMI,MAAM,GAAGD,aAAa,IAAIF,KAAK,KAAKI,aAAMC,MAAhD;;AAEA,UAAIF,MAAM,KAAK,KAAKG,UAAhB,IAA8B,KAAKR,KAAL,CAAWS,mBAA7C,EAAkE;AAChE,aAAKT,KAAL,CAAWS,mBAAX,CAA+BJ,MAA/B;AACD;;AAED,UACEF,QAAQ,KAAKG,aAAMC,MAAnB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,KADK;AAEpBO,EAAAA,aAAa,EAAE;AAFK,C;;AAkDjB,MAAMM,gBAAN,SAA+BpD,KAAK,CAACC,SAArC,CAAsE;AAQ3EC,EAAAA,WAAW,CAACC,KAAD,EAA+B;AACxC,UAAMA,KAAN;;AADwC;;AAAA,iDAKXK,MAAD,IAAqB;AAAA;;AACjD,UAAI2B,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,aAAKC,OAAL,CAAaC,QAAb,CAAsB9B,MAAM,GAAG,KAAKL,KAAL,CAAWoC,aAAd,GAA+B,CAA3D;AACD;;AAED,qDAAKpC,KAAL,EAAWS,mBAAX,qGAAiCJ,MAAjC;AACD,KAXyC;;AAExC,SAAK6B,OAAL,GAAe,IAAId,sBAASiB,KAAb,CAAmB,CAAnB,CAAf;AACD;;AAUDrB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEsB,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmB,SAAGrB;AAAtB,QAA+B,KAAKlB,KAA1C;AAEA,wBACE,oBAAC,kBAAD,eACMkB,IADN;AAEE,MAAA,mBAAmB,EAAE,KAAKT,mBAF5B;AAGE,MAAA,KAAK,EAAE,CAAC8B,KAAD,EAAQP,sBAASC,EAAT,KAAgB,KAAhB,IAAyB;AAAEC,QAAAA,OAAO,EAAE,KAAKA;AAAhB,OAAjC;AAHT,QAIGI,QAJH,CADF;AAQD;;AAhC0E;;;;gBAAhEW,gB,kBACW;AACpBb,EAAAA,aAAa,EAAE,GADK;AAEpBc,EAAAA,UAAU,EAAE;AAFQ,C","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n Platform,\n processColor,\n StyleSheet,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport createNativeWrapper from '../handlers/createNativeWrapper';\nimport GestureHandlerButton from './GestureHandlerButton';\nimport { State } from '../State';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from '../handlers/NativeViewGestureHandler';\n\nexport interface RawButtonProps extends NativeViewGestureHandlerProps {\n /**\n * Defines if more than one button could be pressed simultaneously. By default\n * set true.\n */\n exclusive?: boolean;\n // TODO: we should transform props in `createNativeWrapper`\n\n /**\n * Android only.\n *\n * Defines color of native ripple animation used since API level 21.\n */\n rippleColor?: any; // it was present in BaseButtonProps before but is used here in code\n\n /**\n * Android only.\n *\n * Defines radius of native ripple animation used since API level 21.\n */\n rippleRadius?: number | null;\n\n /**\n * Android only.\n *\n * Set this to true if you want the ripple animation to render outside the view bounds.\n */\n borderless?: boolean;\n\n /**\n * Android only.\n *\n * Defines whether the ripple animation should be drawn on the foreground of the view.\n */\n foreground?: boolean;\n}\n\nexport interface BaseButtonProps extends RawButtonProps {\n /**\n * Called when the button gets pressed (analogous to `onPress` in\n * `TouchableHighlight` from RN core).\n */\n onPress?: (pointerInside: boolean) => void;\n\n /**\n * Called when button changes from inactive to active and vice versa. It\n * passes active state as a boolean variable as a first parameter for that\n * method.\n */\n onActiveStateChange?: (active: boolean) => void;\n style?: StyleProp<ViewStyle>;\n testID?: string;\n}\n\nexport interface RectButtonProps extends BaseButtonProps {\n /**\n * Background color that will be dimmed when button is in active state.\n */\n underlayColor?: string;\n\n /**\n * iOS only.\n *\n * Opacity applied to the underlay when button is in active state.\n */\n activeOpacity?: number;\n}\n\nexport interface BorderlessButtonProps extends BaseButtonProps {\n /**\n * iOS only.\n *\n * Opacity applied to the button when it is in an active state.\n */\n activeOpacity?: number;\n}\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nexport class BaseButton extends React.Component<BaseButtonProps> {\n private lastActive: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n }\n\n private handleEvent = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state, oldState, pointerInside } = nativeEvent;\n const active = pointerInside && state === State.ACTIVE;\n\n if (active !== this.lastActive && this.props.onActiveStateChange) {\n this.props.onActiveStateChange(active);\n }\n\n if (\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n this.lastActive = active;\n };\n\n // Normally, the parent would execute it's handler first, then forward the\n // event to listeners. However, here our handler is virtually only forwarding\n // events to listeners, so we reverse the order to keep the proper order of\n // the callbacks (from \"raw\" ones to \"processed\").\n private onHandlerStateChange = (\n e: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onHandlerStateChange?.(e);\n this.handleEvent(e);\n };\n\n private onGestureEvent = (\n e: GestureEvent<NativeViewGestureHandlerPayload>\n ) => {\n this.props.onGestureEvent?.(e);\n this.handleEvent(\n e as HandlerStateChangeEvent<NativeViewGestureHandlerPayload>\n ); // TODO: maybe it is not correct\n };\n\n render() {\n const { rippleColor, ...rest } = this.props;\n\n return (\n <RawButton\n rippleColor={processColor(rippleColor)}\n {...rest}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}\n />\n );\n }\n}\n\nconst AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);\n\nconst btnStyles = StyleSheet.create({\n underlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n top: 0,\n },\n});\n\nexport class RectButton extends React.Component<RectButtonProps> {\n static defaultProps = {\n activeOpacity: 0.105,\n underlayColor: 'black',\n };\n\n private opacity: Animated.Value;\n\n constructor(props: RectButtonProps) {\n super(props);\n this.opacity = new Animated.Value(0);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 0);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n const resolvedStyle = StyleSheet.flatten(style ?? {});\n\n return (\n <BaseButton\n {...rest}\n style={resolvedStyle}\n onActiveStateChange={this.onActiveStateChange}>\n <Animated.View\n style={[\n btnStyles.underlay,\n {\n opacity: this.opacity,\n backgroundColor: this.props.underlayColor,\n borderRadius: resolvedStyle.borderRadius,\n borderTopLeftRadius: resolvedStyle.borderTopLeftRadius,\n borderTopRightRadius: resolvedStyle.borderTopRightRadius,\n borderBottomLeftRadius: resolvedStyle.borderBottomLeftRadius,\n borderBottomRightRadius: resolvedStyle.borderBottomRightRadius,\n },\n ]}\n />\n {children}\n </BaseButton>\n );\n }\n}\n\nexport class BorderlessButton extends React.Component<BorderlessButtonProps> {\n static defaultProps = {\n activeOpacity: 0.3,\n borderless: true,\n };\n\n private opacity: Animated.Value;\n\n constructor(props: BorderlessButtonProps) {\n super(props);\n this.opacity = new Animated.Value(1);\n }\n\n private onActiveStateChange = (active: boolean) => {\n if (Platform.OS !== 'android') {\n this.opacity.setValue(active ? this.props.activeOpacity! : 1);\n }\n\n this.props.onActiveStateChange?.(active);\n };\n\n render() {\n const { children, style, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n onActiveStateChange={this.onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}
@@ -10,7 +10,7 @@ var _reactNative = require("react-native");
10
10
  var _utils = require("../utils");
11
11
 
12
12
  /* eslint-disable @typescript-eslint/no-var-requires */
13
- const RNGestureHandlerButtonNativeComponent = (0, _utils.isFabric)() ? require('../fabric/RNGestureHandlerButtonNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerButton');
13
+ const RNGestureHandlerButtonNativeComponent = (0, _utils.shouldUseCodegenNativeComponent)() ? require('../fabric/RNGestureHandlerButtonNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerButton');
14
14
  var _default = RNGestureHandlerButtonNativeComponent;
15
15
  exports.default = _default;
16
16
  //# sourceMappingURL=GestureHandlerButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerButton.tsx"],"names":["RNGestureHandlerButtonNativeComponent","require","default"],"mappings":";;;;;;;AACA;;AAEA;;AAHA;AAKA,MAAMA,qCAAqC,GAAG,yBAC1CC,OAAO,CAAC,iDAAD,CAAP,CAA2DC,OADjB,GAE1C,yCAAuB,wBAAvB,CAFJ;eAIeF,qC","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { HostComponent, requireNativeComponent } from 'react-native';\nimport { RawButtonProps } from './GestureButtons';\nimport { isFabric } from '../utils';\n\nconst RNGestureHandlerButtonNativeComponent = isFabric()\n ? require('../fabric/RNGestureHandlerButtonNativeComponent').default\n : requireNativeComponent('RNGestureHandlerButton');\n\nexport default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;\n"]}
1
+ {"version":3,"sources":["GestureHandlerButton.tsx"],"names":["RNGestureHandlerButtonNativeComponent","require","default"],"mappings":";;;;;;;AACA;;AAEA;;AAHA;AAKA,MAAMA,qCAAqC,GAAG,gDAC1CC,OAAO,CAAC,iDAAD,CAAP,CAA2DC,OADjB,GAE1C,yCAAuB,wBAAvB,CAFJ;eAIeF,qC","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { HostComponent, requireNativeComponent } from 'react-native';\nimport { RawButtonProps } from './GestureButtons';\nimport { shouldUseCodegenNativeComponent } from '../utils';\n\nconst RNGestureHandlerButtonNativeComponent = shouldUseCodegenNativeComponent()\n ? require('../fabric/RNGestureHandlerButtonNativeComponent').default\n : requireNativeComponent('RNGestureHandlerButton');\n\nexport default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;\n"]}
@@ -246,6 +246,8 @@ class GenericTouchable extends React.Component {
246
246
  // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,
247
247
  // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016
248
248
  accessibilityState: this.props.accessibilityState,
249
+ accessibilityActions: this.props.accessibilityActions,
250
+ onAccessibilityAction: this.props.onAccessibilityAction,
249
251
  nativeID: this.props.nativeID,
250
252
  onLayout: this.props.onLayout,
251
253
  hitSlop: this.props.hitSlop
@@ -1 +1 @@
1
- {"version":3,"sources":["GenericTouchable.tsx"],"names":["TOUCHABLE_STATE","UNDETERMINED","BEGAN","MOVED_OUTSIDE","GenericTouchable","Component","nativeEvent","pointerInside","onMoveIn","onMoveOut","state","State","CANCELLED","FAILED","moveToState","Platform","OS","ACTIVE","STATE","handlePressIn","END","shouldCallOnPress","longPressDetected","pressOutTimeout","handleGoToUndetermined","props","onPress","onLongPress","delayPressIn","pressInTimeout","setTimeout","time","delayLongPress","longPressTimeout","onLongPressDetected","handleMoveOutside","delayPressOut","clearTimeout","componentDidMount","reset","newState","onPressIn","onPressOut","onStateChange","componentWillUnmount","render","coreProps","accessible","accessibilityLabel","accessibilityHint","accessibilityRole","accessibilityState","nativeID","onLayout","hitSlop","containerStyle","disabled","undefined","onHandlerStateChange","onGestureEvent","shouldActivateOnStart","disallowInterruption","testID","extraButtonProps","style","children","rippleColor","exclusive"],"mappings":";;;;;;;AAAA;;AAEA;;AAQA;;AACA;;;;;;;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG;AAC7BC,EAAAA,YAAY,EAAE,CADe;AAE7BC,EAAAA,KAAK,EAAE,CAFsB;AAG7BC,EAAAA,aAAa,EAAE;AAHc,CAAxB;;;AAkCP;AACA;AACA;AACA;AAEe,MAAMC,gBAAN,SAA+BC,eAA/B,CAEb;AAAA;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,+CAeoB,KAfpB;;AAAA,2CAiBgB,IAjBhB;;AAAA,mCAoBwBL,eAAe,CAACC,YApBxC;;AAAA,4CAkHiB,CAAC;AAChBK,MAAAA,WAAW,EAAE;AAAEC,QAAAA;AAAF;AADG,KAAD,KAEoC;AACnD,UAAI,KAAKA,aAAL,KAAuBA,aAA3B,EA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E,KAAKlC,KAAL,CAAW6B,OAPtB;AAQE,MAAA,qBAAqB,EAAE,KAAK7B,KAAL,CAAWmC,qBARpC;AASE,MAAA,oBAAoB,EAAE,KAAKnC,KAAL,CAAWoC,oBATnC;AAUE,MAAA,MAAM,EAAE,KAAKpC,KAAL,CAAWqC;AAVrB,OAWM,KAAKrC,KAAL,CAAWsC,gBAXjB,gBAYE,oBAAC,qBAAD,CAAU,IAAV,eAAmBjB,SAAnB;AAA8B,MAAA,KAAK,EAAE,KAAKrB,KAAL,CAAWuC;AAAhD,QACG,KAAKvC,KAAL,CAAWwC,QADd,CAZF,CADF;AAkBD;;AAvND;;;;gBAFmB7D,gB,kBAGG;AACpB4B,EAAAA,cAAc,EAAE,GADI;AAEpB+B,EAAAA,gBAAgB,EAAE;AAChBG,IAAAA,WAAW,EAAE,aADG;AAEhBC,IAAAA,SAAS,EAAE;AAFK;AAFE,C","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n Platform,\n StyleProp,\n ViewStyle,\n TouchableWithoutFeedbackProps,\n} from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport { NativeViewGestureHandlerPayload } from '../../handlers/NativeViewGestureHandler';\nimport { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n UNDETERMINED: 0,\n BEGAN: 1,\n MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];\n\nexport interface GenericTouchableProps extends TouchableWithoutFeedbackProps {\n // Decided to drop not used fields from RN's implementation.\n // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment\n\n // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too\n onPress?: () => void;\n onPressIn?: () => void;\n onPressOut?: () => void;\n onLongPress?: () => void;\n\n nativeID?: string;\n shouldActivateOnStart?: boolean;\n disallowInterruption?: boolean;\n\n containerStyle?: StyleProp<ViewStyle>;\n}\n\ninterface InternalProps {\n extraButtonProps: TouchableNativeFeedbackExtraProps;\n onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType<typeof setTimeout> | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n GenericTouchableProps & InternalProps\n> {\n static defaultProps = {\n delayLongPress: 600,\n extraButtonProps: {\n rippleColor: 'transparent',\n exclusive: true,\n },\n };\n\n // timeout handlers\n pressInTimeout: Timeout;\n pressOutTimeout: Timeout;\n longPressTimeout: Timeout;\n\n // This flag is required since recognition of longPress implies not-invoking onPress\n longPressDetected = false;\n\n pointerInside = true;\n\n // State of touchable\n STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n // handlePressIn in called on first touch on traveling inside component.\n // Handles state transition with delay.\n handlePressIn() {\n if (this.props.delayPressIn) {\n this.pressInTimeout = setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n this.pressInTimeout = null;\n }, this.props.delayPressIn);\n } else {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n if (this.props.onLongPress) {\n const time =\n (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n }\n }\n // handleMoveOutside in called on traveling outside component.\n // Handles state transition with delay.\n handleMoveOutside() {\n if (this.props.delayPressOut) {\n this.pressOutTimeout =\n this.pressOutTimeout ||\n setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n }\n }\n\n // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n handleGoToUndetermined() {\n clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n if (this.props.delayPressOut) {\n this.pressOutTimeout = setTimeout(() => {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n }\n }\n\n componentDidMount() {\n this.reset();\n }\n // reset timeout to prevent memory leaks.\n reset() {\n this.longPressDetected = false;\n this.pointerInside = true;\n clearTimeout(this.pressInTimeout!);\n clearTimeout(this.pressOutTimeout!);\n clearTimeout(this.longPressTimeout!);\n this.pressOutTimeout = null;\n this.longPressTimeout = null;\n this.pressInTimeout = null;\n }\n\n // All states' transitions are defined here.\n moveToState(newState: TouchableState) {\n if (newState === this.STATE) {\n // Ignore dummy transitions\n return;\n }\n if (newState === TOUCHABLE_STATE.BEGAN) {\n // First touch and moving inside\n this.props.onPressIn?.();\n } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // Moving outside\n this.props.onPressOut?.();\n } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n // Need to reset each time on transition to UNDETERMINED\n this.reset();\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n // ... and if it happens inside button.\n this.props.onPressOut?.();\n }\n }\n // Finally call lister (used by subclasses)\n this.props.onStateChange?.(this.STATE, newState);\n // ... and make transition.\n this.STATE = newState;\n }\n\n onGestureEvent = ({\n nativeEvent: { pointerInside },\n }: GestureEvent<NativeViewGestureHandlerPayload>) => {\n if (this.pointerInside !== pointerInside) {\n if (pointerInside) {\n this.onMoveIn();\n } else {\n this.onMoveOut();\n }\n }\n this.pointerInside = pointerInside;\n };\n\n onHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state } = nativeEvent;\n if (state === State.CANCELLED || state === State.FAILED) {\n // Need to handle case with external cancellation (e.g. by ScrollView)\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n } else if (\n // This platform check is an implication of slightly different behavior of handlers on different platform.\n // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n // On iOS event on \"Began\" is not delivered.\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n this.STATE === TOUCHABLE_STATE.UNDETERMINED\n ) {\n // Moving inside requires\n this.handlePressIn();\n } else if (state === State.END) {\n const shouldCallOnPress =\n !this.longPressDetected &&\n this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n this.pressOutTimeout === null;\n this.handleGoToUndetermined();\n if (shouldCallOnPress) {\n // Calls only inside component whether no long press was called previously\n this.props.onPress?.();\n }\n }\n };\n\n onLongPressDetected = () => {\n this.longPressDetected = true;\n // checked for in the caller of `onLongPressDetected`, but better to check twice\n this.props.onLongPress?.();\n };\n\n componentWillUnmount() {\n // to prevent memory leaks\n this.reset();\n }\n\n onMoveIn() {\n if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // This call is not throttled with delays (like in RN's implementation).\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n }\n\n onMoveOut() {\n // long press should no longer be detected\n clearTimeout(this.longPressTimeout!);\n this.longPressTimeout = null;\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n this.handleMoveOutside();\n }\n }\n\n render() {\n const coreProps = {\n accessible: this.props.accessible !== false,\n accessibilityLabel: this.props.accessibilityLabel,\n accessibilityHint: this.props.accessibilityHint,\n accessibilityRole: this.props.accessibilityRole,\n // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n accessibilityState: this.props.accessibilityState,\n nativeID: this.props.nativeID,\n onLayout: this.props.onLayout,\n hitSlop: this.props.hitSlop,\n };\n\n return (\n <BaseButton\n style={this.props.containerStyle}\n onHandlerStateChange={\n // TODO: not sure if it can be undefined instead of null\n this.props.disabled ? undefined : this.onHandlerStateChange\n }\n onGestureEvent={this.onGestureEvent}\n hitSlop={this.props.hitSlop}\n shouldActivateOnStart={this.props.shouldActivateOnStart}\n disallowInterruption={this.props.disallowInterruption}\n testID={this.props.testID}\n {...this.props.extraButtonProps}>\n <Animated.View {...coreProps} style={this.props.style}>\n {this.props.children}\n </Animated.View>\n </BaseButton>\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["GenericTouchable.tsx"],"names":["TOUCHABLE_STATE","UNDETERMINED","BEGAN","MOVED_OUTSIDE","GenericTouchable","Component","nativeEvent","pointerInside","onMoveIn","onMoveOut","state","State","CANCELLED","FAILED","moveToState","Platform","OS","ACTIVE","STATE","handlePressIn","END","shouldCallOnPress","longPressDetected","pressOutTimeout","handleGoToUndetermined","props","onPress","onLongPress","delayPressIn","pressInTimeout","setTimeout","time","delayLongPress","longPressTimeout","onLongPressDetected","handleMoveOutside","delayPressOut","clearTimeout","componentDidMount","reset","newState","onPressIn","onPressOut","onStateChange","componentWillUnmount","render","coreProps","accessible","accessibilityLabel","accessibilityHint","accessibilityRole","accessibilityState","accessibilityActions","onAccessibilityAction","nativeID","onLayout","hitSlop","containerStyle","disabled","undefined","onHandlerStateChange","onGestureEvent","shouldActivateOnStart","disallowInterruption","testID","extraButtonProps","style","children","rippleColor","exclusive"],"mappings":";;;;;;;AAAA;;AAEA;;AAQA;;AACA;;;;;;;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,M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KAAK1B,KAAL,CAAW0B,kBAPf;AAQhBC,MAAAA,oBAAoB,EAAE,KAAK3B,KAAL,CAAW2B,oBARjB;AAShBC,MAAAA,qBAAqB,EAAE,KAAK5B,KAAL,CAAW4B,qBATlB;AAUhBC,MAAAA,QAAQ,EAAE,KAAK7B,KAAL,CAAW6B,QAVL;AAWhBC,MAAAA,QAAQ,EAAE,KAAK9B,KAAL,CAAW8B,QAXL;AAYhBC,MAAAA,OAAO,EAAE,KAAK/B,KAAL,CAAW+B;AAZJ,KAAlB;AAeA,wBACE,oBAAC,0BAAD;AACE,MAAA,KAAK,EAAE,KAAK/B,KAAL,CAAWgC,cADpB;AAEE,MAAA,oBAAoB,EAClB;AACA,WAAKhC,KAAL,CAAWiC,QAAX,GAAsBC,SAAtB,GAAkC,KAAKC,oBAJ3C;AAME,MAAA,cAAc,EAAE,KAAKC,cANvB;AAOE,MAAA,OAAO,EAAE,KAAKpC,KAAL,CAAW+B,OAPtB;AAQE,MAAA,qBAAqB,EAAE,KAAK/B,KAAL,CAAWqC,qBARpC;AASE,MAAA,oBAAoB,EAAE,KAAKrC,KAAL,CAAWsC,oBATnC;AAUE,MAAA,MAAM,EAAE,KAAKtC,KAAL,CAAWuC;AAVrB,OAWM,KAAKvC,KAAL,CAAWwC,gBAXjB,gBAYE,oBAAC,qBAAD,CAAU,IAAV,eAAmBnB,SAAnB;AAA8B,MAAA,KAAK,EAAE,KAAKrB,KAAL,CAAWyC;AAAhD,QACG,KAAKzC,KAAL,CAAW0C,QADd,CAZF,CADF;AAkBD;;AAzND;;;;gBAFmB/D,gB,kBAGG;AACpB4B,EAAAA,cAAc,EAAE,GADI;AAEpBiC,EAAAA,gBAAgB,EAAE;AAChBG,IAAAA,WAAW,EAAE,aADG;AAEhBC,IAAAA,SAAS,EAAE;AAFK;AAFE,C","sourcesContent":["import * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n Platform,\n StyleProp,\n ViewStyle,\n TouchableWithoutFeedbackProps,\n} from 'react-native';\n\nimport { State } from '../../State';\nimport { BaseButton } from '../GestureButtons';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../../handlers/gestureHandlerCommon';\nimport { NativeViewGestureHandlerPayload } from '../../handlers/NativeViewGestureHandler';\nimport { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android';\n\n/**\n * Each touchable is a states' machine which preforms transitions.\n * On very beginning (and on the very end or recognition) touchable is\n * UNDETERMINED. Then it moves to BEGAN. If touchable recognizes that finger\n * travel outside it transits to special MOVED_OUTSIDE state. Gesture recognition\n * finishes in UNDETERMINED state.\n */\nexport const TOUCHABLE_STATE = {\n UNDETERMINED: 0,\n BEGAN: 1,\n MOVED_OUTSIDE: 2,\n} as const;\n\ntype TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];\n\nexport interface GenericTouchableProps extends TouchableWithoutFeedbackProps {\n // Decided to drop not used fields from RN's implementation.\n // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment\n\n // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too\n onPress?: () => void;\n onPressIn?: () => void;\n onPressOut?: () => void;\n onLongPress?: () => void;\n\n nativeID?: string;\n shouldActivateOnStart?: boolean;\n disallowInterruption?: boolean;\n\n containerStyle?: StyleProp<ViewStyle>;\n}\n\ninterface InternalProps {\n extraButtonProps: TouchableNativeFeedbackExtraProps;\n onStateChange?: (oldState: TouchableState, newState: TouchableState) => void;\n}\n\n// TODO: maybe can be better\n// TODO: all clearTimeout have ! added, maybe they shouldn't ?\ntype Timeout = ReturnType<typeof setTimeout> | null | undefined;\n\n/**\n * GenericTouchable is not intented to be used as it is.\n * Should be treated as a source for the rest of touchables\n */\n\nexport default class GenericTouchable extends Component<\n GenericTouchableProps & InternalProps\n> {\n static defaultProps = {\n delayLongPress: 600,\n extraButtonProps: {\n rippleColor: 'transparent',\n exclusive: true,\n },\n };\n\n // timeout handlers\n pressInTimeout: Timeout;\n pressOutTimeout: Timeout;\n longPressTimeout: Timeout;\n\n // This flag is required since recognition of longPress implies not-invoking onPress\n longPressDetected = false;\n\n pointerInside = true;\n\n // State of touchable\n STATE: TouchableState = TOUCHABLE_STATE.UNDETERMINED;\n\n // handlePressIn in called on first touch on traveling inside component.\n // Handles state transition with delay.\n handlePressIn() {\n if (this.props.delayPressIn) {\n this.pressInTimeout = setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n this.pressInTimeout = null;\n }, this.props.delayPressIn);\n } else {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n if (this.props.onLongPress) {\n const time =\n (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0);\n this.longPressTimeout = setTimeout(this.onLongPressDetected, time);\n }\n }\n // handleMoveOutside in called on traveling outside component.\n // Handles state transition with delay.\n handleMoveOutside() {\n if (this.props.delayPressOut) {\n this.pressOutTimeout =\n this.pressOutTimeout ||\n setTimeout(() => {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE);\n }\n }\n\n // handleGoToUndetermined transits to UNDETERMINED state with proper delay\n handleGoToUndetermined() {\n clearTimeout(this.pressOutTimeout!); // TODO: maybe it can be undefined\n if (this.props.delayPressOut) {\n this.pressOutTimeout = setTimeout(() => {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n this.pressOutTimeout = null;\n }, this.props.delayPressOut);\n } else {\n if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) {\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n }\n }\n\n componentDidMount() {\n this.reset();\n }\n // reset timeout to prevent memory leaks.\n reset() {\n this.longPressDetected = false;\n this.pointerInside = true;\n clearTimeout(this.pressInTimeout!);\n clearTimeout(this.pressOutTimeout!);\n clearTimeout(this.longPressTimeout!);\n this.pressOutTimeout = null;\n this.longPressTimeout = null;\n this.pressInTimeout = null;\n }\n\n // All states' transitions are defined here.\n moveToState(newState: TouchableState) {\n if (newState === this.STATE) {\n // Ignore dummy transitions\n return;\n }\n if (newState === TOUCHABLE_STATE.BEGAN) {\n // First touch and moving inside\n this.props.onPressIn?.();\n } else if (newState === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // Moving outside\n this.props.onPressOut?.();\n } else if (newState === TOUCHABLE_STATE.UNDETERMINED) {\n // Need to reset each time on transition to UNDETERMINED\n this.reset();\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n // ... and if it happens inside button.\n this.props.onPressOut?.();\n }\n }\n // Finally call lister (used by subclasses)\n this.props.onStateChange?.(this.STATE, newState);\n // ... and make transition.\n this.STATE = newState;\n }\n\n onGestureEvent = ({\n nativeEvent: { pointerInside },\n }: GestureEvent<NativeViewGestureHandlerPayload>) => {\n if (this.pointerInside !== pointerInside) {\n if (pointerInside) {\n this.onMoveIn();\n } else {\n this.onMoveOut();\n }\n }\n this.pointerInside = pointerInside;\n };\n\n onHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {\n const { state } = nativeEvent;\n if (state === State.CANCELLED || state === State.FAILED) {\n // Need to handle case with external cancellation (e.g. by ScrollView)\n this.moveToState(TOUCHABLE_STATE.UNDETERMINED);\n } else if (\n // This platform check is an implication of slightly different behavior of handlers on different platform.\n // And Android \"Active\" state is achieving on first move of a finger, not on press in.\n // On iOS event on \"Began\" is not delivered.\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n this.STATE === TOUCHABLE_STATE.UNDETERMINED\n ) {\n // Moving inside requires\n this.handlePressIn();\n } else if (state === State.END) {\n const shouldCallOnPress =\n !this.longPressDetected &&\n this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE &&\n this.pressOutTimeout === null;\n this.handleGoToUndetermined();\n if (shouldCallOnPress) {\n // Calls only inside component whether no long press was called previously\n this.props.onPress?.();\n }\n }\n };\n\n onLongPressDetected = () => {\n this.longPressDetected = true;\n // checked for in the caller of `onLongPressDetected`, but better to check twice\n this.props.onLongPress?.();\n };\n\n componentWillUnmount() {\n // to prevent memory leaks\n this.reset();\n }\n\n onMoveIn() {\n if (this.STATE === TOUCHABLE_STATE.MOVED_OUTSIDE) {\n // This call is not throttled with delays (like in RN's implementation).\n this.moveToState(TOUCHABLE_STATE.BEGAN);\n }\n }\n\n onMoveOut() {\n // long press should no longer be detected\n clearTimeout(this.longPressTimeout!);\n this.longPressTimeout = null;\n if (this.STATE === TOUCHABLE_STATE.BEGAN) {\n this.handleMoveOutside();\n }\n }\n\n render() {\n const coreProps = {\n accessible: this.props.accessible !== false,\n accessibilityLabel: this.props.accessibilityLabel,\n accessibilityHint: this.props.accessibilityHint,\n accessibilityRole: this.props.accessibilityRole,\n // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,\n // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016\n accessibilityState: this.props.accessibilityState,\n accessibilityActions: this.props.accessibilityActions,\n onAccessibilityAction: this.props.onAccessibilityAction,\n nativeID: this.props.nativeID,\n onLayout: this.props.onLayout,\n hitSlop: this.props.hitSlop,\n };\n\n return (\n <BaseButton\n style={this.props.containerStyle}\n onHandlerStateChange={\n // TODO: not sure if it can be undefined instead of null\n this.props.disabled ? undefined : this.onHandlerStateChange\n }\n onGestureEvent={this.onGestureEvent}\n hitSlop={this.props.hitSlop}\n shouldActivateOnStart={this.props.shouldActivateOnStart}\n disallowInterruption={this.props.disallowInterruption}\n testID={this.props.testID}\n {...this.props.extraButtonProps}>\n <Animated.View {...coreProps} style={this.props.style}>\n {this.props.children}\n </Animated.View>\n </BaseButton>\n );\n }\n}\n"]}