react-native-gesture-handler 2.16.2 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +9 -3
- package/android/build.gradle +105 -0
- package/android/gradle.properties +7 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +7 -7
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -5
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +4 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +1 -0
- package/apple/RNGestureHandlerButtonComponentView.mm +10 -0
- package/apple/RNGestureHandlerModule.mm +2 -3
- package/lib/commonjs/components/GestureButtons.js +27 -12
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +1 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +3 -3
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js +42 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +83 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +143 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js +6 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +80 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +180 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +55 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +47 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +176 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +3 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/utils.js +36 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +56 -64
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +28 -18
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +18 -12
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +7 -2
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +89 -57
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +6 -2
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +2 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/commonjs/web/utils.js +31 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/components/GestureButtons.js +24 -6
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/handlers/createHandler.js +2 -4
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js +26 -0
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +65 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +115 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +64 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +165 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +41 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +36 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js +142 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +3 -1
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/utils.js +34 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +56 -64
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +28 -18
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +18 -12
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +8 -3
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +89 -57
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +7 -3
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/Vector.js +2 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/module/web/utils.js +29 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +3 -34
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -2
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +2 -0
- package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts} +4 -12
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +20 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +4 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +2 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +5 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -1
- package/lib/typescript/utils.d.ts +10 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +34 -31
- package/lib/typescript/web/utils.d.ts +4 -0
- package/package.json +5 -5
- package/src/components/GestureButtons.tsx +36 -4
- package/src/handlers/createHandler.tsx +1 -3
- package/src/handlers/gestureHandlerCommon.ts +4 -1
- package/src/handlers/gestures/GestureDetector/Wrap.tsx +35 -0
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +112 -0
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +14 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +187 -0
- package/src/handlers/gestures/GestureDetector/needsToReattach.ts +27 -0
- package/src/handlers/gestures/GestureDetector/types.ts +32 -0
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +94 -0
- package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +206 -0
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +69 -0
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +54 -0
- package/src/handlers/gestures/GestureDetector/utils.ts +185 -0
- package/src/handlers/gestures/gestureComposition.ts +2 -0
- package/src/handlers/gestures/gestureStateManager.ts +12 -4
- package/src/handlers/gestures/reanimatedWrapper.ts +19 -17
- package/src/utils.ts +39 -0
- package/src/web/detectors/RotationGestureDetector.ts +6 -8
- package/src/web/detectors/ScaleGestureDetector.ts +5 -6
- package/src/web/handlers/FlingGestureHandler.ts +2 -0
- package/src/web/handlers/GestureHandler.ts +53 -62
- package/src/web/handlers/LongPressGestureHandler.ts +2 -0
- package/src/web/handlers/ManualGestureHandler.ts +2 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +8 -4
- package/src/web/handlers/PanGestureHandler.ts +32 -19
- package/src/web/handlers/PinchGestureHandler.ts +2 -0
- package/src/web/handlers/RotationGestureHandler.ts +2 -0
- package/src/web/handlers/TapGestureHandler.ts +20 -12
- package/src/web/interfaces.ts +1 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
- package/src/web/tools/PointerEventManager.ts +10 -3
- package/src/web/tools/PointerTracker.ts +81 -74
- package/src/web/tools/TouchEventManager.ts +5 -3
- package/src/web/tools/Vector.ts +2 -4
- package/src/web/utils.ts +34 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -704
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/module/handlers/gestures/GestureDetector.js +0 -654
- package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
- package/src/handlers/gestures/GestureDetector.tsx +0 -889
package/README.md
CHANGED
@@ -27,13 +27,11 @@ If you want to play with the API but don't feel like trying it on a real app, yo
|
|
27
27
|
yarn install
|
28
28
|
```
|
29
29
|
|
30
|
-
If you are running on ios, run `pod install` in the ios folder
|
31
|
-
|
32
30
|
Run `yarn start` to start the metro bundler
|
33
31
|
|
34
32
|
Run `yarn android` or `yarn ios` (depending on which platform you want to run the example app on).
|
35
33
|
|
36
|
-
You will need to have an Android or iOS device or emulator connected
|
34
|
+
You will need to have an Android or iOS device or emulator connected.
|
37
35
|
|
38
36
|
## React Native Support
|
39
37
|
|
@@ -61,3 +59,11 @@ This project has been build and is maintained thanks to the support from [Shopif
|
|
61
59
|
[![shopify](https://avatars1.githubusercontent.com/u/8085?v=3&s=100 'Shopify.com')](https://shopify.com)
|
62
60
|
[![expo](https://avatars2.githubusercontent.com/u/12504344?v=3&s=100 'Expo.io')](https://expo.io)
|
63
61
|
[![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-reanimated-github 'Software Mansion')](https://swmansion.com)
|
62
|
+
|
63
|
+
## Community Discord
|
64
|
+
|
65
|
+
[Join the Software Mansion Community Discord](https://discord.swmansion.com) to chat about Gesture Handler or other Software Mansion libraries.
|
66
|
+
|
67
|
+
## Gesture Handler is created by Software Mansion
|
68
|
+
|
69
|
+
Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=gesture-handler&utm_medium=readme).
|
package/android/build.gradle
CHANGED
@@ -207,3 +207,108 @@ dependencies {
|
|
207
207
|
implementation "androidx.core:core-ktx:1.6.0"
|
208
208
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
209
209
|
}
|
210
|
+
|
211
|
+
def isGHExampleApp() {
|
212
|
+
return project.hasProperty('isGHExampleApp') && project.property('isGHExampleApp') == "true"
|
213
|
+
}
|
214
|
+
|
215
|
+
def getAbsoluteCodegenArtifactsPaperDestination() {
|
216
|
+
if (!project.hasProperty('codegenArtifactsPaperDestination')) {
|
217
|
+
throw new Exception('[react-native-gesture-handler] Please fill codegenArtifactsPaperDestination variable in android/gradle.properties to point to the correct path to generated specs for paper')
|
218
|
+
}
|
219
|
+
|
220
|
+
return "${project.rootDir}/../../${project.property('codegenArtifactsPaperDestination')}"
|
221
|
+
}
|
222
|
+
|
223
|
+
def getAbsoluteCodegenArtifactsSource() {
|
224
|
+
if (!project.hasProperty('codegenArtifactsSource')) {
|
225
|
+
throw new Exception('[react-native-gesture-handler] Please fill codegenArtifactsSource variable in android/gradle.properties to point to the correct path to codegenerated artifacts')
|
226
|
+
}
|
227
|
+
|
228
|
+
return "${project.rootDir}/../../${project.property('codegenArtifactsSource')}"
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
tasks.register('copyCodegenArtifacts') {
|
233
|
+
group 'After build tasks'
|
234
|
+
description 'Task which copies codegen artifacts to paper architecture'
|
235
|
+
|
236
|
+
if (!isGHExampleApp() || !isNewArchitectureEnabled()) {
|
237
|
+
return
|
238
|
+
}
|
239
|
+
|
240
|
+
dependsOn tasks.generateCodegenArtifactsFromSchema
|
241
|
+
|
242
|
+
doLast {
|
243
|
+
|
244
|
+
def absoluteCodegenArtifactsPaperDestination = getAbsoluteCodegenArtifactsPaperDestination()
|
245
|
+
def absoluteCodegenArtifactsSource = getAbsoluteCodegenArtifactsSource()
|
246
|
+
|
247
|
+
def existingFiles = fileTree(absoluteCodegenArtifactsPaperDestination).matching {
|
248
|
+
include '**/*.java'
|
249
|
+
}
|
250
|
+
|
251
|
+
def generatedFiles = fileTree(absoluteCodegenArtifactsSource).matching {
|
252
|
+
include '**/*.java'
|
253
|
+
}
|
254
|
+
|
255
|
+
def existingFilesMap = [:]
|
256
|
+
|
257
|
+
existingFiles.forEach { existingFile ->
|
258
|
+
println existingFile
|
259
|
+
existingFilesMap[existingFile.name] = 1
|
260
|
+
}
|
261
|
+
|
262
|
+
generatedFiles.forEach { generatedFile ->
|
263
|
+
if (!existingFilesMap.containsKey(generatedFile.name)) {
|
264
|
+
logger.warn("[react-native-gesture-handler] ${generatedFile.name} not found in paper dir, if it's used on Android you need to copy it manually and implement yourself before using auto-copy feature.")
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
if (existingFiles.size() == 0) {
|
269
|
+
logger.warn("[react-native-gesture-handler] Paper destination with codegen interfaces is empty. This might be okay if you don't have any interfaces/delegates used on Android, but if that's not the case please check if codegenArtifactsPaperDestination property in android/gradle.properties is correct.")
|
270
|
+
}
|
271
|
+
|
272
|
+
existingFiles.forEach { existingFile ->
|
273
|
+
def generatedFile = new File("${absoluteCodegenArtifactsSource}/${existingFile.name}")
|
274
|
+
|
275
|
+
if (!generatedFile.exists()) {
|
276
|
+
logger.warn("[react-native-gesture-handler] ${existingFile.name} file does not exist in codegen artifacts source destination. Please check if you still need this interface/delagete.")
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
copy {
|
281
|
+
from absoluteCodegenArtifactsSource
|
282
|
+
include existingFiles.collect { it.name }
|
283
|
+
into absoluteCodegenArtifactsPaperDestination
|
284
|
+
}
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
if (isGHExampleApp() && isNewArchitectureEnabled() && !project.hasProperty('skipCodegenCopyTask')) {
|
289
|
+
tasks.generateCodegenArtifactsFromSchema.finalizedBy('copyCodegenArtifacts')
|
290
|
+
}
|
291
|
+
|
292
|
+
tasks.register('checkIntegrityBetweenArchitectures') {
|
293
|
+
group 'Verification tasks'
|
294
|
+
description 'Task to check integrity between fabric and paper architecture in terms of codegen generated interfaces/delegates'
|
295
|
+
|
296
|
+
if (isGHExampleApp()) {
|
297
|
+
return
|
298
|
+
}
|
299
|
+
|
300
|
+
def absoluteCodegenArtifactsPaperDestination = "../${project.property('codegenArtifactsPaperDestination')}"
|
301
|
+
def absoluteCodegenArtifactsSource = "../${project.property('codegenArtifactsSource')}"
|
302
|
+
|
303
|
+
def existingFiles = fileTree(absoluteCodegenArtifactsPaperDestination).matching {
|
304
|
+
include '**/*.java'
|
305
|
+
}
|
306
|
+
|
307
|
+
existingFiles.forEach { existingFile ->
|
308
|
+
def generatedFile = new File("${absoluteCodegenArtifactsSource}/${existingFile.name}")
|
309
|
+
|
310
|
+
if (existingFile.text != generatedFile.text) {
|
311
|
+
throw new RuntimeException("[react-native-gesture-handler] The source of ${existingFile.name} does not match with the one generated by codegen. Please check if you commited changes produced by copyCodegenArtifacts task.")
|
312
|
+
}
|
313
|
+
}
|
314
|
+
}
|
@@ -17,3 +17,10 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemor
|
|
17
17
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
18
18
|
# org.gradle.parallel=true
|
19
19
|
RNGH_kotlinVersion=1.6.21
|
20
|
+
|
21
|
+
# Path to codegen output directory with this library view managers' interfaces & delegates. Used by `copyCodegenArtifacts` task that helps to synchronize newly generated files with their Paper counterparts.
|
22
|
+
codegenArtifactsSource=android/build/generated/source/codegen/java/com/facebook/react/viewmanagers
|
23
|
+
|
24
|
+
# Path to directory with view managers' interfaces & delegates used while running on Paper architecture. This property is used as the output path for `copyCodegenArtifacts` task.
|
25
|
+
# Used by copyCodegenArtifacts task that automates copying those interfaces/delegates after codegen is run.
|
26
|
+
codegenArtifactsPaperDestination=android/paper/src/main/java/com/facebook/react/viewmanagers
|
@@ -1,11 +1,11 @@
|
|
1
1
|
/**
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
3
|
+
*
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
5
|
+
* once the code is regenerated.
|
6
|
+
*
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
8
|
+
*/
|
9
9
|
|
10
10
|
package com.facebook.react.viewmanagers;
|
11
11
|
|
@@ -83,11 +83,21 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
|
83
83
|
override fun onHandle(event: MotionEvent, sourceEvent: MotionEvent) {
|
84
84
|
val view = view!!
|
85
85
|
if (event.actionMasked == MotionEvent.ACTION_UP) {
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
if (state == STATE_UNDETERMINED && !hook.canBegin(event)) {
|
87
|
+
cancel()
|
88
|
+
} else {
|
89
|
+
view.onTouchEvent(event)
|
90
|
+
if ((state == STATE_UNDETERMINED || state == STATE_BEGAN) && view.isPressed) {
|
91
|
+
activate()
|
92
|
+
}
|
93
|
+
|
94
|
+
if (state == STATE_UNDETERMINED) {
|
95
|
+
cancel()
|
96
|
+
} else {
|
97
|
+
end()
|
98
|
+
}
|
89
99
|
}
|
90
|
-
|
100
|
+
|
91
101
|
hook.afterGestureEnd(event)
|
92
102
|
} else if (state == STATE_UNDETERMINED || state == STATE_BEGAN) {
|
93
103
|
when {
|
@@ -104,10 +114,8 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
|
104
114
|
hook.handleEventBeforeActivation(event)
|
105
115
|
}
|
106
116
|
state != STATE_BEGAN -> {
|
107
|
-
if (hook.canBegin()) {
|
117
|
+
if (hook.canBegin(event)) {
|
108
118
|
begin()
|
109
|
-
} else {
|
110
|
-
cancel()
|
111
119
|
}
|
112
120
|
}
|
113
121
|
}
|
@@ -144,7 +152,7 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
|
144
152
|
* @return Boolean value signalling whether the handler can transition to the BEGAN state. If false
|
145
153
|
* the gesture will be cancelled.
|
146
154
|
*/
|
147
|
-
fun canBegin() = true
|
155
|
+
fun canBegin(event: MotionEvent) = true
|
148
156
|
|
149
157
|
/**
|
150
158
|
* Called after the gesture transitions to the END state.
|
@@ -270,15 +270,15 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
270
270
|
* [com.swmansion.gesturehandler.NativeViewGestureHandler.onHandle] */
|
271
271
|
@SuppressLint("ClickableViewAccessibility")
|
272
272
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
273
|
+
val eventTime = event.eventTime
|
274
|
+
val action = event.action
|
275
|
+
|
273
276
|
if (event.action == MotionEvent.ACTION_CANCEL) {
|
274
277
|
tryFreeingResponder()
|
275
|
-
return super.onTouchEvent(event)
|
276
278
|
}
|
277
279
|
|
278
|
-
val eventTime = event.eventTime
|
279
|
-
val action = event.action
|
280
280
|
// always true when lastEventTime or lastAction have default value (-1)
|
281
|
-
if (lastEventTime != eventTime || lastAction != action) {
|
281
|
+
if (lastEventTime != eventTime || lastAction != action || action == MotionEvent.ACTION_CANCEL) {
|
282
282
|
lastEventTime = eventTime
|
283
283
|
lastAction = action
|
284
284
|
return super.onTouchEvent(event)
|
@@ -384,7 +384,11 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
384
384
|
}
|
385
385
|
}
|
386
386
|
|
387
|
-
override fun canBegin(): Boolean {
|
387
|
+
override fun canBegin(event: MotionEvent): Boolean {
|
388
|
+
if (event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_POINTER_UP) {
|
389
|
+
return false
|
390
|
+
}
|
391
|
+
|
388
392
|
val isResponder = tryGrabbingResponder()
|
389
393
|
if (isResponder) {
|
390
394
|
isTouched = true
|
@@ -54,6 +54,10 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
|
54
54
|
return otherHandler.disallowInterruption
|
55
55
|
}
|
56
56
|
|
57
|
+
if (otherHandler is RNGestureHandlerRootHelper.RootViewGestureHandler) {
|
58
|
+
return true
|
59
|
+
}
|
60
|
+
|
57
61
|
return false
|
58
62
|
}
|
59
63
|
override fun shouldRecognizeSimultaneously(
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt
CHANGED
@@ -57,7 +57,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
|
|
57
57
|
}
|
58
58
|
}
|
59
59
|
|
60
|
-
|
60
|
+
internal inner class RootViewGestureHandler : GestureHandler<RootViewGestureHandler>() {
|
61
61
|
override fun onHandle(event: MotionEvent, sourceEvent: MotionEvent) {
|
62
62
|
val currentState = state
|
63
63
|
// we shouldn't stop intercepting events when there is an active handler already, which could happen when
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt
CHANGED
@@ -49,6 +49,7 @@ class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerT
|
|
49
49
|
putInt("state", handler.state)
|
50
50
|
putInt("numberOfTouches", handler.trackedPointersCount)
|
51
51
|
putInt("eventType", handler.touchEventType)
|
52
|
+
putInt("pointerType", handler.pointerType)
|
52
53
|
|
53
54
|
handler.consumeChangedTouchesPayload()?.let {
|
54
55
|
putArray("changedTouches", it)
|
@@ -34,6 +34,16 @@ using namespace facebook::react;
|
|
34
34
|
return self;
|
35
35
|
}
|
36
36
|
|
37
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
38
|
+
{
|
39
|
+
[_buttonView mountChildComponentView:childComponentView index:index];
|
40
|
+
}
|
41
|
+
|
42
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
43
|
+
{
|
44
|
+
[_buttonView unmountChildComponentView:childComponentView index:index];
|
45
|
+
}
|
46
|
+
|
37
47
|
#pragma mark - RCTComponentViewProtocol
|
38
48
|
|
39
49
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
@@ -53,7 +53,6 @@ typedef void (^GestureHandlerOperation)(RNGestureHandlerManager *manager);
|
|
53
53
|
|
54
54
|
#ifdef RCT_NEW_ARCH_ENABLED
|
55
55
|
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
|
56
|
-
@synthesize bridge = _bridge;
|
57
56
|
@synthesize dispatchToJSThread = _dispatchToJSThread;
|
58
57
|
#endif // RCT_NEW_ARCH_ENABLED
|
59
58
|
|
@@ -133,14 +132,14 @@ void decorateRuntime(jsi::Runtime &runtime)
|
|
133
132
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
134
133
|
{
|
135
134
|
dispatch_block_t block = ^{
|
136
|
-
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)
|
135
|
+
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
|
137
136
|
auto runtime = (jsi::Runtime *)cxxBridge.runtime;
|
138
137
|
decorateRuntime(*runtime);
|
139
138
|
};
|
140
139
|
if (_dispatchToJSThread) {
|
141
140
|
_dispatchToJSThread(block);
|
142
141
|
} else {
|
143
|
-
[
|
142
|
+
[self.bridge dispatchBlock:block queue:RCTJSThread];
|
144
143
|
}
|
145
144
|
|
146
145
|
return @true;
|
@@ -37,7 +37,7 @@ const RawButton = (0, _createNativeWrapper.default)(_GestureHandlerButton.defaul
|
|
37
37
|
});
|
38
38
|
exports.RawButton = RawButton;
|
39
39
|
|
40
|
-
class
|
40
|
+
class InnerBaseButton extends React.Component {
|
41
41
|
constructor(props) {
|
42
42
|
super(props);
|
43
43
|
|
@@ -116,6 +116,7 @@ class BaseButton extends React.Component {
|
|
116
116
|
...rest
|
117
117
|
} = this.props;
|
118
118
|
return /*#__PURE__*/React.createElement(RawButton, _extends({
|
119
|
+
ref: this.props.innerRef,
|
119
120
|
rippleColor: (0, _reactNative.processColor)(rippleColor)
|
120
121
|
}, rest, {
|
121
122
|
onGestureEvent: this.onGestureEvent,
|
@@ -125,12 +126,15 @@ class BaseButton extends React.Component {
|
|
125
126
|
|
126
127
|
}
|
127
128
|
|
128
|
-
|
129
|
-
|
130
|
-
_defineProperty(BaseButton, "defaultProps", {
|
129
|
+
_defineProperty(InnerBaseButton, "defaultProps", {
|
131
130
|
delayLongPress: 600
|
132
131
|
});
|
133
132
|
|
133
|
+
const BaseButton = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(InnerBaseButton, _extends({
|
134
|
+
innerRef: ref
|
135
|
+
}, props)));
|
136
|
+
exports.BaseButton = BaseButton;
|
137
|
+
|
134
138
|
const AnimatedBaseButton = _reactNative.Animated.createAnimatedComponent(BaseButton);
|
135
139
|
|
136
140
|
const btnStyles = _reactNative.StyleSheet.create({
|
@@ -143,7 +147,7 @@ const btnStyles = _reactNative.StyleSheet.create({
|
|
143
147
|
}
|
144
148
|
});
|
145
149
|
|
146
|
-
class
|
150
|
+
class InnerRectButton extends React.Component {
|
147
151
|
constructor(props) {
|
148
152
|
super(props);
|
149
153
|
|
@@ -172,6 +176,7 @@ class RectButton extends React.Component {
|
|
172
176
|
const resolvedStyle = _reactNative.StyleSheet.flatten(style !== null && style !== void 0 ? style : {});
|
173
177
|
|
174
178
|
return /*#__PURE__*/React.createElement(BaseButton, _extends({}, rest, {
|
179
|
+
ref: this.props.innerRef,
|
175
180
|
style: resolvedStyle,
|
176
181
|
onActiveStateChange: this.onActiveStateChange
|
177
182
|
}), /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
|
@@ -189,14 +194,17 @@ class RectButton extends React.Component {
|
|
189
194
|
|
190
195
|
}
|
191
196
|
|
192
|
-
|
193
|
-
|
194
|
-
_defineProperty(RectButton, "defaultProps", {
|
197
|
+
_defineProperty(InnerRectButton, "defaultProps", {
|
195
198
|
activeOpacity: 0.105,
|
196
199
|
underlayColor: 'black'
|
197
200
|
});
|
198
201
|
|
199
|
-
|
202
|
+
const RectButton = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(InnerRectButton, _extends({
|
203
|
+
innerRef: ref
|
204
|
+
}, props)));
|
205
|
+
exports.RectButton = RectButton;
|
206
|
+
|
207
|
+
class InnerBorderlessButton extends React.Component {
|
200
208
|
constructor(props) {
|
201
209
|
super(props);
|
202
210
|
|
@@ -219,9 +227,13 @@ class BorderlessButton extends React.Component {
|
|
219
227
|
const {
|
220
228
|
children,
|
221
229
|
style,
|
230
|
+
innerRef,
|
222
231
|
...rest
|
223
232
|
} = this.props;
|
224
233
|
return /*#__PURE__*/React.createElement(AnimatedBaseButton, _extends({}, rest, {
|
234
|
+
// @ts-ignore We don't want `innerRef` to be accessible from public API.
|
235
|
+
// However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore
|
236
|
+
innerRef: innerRef,
|
225
237
|
onActiveStateChange: this.onActiveStateChange,
|
226
238
|
style: [style, _reactNative.Platform.OS === 'ios' && {
|
227
239
|
opacity: this.opacity
|
@@ -231,10 +243,13 @@ class BorderlessButton extends React.Component {
|
|
231
243
|
|
232
244
|
}
|
233
245
|
|
234
|
-
|
235
|
-
|
236
|
-
_defineProperty(BorderlessButton, "defaultProps", {
|
246
|
+
_defineProperty(InnerBorderlessButton, "defaultProps", {
|
237
247
|
activeOpacity: 0.3,
|
238
248
|
borderless: true
|
239
249
|
});
|
250
|
+
|
251
|
+
const BorderlessButton = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(InnerBorderlessButton, _extends({
|
252
|
+
innerRef: ref
|
253
|
+
}, props)));
|
254
|
+
exports.BorderlessButton = BorderlessButton;
|
240
255
|
//# sourceMappingURL=GestureButtons.js.map
|
@@ -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","longPressDetected","CANCELLED","onPress","Platform","OS","BEGAN","onLongPress","longPressTimeout","setTimeout","delayLongPress","undefined","clearTimeout","END","FAILED","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","RectButton","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","Border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,mBAAmB,EAAE,KAAKrB,mBAF5B;AAGE,MAAA,KAAK,EAAE,CAACwC,KAAD,EAAQpC,sBAASC,EAAT,KAAgB,KAAhB,IAAyB;AAAE8B,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 /**\n * Android only.\n *\n * Set this to true if you don't want the system to play sound when the button is pressed.\n */\n touchSoundDisabled?: 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 the button gets pressed and is held for `delayLongPress`\n * milliseconds.\n */\n onLongPress?: () => 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 /**\n * Delay, in milliseconds, after which the `onLongPress` callback gets called.\n * Defaults to 600.\n */\n delayLongPress?: number;\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 static defaultProps = {\n delayLongPress: 600,\n };\n\n private lastActive: boolean;\n private longPressTimeout: ReturnType<typeof setTimeout> | undefined;\n private longPressDetected: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n this.longPressDetected = 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 !this.longPressDetected &&\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n if (\n !this.lastActive &&\n // NativeViewGestureHandler sends different events based on platform\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n pointerInside\n ) {\n this.longPressDetected = false;\n if (this.props.onLongPress) {\n this.longPressTimeout = setTimeout(\n this.onLongPress,\n this.props.delayLongPress\n );\n }\n } else if (\n // cancel longpress timeout if it's set and the finger moved out of the view\n state === State.ACTIVE &&\n !pointerInside &&\n this.longPressTimeout !== undefined\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n } else if (\n // cancel longpress timeout if it's set and the gesture has finished\n this.longPressTimeout !== undefined &&\n (state === State.END ||\n state === State.CANCELLED ||\n state === State.FAILED)\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n }\n\n this.lastActive = active;\n };\n\n private onLongPress = () => {\n this.longPressDetected = true;\n this.props.onLongPress?.();\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","InnerBaseButton","React","Component","constructor","props","nativeEvent","state","oldState","pointerInside","active","State","ACTIVE","lastActive","onActiveStateChange","longPressDetected","CANCELLED","onPress","Platform","OS","BEGAN","onLongPress","longPressTimeout","setTimeout","delayLongPress","undefined","clearTimeout","END","FAILED","e","onHandlerStateChange","handleEvent","onGestureEvent","render","rippleColor","rest","innerRef","BaseButton","forwardRef","ref","AnimatedBaseButton","Animated","createAnimatedComponent","btnStyles","StyleSheet","create","underlay","position","left","right","bottom","top","InnerRectButton","opacity","setValue","activeOpacity","Value","children","style","resolvedStyle","flatten","backgroundColor","underlayColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","RectButton","InnerBorderlessButton","borderless","BorderlessButton"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AACA;;;;;;;;;;;;AAuHO,MAAMA,SAAS,GAAG,kCAAoBC,6BAApB,EAA0C;AACjEC,EAAAA,uBAAuB,EAAE,KADwC;AAEjEC,EAAAA,qBAAqB,EAAE;AAF0C,CAA1C,CAAlB;;;AAKP,MAAMC,eAAN,SAA8BC,KAAK,CAACC,SAApC,CAAsE;AASpEC,EAAAA,WAAW,CAACC,KAAD,EAAyB;AAClC,UAAMA,KAAN;;AADkC;;AAAA;;AAAA;;AAAA,yCAMd,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,UACE,CAAC,KAAKK,iBAAN,IACAP,QAAQ,KAAKG,aAAMC,MADnB,IAEAL,KAAK,KAAKI,aAAMK,SAFhB,IAGA,KAAKH,UAHL,IAIA,KAAKR,KAAL,CAAWY,OALb,EAME;AACA,aAAKZ,KAAL,CAAWY,OAAX,CAAmBP,MAAnB;AACD;;AAED,UACE,CAA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AQ,EAAEA;AAAjC,GAA0ClC,KAA1C,EAHc,CAAzB","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 /**\n * Android only.\n *\n * Set this to true if you don't want the system to play sound when the button is pressed.\n */\n touchSoundDisabled?: boolean;\n}\n\ninterface ButtonWithRefProps {\n innerRef?: React.ForwardedRef<React.ComponentType<any>>;\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 the button gets pressed and is held for `delayLongPress`\n * milliseconds.\n */\n onLongPress?: () => 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 /**\n * Delay, in milliseconds, after which the `onLongPress` callback gets called.\n * Defaults to 600.\n */\n delayLongPress?: number;\n}\n\ninterface BaseButtonWithRefProps extends BaseButtonProps, ButtonWithRefProps {}\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\ninterface RectButtonWithRefProps extends RectButtonProps, ButtonWithRefProps {}\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\ninterface BorderlessButtonWithRefProps\n extends BorderlessButtonProps,\n ButtonWithRefProps {}\n\nexport const RawButton = createNativeWrapper(GestureHandlerButton, {\n shouldCancelWhenOutside: false,\n shouldActivateOnStart: false,\n});\n\nclass InnerBaseButton extends React.Component<BaseButtonWithRefProps> {\n static defaultProps = {\n delayLongPress: 600,\n };\n\n private lastActive: boolean;\n private longPressTimeout: ReturnType<typeof setTimeout> | undefined;\n private longPressDetected: boolean;\n\n constructor(props: BaseButtonProps) {\n super(props);\n this.lastActive = false;\n this.longPressDetected = 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 !this.longPressDetected &&\n oldState === State.ACTIVE &&\n state !== State.CANCELLED &&\n this.lastActive &&\n this.props.onPress\n ) {\n this.props.onPress(active);\n }\n\n if (\n !this.lastActive &&\n // NativeViewGestureHandler sends different events based on platform\n state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&\n pointerInside\n ) {\n this.longPressDetected = false;\n if (this.props.onLongPress) {\n this.longPressTimeout = setTimeout(\n this.onLongPress,\n this.props.delayLongPress\n );\n }\n } else if (\n // cancel longpress timeout if it's set and the finger moved out of the view\n state === State.ACTIVE &&\n !pointerInside &&\n this.longPressTimeout !== undefined\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n } else if (\n // cancel longpress timeout if it's set and the gesture has finished\n this.longPressTimeout !== undefined &&\n (state === State.END ||\n state === State.CANCELLED ||\n state === State.FAILED)\n ) {\n clearTimeout(this.longPressTimeout);\n this.longPressTimeout = undefined;\n }\n\n this.lastActive = active;\n };\n\n private onLongPress = () => {\n this.longPressDetected = true;\n this.props.onLongPress?.();\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 ref={this.props.innerRef}\n rippleColor={processColor(rippleColor)}\n {...rest}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}\n />\n );\n }\n}\n\nexport const BaseButton = React.forwardRef<\n any,\n Omit<BaseButtonProps, 'innerRef'>\n>((props, ref) => <InnerBaseButton innerRef={ref} {...props} />);\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\nclass InnerRectButton extends React.Component<RectButtonWithRefProps> {\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 ref={this.props.innerRef}\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 const RectButton = React.forwardRef<\n any,\n Omit<RectButtonProps, 'innerRef'>\n>((props, ref) => <InnerRectButton innerRef={ref} {...props} />);\n\nclass InnerBorderlessButton extends React.Component<BorderlessButtonWithRefProps> {\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, innerRef, ...rest } = this.props;\n\n return (\n <AnimatedBaseButton\n {...rest}\n // @ts-ignore We don't want `innerRef` to be accessible from public API.\n // However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore\n innerRef={innerRef}\n onActiveStateChange={this.onActiveStateChange}\n style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>\n {children}\n </AnimatedBaseButton>\n );\n }\n}\n\nexport const BorderlessButton = React.forwardRef<\n any,\n Omit<BorderlessButtonProps, 'innerRef'>\n>((props, ref) => <InnerBorderlessButton innerRef={ref} {...props} />);\n\nexport { default as PureNativeButton } from './GestureHandlerButton';\n"]}
|
@@ -11,8 +11,6 @@ var _reactNative = require("react-native");
|
|
11
11
|
|
12
12
|
var _customDirectEventTypes = require("./customDirectEventTypes");
|
13
13
|
|
14
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
15
|
-
|
16
14
|
var _RNGestureHandlerModule = _interopRequireDefault(require("../RNGestureHandlerModule"));
|
17
15
|
|
18
16
|
var _State = require("../State");
|
@@ -363,7 +361,7 @@ function createHandler({
|
|
363
361
|
} else {
|
364
362
|
const newConfig = (0, _gestureHandlerCommon.filterConfig)(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
|
365
363
|
|
366
|
-
if (!(0,
|
364
|
+
if (!(0, _utils.deepEqual)(this.config, newConfig)) {
|
367
365
|
this.updateGestureHandler(newConfig);
|
368
366
|
}
|
369
367
|
}
|