react-native-gesture-handler 2.13.3 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +19 -25
- package/android/build.gradle +3 -2
- package/android/gradle.properties +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +36 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +13 -9
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +12 -14
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +8 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +34 -88
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +18 -12
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/FlingGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt +22 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/LongPressGestureHandlerEventDataBuilder.kt +33 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/ManualGestureHandlerEventDataBuilder.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/NativeGestureHandlerEventDataBuilder.kt +18 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +42 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PinchGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/RotationGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/TapGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/jni/CMakeLists.txt +14 -2
- package/ios/Handlers/RNHoverHandler.m +15 -14
- package/ios/RNGestureHandler.m +11 -0
- package/ios/RNGestureHandlerButtonComponentView.mm +2 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.js +22 -0
- package/lib/commonjs/getReactNativeVersion.js.map +1 -0
- package/lib/commonjs/getReactNativeVersion.web.js +11 -0
- package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +13 -3
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +8 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/utils.js +0 -13
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +4 -15
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/InteractionManager.js +27 -29
- package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +11 -3
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/getReactNativeVersion.js +10 -0
- package/lib/module/getReactNativeVersion.js.map +1 -0
- package/lib/module/getReactNativeVersion.web.js +4 -0
- package/lib/module/getReactNativeVersion.web.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +12 -3
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +8 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/utils.js +0 -6
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +4 -15
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/InteractionManager.js +27 -29
- package/lib/module/web/tools/InteractionManager.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +11 -3
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +1 -1
- package/lib/typescript/Directions.d.ts +1 -1
- package/lib/typescript/PlatformConstants.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/State.d.ts +1 -1
- package/lib/typescript/TouchEventType.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +9 -9
- package/lib/typescript/components/GestureButtons.d.ts +3 -3
- package/lib/typescript/components/GestureComponents.d.ts +6 -6
- package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +2 -1
- package/lib/typescript/components/Swipeable.d.ts +4 -4
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +4 -3
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +4 -3
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +7 -6
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +3 -2
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -1
- package/lib/typescript/getReactNativeVersion.d.ts +4 -0
- package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +3 -3
- package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/TapGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +11 -10
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +32 -32
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -2
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/gesture.d.ts +7 -5
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +4 -4
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +3 -3
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -1
- package/lib/typescript/jestUtils/jestUtils.d.ts +6 -6
- package/lib/typescript/typeUtils.d.ts +1 -1
- package/lib/typescript/utils.d.ts +1 -5
- package/lib/typescript/web/interfaces.d.ts +4 -3
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
- package/lib/typescript/web/tools/InteractionManager.d.ts +2 -1
- package/lib/typescript/web_hammer/GestureHandler.d.ts +2 -2
- package/package.json +7 -7
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -1
- package/src/getReactNativeVersion.ts +11 -0
- package/src/getReactNativeVersion.web.ts +3 -0
- package/src/handlers/gestureHandlerCommon.ts +6 -1
- package/src/handlers/gestures/GestureDetector.tsx +9 -6
- package/src/handlers/gestures/gesture.ts +9 -1
- package/src/utils.ts +0 -8
- package/src/web/handlers/GestureHandler.ts +1 -1
- package/src/web/interfaces.ts +1 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +4 -13
- package/src/web/tools/InteractionManager.ts +37 -30
- package/src/web/tools/PointerEventManager.ts +12 -3
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +0 -8
- /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +0 -0
- /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
package/RNGestureHandler.podspec
CHANGED
@@ -3,30 +3,6 @@ require "json"
|
|
3
3
|
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
4
4
|
apple_platform = new_arch_enabled ? '11.0' : '9.0'
|
5
5
|
|
6
|
-
# Utility function to install dependencies if React Native's
|
7
|
-
# install_modules_dependencies is not defined
|
8
|
-
def install_dependencies(s, new_arch_enabled)
|
9
|
-
if new_arch_enabled
|
10
|
-
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
11
|
-
|
12
|
-
s.pod_target_xcconfig = {
|
13
|
-
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
|
14
|
-
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
15
|
-
}
|
16
|
-
s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
|
17
|
-
|
18
|
-
s.dependency "React"
|
19
|
-
s.dependency "React-RCTFabric" # This is for fabric component
|
20
|
-
s.dependency "React-Codegen"
|
21
|
-
s.dependency "RCT-Folly"
|
22
|
-
s.dependency "RCTRequired"
|
23
|
-
s.dependency "RCTTypeSafety"
|
24
|
-
s.dependency "ReactCommon/turbomodule/core"
|
25
|
-
else
|
26
|
-
s.dependency "React-Core"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
6
|
Pod::Spec.new do |s|
|
31
7
|
# NPM package specification
|
32
8
|
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), "package.json")))
|
@@ -45,6 +21,24 @@ Pod::Spec.new do |s|
|
|
45
21
|
if defined?(install_modules_dependencies()) != nil
|
46
22
|
install_modules_dependencies(s);
|
47
23
|
else
|
48
|
-
|
24
|
+
if new_arch_enabled
|
25
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
26
|
+
|
27
|
+
s.pod_target_xcconfig = {
|
28
|
+
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
|
29
|
+
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
30
|
+
}
|
31
|
+
s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
|
32
|
+
|
33
|
+
s.dependency "React"
|
34
|
+
s.dependency "React-RCTFabric" # This is for fabric component
|
35
|
+
s.dependency "React-Codegen"
|
36
|
+
s.dependency "RCT-Folly"
|
37
|
+
s.dependency "RCTRequired"
|
38
|
+
s.dependency "RCTTypeSafety"
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
40
|
+
else
|
41
|
+
s.dependency "React-Core"
|
42
|
+
end
|
49
43
|
end
|
50
44
|
end
|
package/android/build.gradle
CHANGED
@@ -139,6 +139,7 @@ android {
|
|
139
139
|
cppFlags "-O2", "-frtti", "-fexceptions", "-Wall", "-Werror", "-std=c++17", "-DANDROID"
|
140
140
|
arguments "-DAPP_BUILD_DIR=${appProject.buildDir}",
|
141
141
|
"-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
|
142
|
+
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
|
142
143
|
"-DANDROID_STL=c++_shared"
|
143
144
|
abiFilters (*reactNativeArchitectures())
|
144
145
|
}
|
@@ -179,11 +180,11 @@ android {
|
|
179
180
|
}
|
180
181
|
|
181
182
|
if (isNewArchitectureEnabled()) {
|
182
|
-
srcDirs += 'src/
|
183
|
+
srcDirs += 'fabric/src/main/java'
|
183
184
|
} else {
|
184
185
|
// this folder also includes files from codegen so the library can compile with
|
185
186
|
// codegen turned off
|
186
|
-
srcDirs += 'src/
|
187
|
+
srcDirs += 'paper/src/main/java'
|
187
188
|
}
|
188
189
|
}
|
189
190
|
}
|
@@ -9,8 +9,8 @@
|
|
9
9
|
|
10
10
|
# Specifies the JVM arguments used for the daemon process.
|
11
11
|
# The setting is particularly useful for tweaking memory settings.
|
12
|
-
# Default value: -Xmx10248m -XX:
|
13
|
-
org.gradle.jvmargs=-Xmx2048m -XX:
|
12
|
+
# Default value: -Xmx10248m -XX:MaxMetaspaceSize=256m
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
14
14
|
|
15
15
|
# When configured, Gradle will run in incubating parallel mode.
|
16
16
|
# This option should only be used with decoupled projects. More details, visit
|
package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
CHANGED
@@ -19,13 +19,9 @@ class GestureHandlerOrchestrator(
|
|
19
19
|
* traversing view hierarchy and looking for gesture handlers.
|
20
20
|
*/
|
21
21
|
var minimumAlphaForTraversal = DEFAULT_MIN_ALPHA_FOR_TRAVERSAL
|
22
|
-
|
23
|
-
private val
|
24
|
-
private val
|
25
|
-
private val preparedHandlers = arrayOfNulls<GestureHandler<*>?>(SIMULTANEOUS_GESTURE_HANDLER_LIMIT)
|
26
|
-
private val handlersToCancel = arrayOfNulls<GestureHandler<*>?>(SIMULTANEOUS_GESTURE_HANDLER_LIMIT)
|
27
|
-
private var gestureHandlersCount = 0
|
28
|
-
private var awaitingHandlersCount = 0
|
22
|
+
private val gestureHandlers = arrayListOf<GestureHandler<*>>()
|
23
|
+
private val awaitingHandlers = arrayListOf<GestureHandler<*>>()
|
24
|
+
private val preparedHandlers = arrayListOf<GestureHandler<*>>()
|
29
25
|
private var isHandlingTouch = false
|
30
26
|
private var handlingChangeSemaphore = 0
|
31
27
|
private var finishedHandlersCleanupScheduled = false
|
@@ -60,23 +56,9 @@ class GestureHandlerOrchestrator(
|
|
60
56
|
}
|
61
57
|
}
|
62
58
|
|
63
|
-
private inline fun compactHandlersIf(handlers: Array<GestureHandler<*>?>, count: Int, predicate: (handler: GestureHandler<*>?) -> Boolean): Int {
|
64
|
-
var out = 0
|
65
|
-
for (i in 0 until count) {
|
66
|
-
if (predicate(handlers[i])) {
|
67
|
-
handlers[out++] = handlers[i]
|
68
|
-
}
|
69
|
-
}
|
70
|
-
return out
|
71
|
-
}
|
72
|
-
|
73
59
|
private fun cleanupFinishedHandlers() {
|
74
|
-
|
75
|
-
for (i in gestureHandlersCount - 1 downTo 0) {
|
76
|
-
val handler = gestureHandlers[i]!!
|
60
|
+
for (handler in gestureHandlers.asReversed()) {
|
77
61
|
if (isFinished(handler.state) && !handler.isAwaiting) {
|
78
|
-
gestureHandlers[i] = null
|
79
|
-
shouldCleanEmptyCells = true
|
80
62
|
handler.reset()
|
81
63
|
handler.apply {
|
82
64
|
isActive = false
|
@@ -85,17 +67,14 @@ class GestureHandlerOrchestrator(
|
|
85
67
|
}
|
86
68
|
}
|
87
69
|
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
}
|
70
|
+
|
71
|
+
gestureHandlers.removeAll { isFinished(it.state) && !it.isAwaiting }
|
72
|
+
|
93
73
|
finishedHandlersCleanupScheduled = false
|
94
74
|
}
|
95
75
|
|
96
76
|
private fun hasOtherHandlerToWaitFor(handler: GestureHandler<*>): Boolean {
|
97
|
-
for (
|
98
|
-
val otherHandler = gestureHandlers[i]!!
|
77
|
+
for (otherHandler in gestureHandlers) {
|
99
78
|
if (!isFinished(otherHandler.state) && shouldHandlerWaitForOther(handler, otherHandler)) {
|
100
79
|
return true
|
101
80
|
}
|
@@ -115,9 +94,7 @@ class GestureHandlerOrchestrator(
|
|
115
94
|
}
|
116
95
|
|
117
96
|
private fun cleanupAwaitingHandlers() {
|
118
|
-
|
119
|
-
handler!!.isAwaiting
|
120
|
-
}
|
97
|
+
awaitingHandlers.removeAll { !it.isAwaiting }
|
121
98
|
}
|
122
99
|
|
123
100
|
/*package*/
|
@@ -125,9 +102,8 @@ class GestureHandlerOrchestrator(
|
|
125
102
|
handlingChangeSemaphore += 1
|
126
103
|
if (isFinished(newState)) {
|
127
104
|
// if there were handlers awaiting completion of this handler, we can trigger active state
|
128
|
-
for (
|
129
|
-
|
130
|
-
if (shouldHandlerWaitForOther(otherHandler!!, handler)) {
|
105
|
+
for (otherHandler in awaitingHandlers) {
|
106
|
+
if (shouldHandlerWaitForOther(otherHandler, handler)) {
|
131
107
|
if (newState == GestureHandler.STATE_END) {
|
132
108
|
// gesture has ended, we need to kill the awaiting handler
|
133
109
|
otherHandler.cancel()
|
@@ -182,21 +158,15 @@ class GestureHandlerOrchestrator(
|
|
182
158
|
shouldResetProgress = true
|
183
159
|
activationIndex = this@GestureHandlerOrchestrator.activationIndex++
|
184
160
|
}
|
185
|
-
|
186
|
-
|
187
|
-
for (i in 0 until gestureHandlersCount) {
|
188
|
-
val otherHandler = gestureHandlers[i]!!
|
161
|
+
|
162
|
+
for (otherHandler in gestureHandlers.asReversed()) {
|
189
163
|
if (shouldHandlerBeCancelledBy(otherHandler, handler)) {
|
190
|
-
|
164
|
+
otherHandler.cancel()
|
191
165
|
}
|
192
166
|
}
|
193
|
-
for (i in toCancelCount - 1 downTo 0) {
|
194
|
-
handlersToCancel[i]!!.cancel()
|
195
|
-
}
|
196
167
|
|
197
168
|
// Clear all awaiting handlers waiting for the current handler to fail
|
198
|
-
for (
|
199
|
-
val otherHandler = awaitingHandlers[i]!!
|
169
|
+
for (otherHandler in awaitingHandlers.reversed()) {
|
200
170
|
if (shouldHandlerBeCancelledBy(otherHandler, handler)) {
|
201
171
|
otherHandler.cancel()
|
202
172
|
otherHandler.isAwaiting = false
|
@@ -218,32 +188,31 @@ class GestureHandlerOrchestrator(
|
|
218
188
|
private fun deliverEventToGestureHandlers(event: MotionEvent) {
|
219
189
|
// Copy handlers to "prepared handlers" array, because the list of active handlers can change
|
220
190
|
// as a result of state updates
|
221
|
-
|
191
|
+
preparedHandlers.clear()
|
192
|
+
preparedHandlers.addAll(gestureHandlers)
|
222
193
|
|
223
|
-
gestureHandlers.copyInto(preparedHandlers, 0, 0, handlersCount)
|
224
194
|
// We want to deliver events to active handlers first in order of their activation (handlers
|
225
195
|
// that activated first will first get event delivered). Otherwise we deliver events in the
|
226
196
|
// order in which handlers has been added ("most direct" children goes first). Therefore we rely
|
227
197
|
// on Arrays.sort providing a stable sort (as children are registered in order in which they
|
228
198
|
// should be tested)
|
229
|
-
preparedHandlers.sortWith(handlersComparator
|
230
|
-
for (
|
231
|
-
deliverEventToGestureHandler(
|
199
|
+
preparedHandlers.sortWith(handlersComparator)
|
200
|
+
for (handler in preparedHandlers) {
|
201
|
+
deliverEventToGestureHandler(handler, event)
|
232
202
|
}
|
233
203
|
}
|
234
204
|
|
235
205
|
private fun cancelAll() {
|
236
|
-
for (
|
237
|
-
|
206
|
+
for (handler in awaitingHandlers.reversed()) {
|
207
|
+
handler.cancel()
|
238
208
|
}
|
239
209
|
// Copy handlers to "prepared handlers" array, because the list of active handlers can change
|
240
210
|
// as a result of state updates
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
preparedHandlers[i]!!.cancel()
|
211
|
+
preparedHandlers.clear()
|
212
|
+
preparedHandlers.addAll(gestureHandlers)
|
213
|
+
|
214
|
+
for (handler in gestureHandlers.reversed()) {
|
215
|
+
handler.cancel()
|
247
216
|
}
|
248
217
|
}
|
249
218
|
|
@@ -325,7 +294,7 @@ class GestureHandlerOrchestrator(
|
|
325
294
|
return parent === wrapperView
|
326
295
|
}
|
327
296
|
|
328
|
-
fun isAnyHandlerActive() = gestureHandlers.any { it
|
297
|
+
fun isAnyHandlerActive() = gestureHandlers.any { it.state == GestureHandler.STATE_ACTIVE }
|
329
298
|
|
330
299
|
/**
|
331
300
|
* Transforms an event in the coordinates of wrapperView into the coordinate space of the received view.
|
@@ -399,13 +368,11 @@ class GestureHandlerOrchestrator(
|
|
399
368
|
}
|
400
369
|
|
401
370
|
private fun addAwaitingHandler(handler: GestureHandler<*>) {
|
402
|
-
|
403
|
-
|
404
|
-
return
|
405
|
-
}
|
371
|
+
if (awaitingHandlers.contains(handler)) {
|
372
|
+
return
|
406
373
|
}
|
407
|
-
|
408
|
-
awaitingHandlers
|
374
|
+
|
375
|
+
awaitingHandlers.add(handler)
|
409
376
|
with(handler) {
|
410
377
|
isAwaiting = true
|
411
378
|
activationIndex = this@GestureHandlerOrchestrator.activationIndex++
|
@@ -413,13 +380,11 @@ class GestureHandlerOrchestrator(
|
|
413
380
|
}
|
414
381
|
|
415
382
|
private fun recordHandlerIfNotPresent(handler: GestureHandler<*>, view: View) {
|
416
|
-
|
417
|
-
|
418
|
-
return
|
419
|
-
}
|
383
|
+
if (gestureHandlers.contains(handler)) {
|
384
|
+
return
|
420
385
|
}
|
421
|
-
|
422
|
-
gestureHandlers
|
386
|
+
|
387
|
+
gestureHandlers.add(handler)
|
423
388
|
handler.isActive = false
|
424
389
|
handler.isAwaiting = false
|
425
390
|
handler.activationIndex = Int.MAX_VALUE
|
@@ -608,7 +573,6 @@ class GestureHandlerOrchestrator(
|
|
608
573
|
companion object {
|
609
574
|
// The limit doesn't necessarily need to exists, it was just simpler to implement it that way
|
610
575
|
// it is also more allocation-wise efficient to have a fixed limit
|
611
|
-
private const val SIMULTANEOUS_GESTURE_HANDLER_LIMIT = 20
|
612
576
|
|
613
577
|
// Be default fully transparent views can receive touch
|
614
578
|
private const val DEFAULT_MIN_ALPHA_FOR_TRAVERSAL = 0f
|
@@ -13,4 +13,4 @@ val ReactContext.UIManager: UIManagerModule
|
|
13
13
|
get() = this.getNativeModule(UIManagerModule::class.java)!!
|
14
14
|
|
15
15
|
fun Context.isScreenReaderOn() =
|
16
|
-
(getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager).
|
16
|
+
(getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager).isTouchExplorationEnabled
|
@@ -188,6 +188,17 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
188
188
|
return false
|
189
189
|
}
|
190
190
|
|
191
|
+
private fun updateBackgroundColor(backgroundColor: Int, borderRadius: Float, selectable: Drawable?) {
|
192
|
+
val colorDrawable = PaintDrawable(backgroundColor)
|
193
|
+
|
194
|
+
if (borderRadius != 0f) {
|
195
|
+
colorDrawable.setCornerRadius(borderRadius)
|
196
|
+
}
|
197
|
+
|
198
|
+
val layerDrawable = LayerDrawable(if (selectable != null) arrayOf(colorDrawable, selectable) else arrayOf(colorDrawable))
|
199
|
+
background = layerDrawable
|
200
|
+
}
|
201
|
+
|
191
202
|
fun updateBackground() {
|
192
203
|
if (!needBackgroundUpdate) {
|
193
204
|
return
|
@@ -223,19 +234,12 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
223
234
|
if (useDrawableOnForeground && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
224
235
|
foreground = selectable
|
225
236
|
if (_backgroundColor != Color.TRANSPARENT) {
|
226
|
-
|
237
|
+
updateBackgroundColor(_backgroundColor, borderRadius, null)
|
227
238
|
}
|
228
239
|
} else if (_backgroundColor == Color.TRANSPARENT && rippleColor == null) {
|
229
240
|
background = selectable
|
230
241
|
} else {
|
231
|
-
|
232
|
-
|
233
|
-
if (borderRadius != 0f) {
|
234
|
-
colorDrawable.setCornerRadius(borderRadius)
|
235
|
-
}
|
236
|
-
|
237
|
-
val layerDrawable = LayerDrawable(if (selectable != null) arrayOf(colorDrawable, selectable) else arrayOf(colorDrawable))
|
238
|
-
background = layerDrawable
|
242
|
+
updateBackgroundColor(_backgroundColor, borderRadius, selectable)
|
239
243
|
}
|
240
244
|
}
|
241
245
|
|
@@ -12,9 +12,10 @@ import com.facebook.react.bridge.WritableMap
|
|
12
12
|
import com.facebook.react.uimanager.events.Event
|
13
13
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
14
14
|
import com.swmansion.gesturehandler.core.GestureHandler
|
15
|
+
import com.swmansion.gesturehandler.react.eventbuilders.GestureHandlerEventDataBuilder
|
15
16
|
|
16
17
|
class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>() {
|
17
|
-
private var
|
18
|
+
private var dataBuilder: GestureHandlerEventDataBuilder<*>? = null
|
18
19
|
private var coalescingKey: Short = 0
|
19
20
|
|
20
21
|
// On the new architecture, native animated expects event names prefixed with `top` instead of `on`,
|
@@ -26,17 +27,17 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
|
|
26
27
|
|
27
28
|
private fun <T : GestureHandler<T>> init(
|
28
29
|
handler: T,
|
29
|
-
|
30
|
+
dataBuilder: GestureHandlerEventDataBuilder<T>,
|
30
31
|
useNativeAnimatedName: Boolean
|
31
32
|
) {
|
32
33
|
super.init(handler.view!!.id)
|
33
|
-
|
34
|
-
coalescingKey = handler.eventCoalescingKey
|
34
|
+
this.dataBuilder = dataBuilder
|
35
35
|
this.useTopPrefixedName = useNativeAnimatedName
|
36
|
+
coalescingKey = handler.eventCoalescingKey
|
36
37
|
}
|
37
38
|
|
38
39
|
override fun onDispose() {
|
39
|
-
|
40
|
+
dataBuilder = null
|
40
41
|
EVENTS_POOL.release(this)
|
41
42
|
}
|
42
43
|
|
@@ -47,7 +48,7 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
|
|
47
48
|
override fun getCoalescingKey() = coalescingKey
|
48
49
|
|
49
50
|
override fun dispatch(rctEventEmitter: RCTEventEmitter) {
|
50
|
-
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME,
|
51
|
+
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, createEventData(dataBuilder!!))
|
51
52
|
}
|
52
53
|
|
53
54
|
companion object {
|
@@ -58,20 +59,17 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
|
|
58
59
|
|
59
60
|
fun <T : GestureHandler<T>> obtain(
|
60
61
|
handler: T,
|
61
|
-
|
62
|
+
dataBuilder: GestureHandlerEventDataBuilder<T>,
|
62
63
|
useTopPrefixedName: Boolean = false
|
63
64
|
): RNGestureHandlerEvent =
|
64
65
|
(EVENTS_POOL.acquire() ?: RNGestureHandlerEvent()).apply {
|
65
|
-
init(handler,
|
66
|
+
init(handler, dataBuilder, useTopPrefixedName)
|
66
67
|
}
|
67
68
|
|
68
|
-
fun
|
69
|
-
|
70
|
-
dataExtractor: RNGestureHandlerEventDataExtractor<T>?
|
69
|
+
fun createEventData(
|
70
|
+
dataBuilder: GestureHandlerEventDataBuilder<*>
|
71
71
|
): WritableMap = Arguments.createMap().apply {
|
72
|
-
|
73
|
-
putInt("handlerTag", handler.tag)
|
74
|
-
putInt("state", handler.state)
|
72
|
+
dataBuilder.buildEventData(this)
|
75
73
|
}
|
76
74
|
}
|
77
75
|
}
|
@@ -9,6 +9,8 @@ import com.swmansion.gesturehandler.core.NativeViewGestureHandler
|
|
9
9
|
class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
10
10
|
private val waitForRelations = SparseArray<IntArray>()
|
11
11
|
private val simultaneousRelations = SparseArray<IntArray>()
|
12
|
+
private val blockingRelations = SparseArray<IntArray>()
|
13
|
+
|
12
14
|
fun dropRelationsForHandlerWithTag(handlerTag: Int) {
|
13
15
|
waitForRelations.remove(handlerTag)
|
14
16
|
simultaneousRelations.remove(handlerTag)
|
@@ -33,6 +35,10 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
|
33
35
|
val tags = convertHandlerTagsArray(config, KEY_SIMULTANEOUS_HANDLERS)
|
34
36
|
simultaneousRelations.put(handler.tag, tags)
|
35
37
|
}
|
38
|
+
if (config.hasKey(KEY_BLOCKS_HANDLERS)) {
|
39
|
+
val tags = convertHandlerTagsArray(config, KEY_BLOCKS_HANDLERS)
|
40
|
+
blockingRelations.put(handler.tag, tags)
|
41
|
+
}
|
36
42
|
}
|
37
43
|
|
38
44
|
override fun shouldWaitForHandlerFailure(handler: GestureHandler<*>, otherHandler: GestureHandler<*>) =
|
@@ -41,7 +47,7 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
|
41
47
|
override fun shouldRequireHandlerToWaitForFailure(
|
42
48
|
handler: GestureHandler<*>,
|
43
49
|
otherHandler: GestureHandler<*>,
|
44
|
-
) = false
|
50
|
+
) = blockingRelations[handler.tag]?.any { tag -> tag == otherHandler.tag } ?: false
|
45
51
|
|
46
52
|
override fun shouldHandlerBeCancelledBy(handler: GestureHandler<*>, otherHandler: GestureHandler<*>): Boolean {
|
47
53
|
if (otherHandler is NativeViewGestureHandler) {
|
@@ -63,5 +69,6 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
|
|
63
69
|
companion object {
|
64
70
|
private const val KEY_WAIT_FOR = "waitFor"
|
65
71
|
private const val KEY_SIMULTANEOUS_HANDLERS = "simultaneousHandlers"
|
72
|
+
private const val KEY_BLOCKS_HANDLERS = "blocksHandlers"
|
66
73
|
}
|
67
74
|
}
|