react-native-gesture-handler 2.9.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/RNGestureHandler.podspec +1 -1
- package/android/build.gradle +69 -29
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +39 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +8 -2
- package/ios/Handlers/RNNativeViewHandler.mm +4 -4
- package/ios/RNGestureHandlerButtonComponentView.h +2 -2
- package/ios/RNGestureHandlerButtonComponentView.mm +2 -2
- package/ios/RNGestureHandlerManager.mm +65 -16
- package/ios/RNGestureHandlerModule.mm +20 -16
- package/ios/RNGestureHandlerRootViewComponentView.mm +2 -2
- package/ios/RNRootViewGestureRecognizer.m +3 -3
- package/lib/commonjs/EnableNewWebImplementation.js +35 -0
- package/lib/commonjs/EnableNewWebImplementation.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootViewContext.js +15 -0
- package/lib/commonjs/GestureHandlerRootViewContext.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.macos.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.windows.js +6 -6
- package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.web.js +6 -5
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +3 -5
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/{GestureHandlerRootView.android.js → components/GestureHandlerRootView.android.js} +8 -7
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +8 -2
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/{GestureHandlerRootView.web.js → components/GestureHandlerRootView.web.js} +7 -1
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +17 -3
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/{gestureHandlerRootHOC.js.map → components/gestureHandlerRootHOC.js.map} +1 -1
- package/lib/commonjs/handlers/createHandler.js +21 -13
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -4
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +19 -9
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +22 -19
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/index.js +16 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils.js +0 -6
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +3 -0
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -12
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -5
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -6
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/CircularBuffer.js +59 -0
- package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -0
- package/lib/commonjs/web/tools/LeastSquareSolver.js +204 -0
- package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -0
- package/lib/commonjs/web/tools/PointerEventManager.js +27 -0
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +11 -7
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/VelocityTracker.js +111 -0
- package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -0
- package/lib/commonjs/web_hammer/GestureHandler.js +1 -1
- package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
- package/lib/module/EnableNewWebImplementation.js +22 -0
- package/lib/module/EnableNewWebImplementation.js.map +1 -0
- package/lib/module/GestureHandlerRootViewContext.js +3 -0
- package/lib/module/GestureHandlerRootViewContext.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.macos.js +6 -6
- package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +6 -6
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.windows.js +6 -6
- package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/module/components/GestureComponents.web.js +5 -6
- package/lib/module/components/GestureComponents.web.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +1 -4
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.android.js +14 -0
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +5 -2
- package/lib/module/components/GestureHandlerRootView.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.web.js +9 -0
- package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +17 -3
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/{gestureHandlerRootHOC.js.map → components/gestureHandlerRootHOC.js.map} +1 -1
- package/lib/module/handlers/createHandler.js +20 -13
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +5 -4
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +18 -10
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -16
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/index.js +4 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils.js +0 -4
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +0 -5
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +3 -0
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +0 -5
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -6
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +2 -9
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +0 -5
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +0 -6
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +0 -6
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/CircularBuffer.js +50 -0
- package/lib/module/web/tools/CircularBuffer.js.map +1 -0
- package/lib/module/web/tools/LeastSquareSolver.js +195 -0
- package/lib/module/web/tools/LeastSquareSolver.js.map +1 -0
- package/lib/module/web/tools/PointerEventManager.js +27 -0
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +8 -7
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/VelocityTracker.js +98 -0
- package/lib/module/web/tools/VelocityTracker.js.map +1 -0
- package/lib/module/web_hammer/GestureHandler.js +1 -1
- package/lib/module/web_hammer/GestureHandler.js.map +1 -1
- package/lib/typescript/EnableNewWebImplementation.d.ts +3 -0
- package/lib/typescript/GestureHandlerRootViewContext.d.ts +3 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
- package/lib/typescript/components/Swipeable.d.ts +12 -1
- package/lib/typescript/{gestureHandlerRootHOC.d.ts → components/gestureHandlerRootHOC.d.ts} +1 -1
- package/lib/typescript/index.d.ts +4 -4
- package/lib/typescript/utils.d.ts +0 -1
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -1
- package/lib/typescript/web/tools/CircularBuffer.d.ts +11 -0
- package/lib/typescript/web/tools/LeastSquareSolver.d.ts +12 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
- package/lib/typescript/web/tools/VelocityTracker.d.ts +13 -0
- package/package.json +3 -3
- package/src/EnableNewWebImplementation.ts +35 -0
- package/src/GestureHandlerRootViewContext.ts +3 -0
- package/src/RNGestureHandlerModule.macos.ts +6 -6
- package/src/RNGestureHandlerModule.web.ts +6 -6
- package/src/RNGestureHandlerModule.windows.ts +6 -6
- package/src/components/GestureComponents.web.tsx +5 -6
- package/src/components/GestureHandlerButton.tsx +2 -7
- package/src/components/GestureHandlerRootView.android.tsx +24 -0
- package/src/{GestureHandlerRootView.tsx → components/GestureHandlerRootView.tsx} +7 -2
- package/src/{GestureHandlerRootView.web.tsx → components/GestureHandlerRootView.web.tsx} +6 -1
- package/src/components/Swipeable.tsx +30 -4
- package/src/{gestureHandlerRootHOC.tsx → components/gestureHandlerRootHOC.tsx} +1 -1
- package/src/handlers/createHandler.tsx +20 -9
- package/src/handlers/gestureHandlerCommon.ts +5 -6
- package/src/handlers/gestures/GestureDetector.tsx +19 -9
- package/src/handlers/gestures/reanimatedWrapper.ts +21 -20
- package/src/index.ts +7 -3
- package/src/utils.ts +0 -5
- package/src/web/handlers/FlingGestureHandler.ts +0 -5
- package/src/web/handlers/GestureHandler.ts +3 -0
- package/src/web/handlers/ManualGestureHandler.ts +0 -5
- package/src/web/handlers/NativeViewGestureHandler.ts +0 -6
- package/src/web/handlers/PanGestureHandler.ts +2 -9
- package/src/web/handlers/PinchGestureHandler.ts +0 -5
- package/src/web/handlers/RotationGestureHandler.ts +0 -7
- package/src/web/handlers/TapGestureHandler.ts +0 -6
- package/src/web/tools/CircularBuffer.ts +42 -0
- package/src/web/tools/LeastSquareSolver.ts +182 -0
- package/src/web/tools/PointerEventManager.ts +29 -0
- package/src/web/tools/PointerTracker.ts +7 -7
- package/src/web/tools/VelocityTracker.ts +98 -0
- package/src/web_hammer/GestureHandler.ts +1 -1
- package/lib/commonjs/EnableExperimentalWebImplementation.js +0 -31
- package/lib/commonjs/EnableExperimentalWebImplementation.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.android.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.js.map +0 -1
- package/lib/commonjs/GestureHandlerRootView.web.js.map +0 -1
- package/lib/module/EnableExperimentalWebImplementation.js +0 -20
- package/lib/module/EnableExperimentalWebImplementation.js.map +0 -1
- package/lib/module/GestureHandlerRootView.android.js +0 -14
- package/lib/module/GestureHandlerRootView.android.js.map +0 -1
- package/lib/module/GestureHandlerRootView.js.map +0 -1
- package/lib/module/GestureHandlerRootView.web.js +0 -6
- package/lib/module/GestureHandlerRootView.web.js.map +0 -1
- package/lib/typescript/EnableExperimentalWebImplementation.d.ts +0 -2
- package/src/EnableExperimentalWebImplementation.ts +0 -27
- package/src/GestureHandlerRootView.android.tsx +0 -24
- /package/lib/commonjs/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
- /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
- /package/lib/module/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
- /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
- /package/lib/typescript/{GestureHandlerRootView.android.d.ts → components/GestureHandlerRootView.android.d.ts} +0 -0
- /package/lib/typescript/{GestureHandlerRootView.d.ts → components/GestureHandlerRootView.d.ts} +0 -0
- /package/lib/typescript/{GestureHandlerRootView.web.d.ts → components/GestureHandlerRootView.web.d.ts} +0 -0
- /package/lib/typescript/{fabric → specs}/RNGestureHandlerButtonNativeComponent.d.ts +0 -0
- /package/lib/typescript/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.d.ts +0 -0
- /package/src/{fabric → specs}/RNGestureHandlerButtonNativeComponent.ts +0 -0
- /package/src/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.ts +0 -0
package/README.md
CHANGED
package/RNGestureHandler.podspec
CHANGED
@@ -39,7 +39,7 @@ Pod::Spec.new do |s|
|
|
39
39
|
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
40
40
|
}
|
41
41
|
s.platforms = { ios: '11.0', tvos: '11.0' }
|
42
|
-
s.compiler_flags = folly_compiler_flags + ' -
|
42
|
+
s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
|
43
43
|
|
44
44
|
s.dependency "React"
|
45
45
|
s.dependency "React-RCTFabric" # This is for fabric component
|
package/android/build.gradle
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import groovy.json.JsonSlurper
|
2
|
-
|
2
|
+
|
3
|
+
import javax.inject.Inject
|
4
|
+
import java.nio.file.Files
|
3
5
|
|
4
6
|
buildscript {
|
5
7
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNGH_kotlinVersion']
|
@@ -66,6 +68,14 @@ if (project == rootProject) {
|
|
66
68
|
apply from: "spotless.gradle"
|
67
69
|
}
|
68
70
|
|
71
|
+
def shouldAssertNoMultipleInstances() {
|
72
|
+
if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
|
73
|
+
return rootProject.property("disableMultipleInstancesCheck") != "true"
|
74
|
+
} else {
|
75
|
+
return true
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
69
79
|
// Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
|
70
80
|
def shouldUseCommonInterfaceFromReanimated() {
|
71
81
|
def reanimated = rootProject.subprojects.find { it.name == 'react-native-reanimated' }
|
@@ -85,28 +95,6 @@ def reactNativeArchitectures() {
|
|
85
95
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
86
96
|
}
|
87
97
|
|
88
|
-
def shouldAssertNoMultipleInstances() {
|
89
|
-
if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
|
90
|
-
return rootProject.property("disableMultipleInstancesCheck") != "true"
|
91
|
-
} else {
|
92
|
-
return true
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
def noMultipleInstancesAssertion() {
|
97
|
-
Set<File> files = fileTree(rootDir.parent) {
|
98
|
-
include "node_modules/**/react-native-gesture-handler/package.json"
|
99
|
-
exclude "**/.yarn/**"
|
100
|
-
exclude "**/.pnpm/**"
|
101
|
-
}.files
|
102
|
-
|
103
|
-
if (files.size() > 1) {
|
104
|
-
String parsedLocation = files.stream().map({ File file -> "- " + file.toString().replace("/package.json", "") }).collect().join("\n")
|
105
|
-
String exceptionMessage = "\n[Gesture Handler] Multiple instances of Gesture Handler were detected. Only one instance of react-native-gesture-handler can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-gesture-handler/docs/troubleshooting#multiple-instances-of-gesture-handler-were-detected \n\nConflict between: \n" + parsedLocation + "\n";
|
106
|
-
throw new Exception(exceptionMessage);
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
98
|
def REACT_NATIVE_DIR = resolveReactNativeDirectory()
|
111
99
|
|
112
100
|
def reactProperties = new Properties()
|
@@ -115,23 +103,75 @@ file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { react
|
|
115
103
|
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
116
104
|
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
117
105
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
106
|
+
|
107
|
+
abstract class NoMultipleInstancesAssertionTask extends DefaultTask {
|
108
|
+
@Inject abstract ObjectFactory getObjectFactory()
|
109
|
+
|
110
|
+
@Input abstract Property<File> getProjectDirFile()
|
111
|
+
@Input abstract Property<File> getRootDirFile()
|
112
|
+
@Input abstract Property<Boolean> getShouldCheck()
|
113
|
+
|
114
|
+
def findGestureHandlerInstancesForPath(String path) {
|
115
|
+
return objectFactory.fileTree().from(path)
|
116
|
+
.include("**/react-native-gesture-handler/package.json")
|
117
|
+
.exclude("**/.yarn/**")
|
118
|
+
.exclude({ Files.isSymbolicLink(it.getFile().toPath()) })
|
119
|
+
.findAll()
|
120
|
+
}
|
121
|
+
|
122
|
+
@TaskAction
|
123
|
+
def check() {
|
124
|
+
if (shouldCheck.get()) {
|
125
|
+
// Assert there are no multiple installations of Gesture Handler
|
126
|
+
Set<File> files
|
127
|
+
|
128
|
+
if (projectDirFile.get().parent.contains(rootDirFile.get().parent)) {
|
129
|
+
// standard app
|
130
|
+
files = findGestureHandlerInstancesForPath(rootDirFile.get().parent + "/node_modules")
|
131
|
+
} else {
|
132
|
+
// monorepo
|
133
|
+
files = findGestureHandlerInstancesForPath(rootDirFile.get().parent + "/node_modules")
|
134
|
+
files.addAll(
|
135
|
+
findGestureHandlerInstancesForPath(projectDirFile.get().parentFile.parent)
|
136
|
+
)
|
137
|
+
}
|
138
|
+
|
139
|
+
if (files.size() > 1) {
|
140
|
+
String parsedLocation = files.stream().map({
|
141
|
+
File file -> "- " + file.toString().replace("/package.json", "")
|
142
|
+
}).collect().join("\n")
|
143
|
+
String exceptionMessage = "\n[react-native-gesture-handler] Multiple versions of Gesture Handler " +
|
144
|
+
"were detected. Only one instance of react-native-gesture-handler can be installed in a " +
|
145
|
+
"project. You need to resolve the conflict manually. Check out the documentation: " +
|
146
|
+
"https://docs.swmansion.com/react-native-gesture-handler/docs/troubleshooting" +
|
147
|
+
"#multiple-instances-of-gesture-handler-were-detected \n\nConflict between: \n" +
|
148
|
+
parsedLocation + "\n"
|
149
|
+
throw new GradleException(exceptionMessage)
|
150
|
+
}
|
151
|
+
}
|
122
152
|
}
|
123
153
|
}
|
124
154
|
|
125
|
-
tasks.
|
126
|
-
|
155
|
+
tasks.register('assertNoMultipleInstances', NoMultipleInstancesAssertionTask) {
|
156
|
+
shouldCheck = shouldAssertNoMultipleInstances()
|
157
|
+
rootDirFile = rootDir
|
158
|
+
projectDirFile = projectDir
|
127
159
|
}
|
128
160
|
|
161
|
+
tasks.preBuild {
|
162
|
+
dependsOn assertNoMultipleInstances
|
163
|
+
}
|
164
|
+
|
129
165
|
repositories {
|
130
166
|
mavenCentral()
|
131
167
|
}
|
132
168
|
|
133
169
|
android {
|
134
170
|
compileSdkVersion safeExtGet("compileSdkVersion", 28)
|
171
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
172
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
173
|
+
namespace "com.swmansion.gesturehandler"
|
174
|
+
}
|
135
175
|
|
136
176
|
// Used to override the NDK path/version on internal CI or by allowing
|
137
177
|
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
@@ -64,7 +64,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
|
|
64
64
|
private var shouldCancelWhenOutside = false
|
65
65
|
var numberOfPointers = 0
|
66
66
|
private set
|
67
|
-
|
67
|
+
protected var orchestrator: GestureHandlerOrchestrator? = null
|
68
68
|
private var onTouchEventListener: OnTouchEventListener? = null
|
69
69
|
private var interactionController: GestureHandlerInteractionController? = null
|
70
70
|
|
package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
CHANGED
@@ -50,6 +50,8 @@ class GestureHandlerOrchestrator(
|
|
50
50
|
return true
|
51
51
|
}
|
52
52
|
|
53
|
+
fun getHandlersForView(view: View) = handlerRegistry.getHandlersForView(view)
|
54
|
+
|
53
55
|
private fun scheduleFinishedHandlersCleanup() {
|
54
56
|
if (isHandlingTouch || handlingChangeSemaphore != 0) {
|
55
57
|
finishedHandlersCleanupScheduled = true
|
@@ -5,6 +5,8 @@ import android.view.MotionEvent
|
|
5
5
|
import android.view.View
|
6
6
|
import android.view.ViewConfiguration
|
7
7
|
import android.view.ViewGroup
|
8
|
+
import android.widget.ScrollView
|
9
|
+
import com.facebook.react.views.swiperefresh.ReactSwipeRefreshLayout
|
8
10
|
import com.facebook.react.views.textinput.ReactEditText
|
9
11
|
|
10
12
|
class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
@@ -72,6 +74,7 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
|
72
74
|
when (val view = view) {
|
73
75
|
is NativeViewGestureHandlerHook -> this.hook = view
|
74
76
|
is ReactEditText -> this.hook = EditTextHook(this, view)
|
77
|
+
is ReactSwipeRefreshLayout -> this.hook = SwipeRefreshLayoutHook(this, view)
|
75
78
|
}
|
76
79
|
}
|
77
80
|
|
@@ -208,4 +211,40 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
|
|
208
211
|
|
209
212
|
override fun shouldCancelRootViewGestureHandlerIfNecessary() = true
|
210
213
|
}
|
214
|
+
|
215
|
+
private class SwipeRefreshLayoutHook(
|
216
|
+
private val handler: NativeViewGestureHandler,
|
217
|
+
private val swipeRefreshLayout: ReactSwipeRefreshLayout
|
218
|
+
) : NativeViewGestureHandlerHook {
|
219
|
+
override fun wantsToHandleEventBeforeActivation() = true
|
220
|
+
|
221
|
+
override fun handleEventBeforeActivation(event: MotionEvent) {
|
222
|
+
// RefreshControl from GH is set up in a way that ScrollView wrapped with it should wait for
|
223
|
+
// it to fail. This way the RefreshControl is not canceled by the scroll handler.
|
224
|
+
// The problem with this approach is that the RefreshControl handler stays active all the time
|
225
|
+
// preventing scroll from activating.
|
226
|
+
// This is a workaround to prevent it from happening.
|
227
|
+
|
228
|
+
// First get the ScrollView under the RefreshControl, if there is none, return.
|
229
|
+
val scroll = swipeRefreshLayout.getChildAt(0) as? ScrollView ?: return
|
230
|
+
|
231
|
+
// Then find the first NativeViewGestureHandler attached to it
|
232
|
+
val scrollHandler = handler.orchestrator
|
233
|
+
?.getHandlersForView(scroll)
|
234
|
+
?.first {
|
235
|
+
it is NativeViewGestureHandler
|
236
|
+
}
|
237
|
+
|
238
|
+
// If handler was found, it's active and the ScrollView is not at the top, fail the RefreshControl
|
239
|
+
if (scrollHandler != null && scrollHandler.state == STATE_ACTIVE && scroll.scrollY > 0) {
|
240
|
+
handler.fail()
|
241
|
+
}
|
242
|
+
|
243
|
+
// The drawback is that the smooth transition from scrolling to refreshing in a single swipe
|
244
|
+
// is impossible this way and two swipes are required:
|
245
|
+
// - one to go back to top
|
246
|
+
// - one to actually refresh
|
247
|
+
// oh well ¯\_(ツ)_/¯
|
248
|
+
}
|
249
|
+
}
|
211
250
|
}
|
@@ -229,12 +229,12 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
229
229
|
colorDrawable.setCornerRadius(borderRadius)
|
230
230
|
}
|
231
231
|
|
232
|
-
val layerDrawable = LayerDrawable(arrayOf(colorDrawable, selectable))
|
232
|
+
val layerDrawable = LayerDrawable(if (selectable != null) arrayOf(colorDrawable, selectable) else arrayOf(colorDrawable))
|
233
233
|
background = layerDrawable
|
234
234
|
}
|
235
235
|
}
|
236
236
|
|
237
|
-
private fun createSelectableDrawable(): Drawable {
|
237
|
+
private fun createSelectableDrawable(): Drawable? {
|
238
238
|
// TODO: remove once support for RN 0.63 is dropped, since 0.64 minSdkVersion is 21
|
239
239
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
240
240
|
context.theme.resolveAttribute(android.R.attr.selectableItemBackground, resolveOutValue, true)
|
@@ -242,6 +242,12 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
|
|
242
242
|
return resources.getDrawable(resolveOutValue.resourceId)
|
243
243
|
}
|
244
244
|
|
245
|
+
// Since Android 13, alpha channel in RippleDrawable is clamped between [128, 255]
|
246
|
+
// see https://github.com/aosp-mirror/platform_frameworks_base/blob/c1bd0480261460584753508327ca8a0c6fc80758/graphics/java/android/graphics/drawable/RippleDrawable.java#L1012
|
247
|
+
if (rippleColor == Color.TRANSPARENT && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
248
|
+
return null
|
249
|
+
}
|
250
|
+
|
245
251
|
val states = arrayOf(intArrayOf(android.R.attr.state_enabled))
|
246
252
|
val rippleRadius = rippleRadius
|
247
253
|
val colorStateList = if (rippleColor != null) {
|
@@ -13,11 +13,11 @@
|
|
13
13
|
#import <React/RCTConvert.h>
|
14
14
|
#import <React/UIView+React.h>
|
15
15
|
|
16
|
-
#ifdef
|
16
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
17
17
|
#import <React/RCTScrollViewComponentView.h>
|
18
18
|
#else
|
19
19
|
#import <React/RCTScrollView.h>
|
20
|
-
#endif //
|
20
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
21
21
|
|
22
22
|
#pragma mark RNDummyGestureRecognizer
|
23
23
|
|
@@ -110,7 +110,7 @@
|
|
110
110
|
// We can restore default scrollview behaviour to delay touches to scrollview's children
|
111
111
|
// because gesture handler system can handle cancellation of scroll recognizer when JS responder
|
112
112
|
// is set
|
113
|
-
#ifdef
|
113
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
114
114
|
if ([view isKindOfClass:[RCTScrollViewComponentView class]]) {
|
115
115
|
UIScrollView *scrollView = ((RCTScrollViewComponentView *)view).scrollView;
|
116
116
|
scrollView.delaysContentTouches = YES;
|
@@ -123,7 +123,7 @@
|
|
123
123
|
UIScrollView *scrollView = [view.subviews objectAtIndex:0];
|
124
124
|
scrollView.delaysContentTouches = YES;
|
125
125
|
}
|
126
|
-
#endif //
|
126
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
127
127
|
}
|
128
128
|
|
129
129
|
- (void)handleTouchDown:(UIView *)sender forEvent:(UIEvent *)event
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#ifdef
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
2
2
|
|
3
3
|
#import "RNGestureHandlerButtonComponentView.h"
|
4
4
|
|
@@ -57,4 +57,4 @@ Class<RCTComponentViewProtocol> RNGestureHandlerButtonCls(void)
|
|
57
57
|
return RNGestureHandlerButtonComponentView.class;
|
58
58
|
}
|
59
59
|
|
60
|
-
#endif //
|
60
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
@@ -14,12 +14,13 @@
|
|
14
14
|
#import "RNGestureHandlerState.h"
|
15
15
|
#import "RNRootViewGestureRecognizer.h"
|
16
16
|
|
17
|
-
#ifdef
|
17
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
18
18
|
#import <React/RCTSurfaceTouchHandler.h>
|
19
|
+
#import <React/RCTSurfaceView.h>
|
19
20
|
#import <React/RCTViewComponentView.h>
|
20
21
|
#else
|
21
22
|
#import <React/RCTTouchHandler.h>
|
22
|
-
#endif //
|
23
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
23
24
|
|
24
25
|
#import "Handlers/RNFlingHandler.h"
|
25
26
|
#import "Handlers/RNForceTouchHandler.h"
|
@@ -37,6 +38,8 @@
|
|
37
38
|
RCTDefaultLogFunction( \
|
38
39
|
RCTLogLevelInfo, RCTLogSourceNative, @(__FILE__), @(__LINE__), [NSString stringWithFormat:__VA_ARGS__])
|
39
40
|
|
41
|
+
constexpr int NEW_ARCH_NUMBER_OF_ATTACH_RETRIES = 25;
|
42
|
+
|
40
43
|
@interface RNGestureHandlerManager () <RNGestureHandlerEventEmitter, RNRootViewGestureRecognizerDelegate>
|
41
44
|
|
42
45
|
@end
|
@@ -45,6 +48,7 @@
|
|
45
48
|
RNGestureHandlerRegistry *_registry;
|
46
49
|
RCTUIManager *_uiManager;
|
47
50
|
NSHashTable<RNRootViewGestureRecognizer *> *_rootViewGestureRecognizers;
|
51
|
+
NSMutableDictionary<NSNumber *, NSNumber *> *_attachRetryCounter;
|
48
52
|
RCTEventDispatcher *_eventDispatcher;
|
49
53
|
id _reanimatedModule;
|
50
54
|
}
|
@@ -56,6 +60,7 @@
|
|
56
60
|
_eventDispatcher = eventDispatcher;
|
57
61
|
_registry = [RNGestureHandlerRegistry new];
|
58
62
|
_rootViewGestureRecognizers = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory];
|
63
|
+
_attachRetryCounter = [[NSMutableDictionary alloc] init];
|
59
64
|
_reanimatedModule = nil;
|
60
65
|
}
|
61
66
|
return self;
|
@@ -99,13 +104,40 @@
|
|
99
104
|
{
|
100
105
|
UIView *view = [_uiManager viewForReactTag:viewTag];
|
101
106
|
|
102
|
-
#ifdef
|
103
|
-
if (view == nil) {
|
104
|
-
//
|
105
|
-
//
|
107
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
108
|
+
if (view == nil || view.superview == nil) {
|
109
|
+
// There are a few reasons we could end up here:
|
110
|
+
// - the native view corresponding to the viewtag hasn't yet been created
|
111
|
+
// - the native view has been created, but it's not attached to window
|
112
|
+
// - the native view will not exist because it got flattened
|
113
|
+
// In the first two cases we just want to wait until the view gets created or gets attached to its superview
|
114
|
+
// In the third case we don't want to do anything but we cannot easily distinguish it here, hece the abomination
|
115
|
+
// below
|
116
|
+
// TODO: would be great to have a better solution, although it might require migration to the shadow nodes from
|
117
|
+
// viewTags
|
118
|
+
|
119
|
+
NSNumber *counter = [_attachRetryCounter objectForKey:viewTag];
|
120
|
+
if (counter == nil) {
|
121
|
+
counter = @1;
|
122
|
+
} else {
|
123
|
+
counter = [NSNumber numberWithInt:counter.intValue + 1];
|
124
|
+
}
|
125
|
+
|
126
|
+
if (counter.intValue > NEW_ARCH_NUMBER_OF_ATTACH_RETRIES) {
|
127
|
+
[_attachRetryCounter removeObjectForKey:viewTag];
|
128
|
+
} else {
|
129
|
+
[_attachRetryCounter setObject:counter forKey:viewTag];
|
130
|
+
|
131
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
132
|
+
[self attachGestureHandler:handlerTag toViewWithTag:viewTag withActionType:actionType];
|
133
|
+
});
|
134
|
+
}
|
135
|
+
|
106
136
|
return;
|
107
137
|
}
|
108
138
|
|
139
|
+
[_attachRetryCounter removeObjectForKey:viewTag];
|
140
|
+
|
109
141
|
// I think it should be moved to RNNativeViewHandler, but that would require
|
110
142
|
// additional logic for setting contentView.reactTag, this works for now
|
111
143
|
if ([view isKindOfClass:[RCTViewComponentView class]]) {
|
@@ -117,7 +149,7 @@
|
|
117
149
|
|
118
150
|
view.reactTag = viewTag; // necessary for RNReanimated eventHash (e.g. "42onGestureHandlerEvent"), also will be
|
119
151
|
// returned as event.target
|
120
|
-
#endif //
|
152
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
121
153
|
|
122
154
|
[_registry attachHandlerWithTag:handlerTag toView:view withActionType:actionType];
|
123
155
|
|
@@ -164,18 +196,26 @@
|
|
164
196
|
|
165
197
|
- (void)registerViewWithGestureRecognizerAttachedIfNeeded:(UIView *)childView
|
166
198
|
{
|
199
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
200
|
+
UIView *touchHandlerView = childView;
|
201
|
+
|
202
|
+
while (touchHandlerView != nil && ![touchHandlerView isKindOfClass:[RCTSurfaceView class]]) {
|
203
|
+
touchHandlerView = touchHandlerView.superview;
|
204
|
+
}
|
205
|
+
#else
|
167
206
|
UIView *parent = childView;
|
168
207
|
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)])
|
169
208
|
parent = parent.superview;
|
170
209
|
|
171
|
-
// Many views can return the same touchHandler so we check if the one we want to register
|
172
|
-
// is not already present in the set.
|
173
210
|
UIView *touchHandlerView = [[parent performSelector:@selector(touchHandler)] view];
|
211
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
174
212
|
|
175
213
|
if (touchHandlerView == nil) {
|
176
214
|
return;
|
177
215
|
}
|
178
216
|
|
217
|
+
// Many views can return the same touchHandler so we check if the one we want to register
|
218
|
+
// is not already present in the set.
|
179
219
|
for (UIGestureRecognizer *recognizer in touchHandlerView.gestureRecognizers) {
|
180
220
|
if ([recognizer isKindOfClass:[RNRootViewGestureRecognizer class]]) {
|
181
221
|
return;
|
@@ -207,11 +247,20 @@
|
|
207
247
|
if ([gestureRecognizer.view isKindOfClass:[UIScrollView class]])
|
208
248
|
return;
|
209
249
|
|
210
|
-
#ifdef
|
211
|
-
|
250
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
251
|
+
UIGestureRecognizer *touchHandler = nil;
|
252
|
+
|
253
|
+
// touchHandler (RCTSurfaceTouchHandler) is private in RCTFabricSurface so we have to do
|
254
|
+
// this little trick to get access to it
|
255
|
+
for (UIGestureRecognizer *recognizer in [viewWithTouchHandler gestureRecognizers]) {
|
256
|
+
if ([recognizer isKindOfClass:[RCTSurfaceTouchHandler class]]) {
|
257
|
+
touchHandler = recognizer;
|
258
|
+
break;
|
259
|
+
}
|
260
|
+
}
|
212
261
|
#else
|
213
262
|
RCTTouchHandler *touchHandler = [viewWithTouchHandler performSelector:@selector(touchHandler)];
|
214
|
-
#endif
|
263
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
215
264
|
[touchHandler setEnabled:NO];
|
216
265
|
[touchHandler setEnabled:YES];
|
217
266
|
}
|
@@ -249,7 +298,7 @@
|
|
249
298
|
- (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event
|
250
299
|
{
|
251
300
|
// Delivers the event to Reanimated.
|
252
|
-
#ifdef
|
301
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
253
302
|
// Send event directly to Reanimated
|
254
303
|
if (_reanimatedModule == nil) {
|
255
304
|
_reanimatedModule = [_uiManager.bridge moduleForName:@"ReanimatedModule"];
|
@@ -260,7 +309,7 @@
|
|
260
309
|
// In the old architecture, Reanimated overwrites RCTEventDispatcher
|
261
310
|
// with REAEventDispatcher and intercepts all direct events.
|
262
311
|
[self sendEventForDirectEvent:event];
|
263
|
-
#endif //
|
312
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
264
313
|
}
|
265
314
|
|
266
315
|
- (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
|
@@ -275,11 +324,11 @@
|
|
275
324
|
- (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
|
276
325
|
{
|
277
326
|
// Delivers the event to JS (old RNGH API).
|
278
|
-
#ifdef
|
327
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
279
328
|
[self sendEventForDeviceEvent:event];
|
280
329
|
#else
|
281
330
|
[self sendEventForDirectEvent:event];
|
282
|
-
#endif //
|
331
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
283
332
|
}
|
284
333
|
|
285
334
|
- (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
|
@@ -7,7 +7,7 @@
|
|
7
7
|
#import <React/RCTUIManagerUtils.h>
|
8
8
|
#import <React/RCTViewManager.h>
|
9
9
|
|
10
|
-
#ifdef
|
10
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
11
11
|
#import <React/RCTBridge+Private.h>
|
12
12
|
#import <React/RCTBridge.h>
|
13
13
|
#import <React/RCTSurfacePresenter.h>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
#import <ReactCommon/RCTTurboModule.h>
|
17
17
|
|
18
18
|
#import <react/renderer/uimanager/primitives.h>
|
19
|
-
#endif //
|
19
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
20
20
|
|
21
21
|
#import "RNGestureHandler.h"
|
22
22
|
#import "RNGestureHandlerDirection.h"
|
@@ -26,12 +26,12 @@
|
|
26
26
|
#import "RNGestureHandlerButton.h"
|
27
27
|
#import "RNGestureHandlerStateManager.h"
|
28
28
|
|
29
|
-
#ifdef
|
29
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
30
30
|
using namespace facebook;
|
31
31
|
using namespace react;
|
32
|
-
#endif //
|
32
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
33
33
|
|
34
|
-
#ifdef
|
34
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
35
35
|
@interface RNGestureHandlerModule () <RCTSurfacePresenterObserver, RNGestureHandlerStateManager>
|
36
36
|
|
37
37
|
@end
|
@@ -39,7 +39,7 @@ using namespace react;
|
|
39
39
|
@interface RNGestureHandlerModule () <RCTUIManagerObserver, RNGestureHandlerStateManager>
|
40
40
|
|
41
41
|
@end
|
42
|
-
#endif //
|
42
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
43
43
|
|
44
44
|
typedef void (^GestureHandlerOperation)(RNGestureHandlerManager *manager);
|
45
45
|
|
@@ -66,11 +66,11 @@ RCT_EXPORT_MODULE()
|
|
66
66
|
|
67
67
|
_manager = nil;
|
68
68
|
|
69
|
-
#ifdef
|
69
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
70
70
|
[self.bridge.surfacePresenter removeObserver:self];
|
71
71
|
#else
|
72
72
|
[self.bridge.uiManager.observerCoordinator removeObserver:self];
|
73
|
-
#endif //
|
73
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
74
74
|
}
|
75
75
|
|
76
76
|
- (dispatch_queue_t)methodQueue
|
@@ -84,7 +84,7 @@ RCT_EXPORT_MODULE()
|
|
84
84
|
return RCTGetUIManagerQueue();
|
85
85
|
}
|
86
86
|
|
87
|
-
#ifdef
|
87
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
88
88
|
void decorateRuntime(jsi::Runtime &runtime)
|
89
89
|
{
|
90
90
|
auto isFormsStackingContext = jsi::Function::createFromHostFunction(
|
@@ -103,7 +103,7 @@ void decorateRuntime(jsi::Runtime &runtime)
|
|
103
103
|
});
|
104
104
|
runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext));
|
105
105
|
}
|
106
|
-
#endif //
|
106
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
107
107
|
|
108
108
|
- (void)setBridge:(RCTBridge *)bridge
|
109
109
|
{
|
@@ -113,14 +113,14 @@ void decorateRuntime(jsi::Runtime &runtime)
|
|
113
113
|
eventDispatcher:bridge.eventDispatcher];
|
114
114
|
_operations = [NSMutableArray new];
|
115
115
|
|
116
|
-
#ifdef
|
116
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
117
117
|
[bridge.surfacePresenter addObserver:self];
|
118
118
|
#else
|
119
119
|
[bridge.uiManager.observerCoordinator addObserver:self];
|
120
|
-
#endif //
|
120
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
121
121
|
}
|
122
122
|
|
123
|
-
#ifdef
|
123
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
124
124
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
125
125
|
{
|
126
126
|
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
|
@@ -128,7 +128,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
|
128
128
|
decorateRuntime(*runtime);
|
129
129
|
return @true;
|
130
130
|
}
|
131
|
-
#endif //
|
131
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
132
132
|
|
133
133
|
RCT_EXPORT_METHOD(createGestureHandler
|
134
134
|
: (nonnull NSString *)handlerName tag
|
@@ -184,6 +184,9 @@ RCT_EXPORT_METHOD(handleClearJSResponder)
|
|
184
184
|
|
185
185
|
RCT_EXPORT_METHOD(flushOperations)
|
186
186
|
{
|
187
|
+
// On the new arch we rely on `flushOperations` for scheduling the operations on the UI thread.
|
188
|
+
// On the old arch we rely on `uiManagerWillPerformMounting`
|
189
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
187
190
|
if (_operations.count == 0) {
|
188
191
|
return;
|
189
192
|
}
|
@@ -197,6 +200,7 @@ RCT_EXPORT_METHOD(flushOperations)
|
|
197
200
|
operation(self->_manager);
|
198
201
|
}
|
199
202
|
}];
|
203
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
200
204
|
}
|
201
205
|
|
202
206
|
- (void)setGestureState:(int)state forHandler:(int)handlerTag
|
@@ -239,7 +243,7 @@ RCT_EXPORT_METHOD(flushOperations)
|
|
239
243
|
|
240
244
|
#pragma mark - RCTSurfacePresenterObserver
|
241
245
|
|
242
|
-
#ifdef
|
246
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
243
247
|
|
244
248
|
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
|
245
249
|
{
|
@@ -282,7 +286,7 @@ RCT_EXPORT_METHOD(flushOperations)
|
|
282
286
|
}];
|
283
287
|
}
|
284
288
|
|
285
|
-
#endif //
|
289
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
286
290
|
|
287
291
|
#pragma mark Events
|
288
292
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#ifdef
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
2
2
|
|
3
3
|
#import <React/RCTFabricComponentsPlugins.h>
|
4
4
|
|
@@ -18,4 +18,4 @@ Class<RCTComponentViewProtocol> RNGestureHandlerRootViewCls(void)
|
|
18
18
|
return nil;
|
19
19
|
}
|
20
20
|
|
21
|
-
#endif //
|
21
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
@@ -10,11 +10,11 @@
|
|
10
10
|
|
11
11
|
#import <UIKit/UIGestureRecognizerSubclass.h>
|
12
12
|
|
13
|
-
#ifdef
|
13
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
14
14
|
#import <React/RCTSurfaceTouchHandler.h>
|
15
15
|
#else
|
16
16
|
#import <React/RCTTouchHandler.h>
|
17
|
-
#endif //
|
17
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
18
18
|
|
19
19
|
@implementation RNRootViewGestureRecognizer {
|
20
20
|
BOOL _active;
|
@@ -46,7 +46,7 @@
|
|
46
46
|
- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer
|
47
47
|
{
|
48
48
|
return ![preventedGestureRecognizer isKindOfClass:[
|
49
|
-
#ifdef
|
49
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
50
50
|
RCTSurfaceTouchHandler
|
51
51
|
#else
|
52
52
|
RCTTouchHandler
|