react-native-gesture-handler 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +1 -0
  2. package/RNGestureHandler.podspec +2 -2
  3. package/android/build.gradle +107 -65
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +1 -1
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +39 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -2
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +14 -2
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +5 -1
  10. package/android/src/main/jni/CMakeLists.txt +10 -44
  11. package/android/src/main/jni/cpp-adapter.cpp +16 -13
  12. package/ios/Handlers/RNFlingHandler.m +39 -37
  13. package/ios/Handlers/RNForceTouchHandler.m +19 -17
  14. package/ios/Handlers/RNLongPressHandler.m +20 -22
  15. package/ios/Handlers/RNManualHandler.m +2 -3
  16. package/ios/Handlers/RNNativeViewHandler.mm +96 -92
  17. package/ios/Handlers/RNPanHandler.m +28 -32
  18. package/ios/Handlers/RNPinchHandler.m +9 -10
  19. package/ios/Handlers/RNRotationHandler.m +11 -14
  20. package/ios/Handlers/RNTapHandler.m +26 -26
  21. package/ios/RNGestureHandler.h +31 -24
  22. package/ios/RNGestureHandler.m +278 -273
  23. package/ios/RNGestureHandlerActionType.h +6 -4
  24. package/ios/RNGestureHandlerButton.m +11 -12
  25. package/ios/RNGestureHandlerButtonComponentView.h +2 -2
  26. package/ios/RNGestureHandlerButtonComponentView.mm +2 -2
  27. package/ios/RNGestureHandlerButtonManager.m +6 -5
  28. package/ios/RNGestureHandlerDirection.h +4 -4
  29. package/ios/RNGestureHandlerEvents.h +3 -4
  30. package/ios/RNGestureHandlerEvents.m +114 -119
  31. package/ios/RNGestureHandlerManager.h +1 -2
  32. package/ios/RNGestureHandlerManager.mm +9 -9
  33. package/ios/RNGestureHandlerModule.h +1 -2
  34. package/ios/RNGestureHandlerModule.mm +142 -138
  35. package/ios/RNGestureHandlerPointerTracker.h +1 -1
  36. package/ios/RNGestureHandlerPointerTracker.m +40 -37
  37. package/ios/RNGestureHandlerRegistry.h +3 -1
  38. package/ios/RNGestureHandlerRegistry.m +24 -22
  39. package/ios/RNGestureHandlerRootViewComponentView.mm +2 -2
  40. package/ios/RNGestureHandlerState.h +6 -6
  41. package/ios/RNGestureHandlerStateManager.h +1 -1
  42. package/ios/RNManualActivationRecognizer.m +9 -9
  43. package/ios/RNRootViewGestureRecognizer.m +39 -42
  44. package/lib/commonjs/EnableNewWebImplementation.js +35 -0
  45. package/lib/commonjs/EnableNewWebImplementation.js.map +1 -0
  46. package/lib/commonjs/GestureHandlerRootViewContext.js +15 -0
  47. package/lib/commonjs/GestureHandlerRootViewContext.js.map +1 -0
  48. package/lib/commonjs/RNGestureHandlerModule.macos.js +6 -6
  49. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
  50. package/lib/commonjs/RNGestureHandlerModule.web.js +6 -6
  51. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  52. package/lib/commonjs/RNGestureHandlerModule.windows.js +6 -6
  53. package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
  54. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  55. package/lib/commonjs/components/GestureComponents.web.js +6 -5
  56. package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
  57. package/lib/commonjs/components/GestureHandlerButton.js +3 -5
  58. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  59. package/lib/commonjs/{GestureHandlerRootView.android.js → components/GestureHandlerRootView.android.js} +8 -7
  60. package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -0
  61. package/lib/commonjs/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +8 -2
  62. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -0
  63. package/lib/commonjs/{GestureHandlerRootView.web.js → components/GestureHandlerRootView.web.js} +7 -1
  64. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
  65. package/lib/commonjs/components/Swipeable.js +17 -3
  66. package/lib/commonjs/components/Swipeable.js.map +1 -1
  67. package/lib/commonjs/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  68. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -0
  69. package/lib/commonjs/handlers/LongPressGestureHandler.js +3 -1
  70. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  71. package/lib/commonjs/handlers/TapGestureHandler.js +3 -1
  72. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  73. package/lib/commonjs/handlers/createHandler.js +21 -13
  74. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  75. package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -4
  76. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  77. package/lib/commonjs/handlers/gestures/GestureDetector.js +89 -37
  78. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  79. package/lib/commonjs/handlers/gestures/longPressGesture.js +1 -0
  80. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  81. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +22 -19
  82. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  83. package/lib/commonjs/handlers/gestures/tapGesture.js +1 -0
  84. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
  85. package/lib/commonjs/index.js +16 -4
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/utils.js +0 -6
  88. package/lib/commonjs/utils.js.map +1 -1
  89. package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -5
  90. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  91. package/lib/commonjs/web/handlers/GestureHandler.js +3 -0
  92. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  93. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +0 -1
  94. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  95. package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -5
  96. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  97. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -6
  98. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  99. package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -12
  100. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  101. package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -5
  102. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  103. package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -6
  104. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -7
  106. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  107. package/lib/commonjs/web/tools/CircularBuffer.js +59 -0
  108. package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -0
  109. package/lib/commonjs/web/tools/LeastSquareSolver.js +204 -0
  110. package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -0
  111. package/lib/commonjs/web/tools/PointerEventManager.js +27 -0
  112. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  113. package/lib/commonjs/web/tools/PointerTracker.js +11 -7
  114. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  115. package/lib/commonjs/web/tools/VelocityTracker.js +111 -0
  116. package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -0
  117. package/lib/commonjs/web_hammer/GestureHandler.js +1 -1
  118. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
  119. package/lib/module/EnableNewWebImplementation.js +22 -0
  120. package/lib/module/EnableNewWebImplementation.js.map +1 -0
  121. package/lib/module/GestureHandlerRootViewContext.js +3 -0
  122. package/lib/module/GestureHandlerRootViewContext.js.map +1 -0
  123. package/lib/module/RNGestureHandlerModule.macos.js +6 -6
  124. package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
  125. package/lib/module/RNGestureHandlerModule.web.js +6 -6
  126. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  127. package/lib/module/RNGestureHandlerModule.windows.js +6 -6
  128. package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
  129. package/lib/module/components/DrawerLayout.js.map +1 -1
  130. package/lib/module/components/GestureComponents.web.js +5 -6
  131. package/lib/module/components/GestureComponents.web.js.map +1 -1
  132. package/lib/module/components/GestureHandlerButton.js +1 -4
  133. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  134. package/lib/module/components/GestureHandlerRootView.android.js +14 -0
  135. package/lib/module/components/GestureHandlerRootView.android.js.map +1 -0
  136. package/lib/module/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +5 -2
  137. package/lib/module/components/GestureHandlerRootView.js.map +1 -0
  138. package/lib/module/components/GestureHandlerRootView.web.js +9 -0
  139. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
  140. package/lib/module/components/Swipeable.js +17 -3
  141. package/lib/module/components/Swipeable.js.map +1 -1
  142. package/lib/module/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  143. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -0
  144. package/lib/module/handlers/LongPressGestureHandler.js +3 -1
  145. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  146. package/lib/module/handlers/TapGestureHandler.js +3 -1
  147. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  148. package/lib/module/handlers/createHandler.js +20 -13
  149. package/lib/module/handlers/createHandler.js.map +1 -1
  150. package/lib/module/handlers/gestureHandlerCommon.js +5 -4
  151. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  152. package/lib/module/handlers/gestures/GestureDetector.js +89 -38
  153. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  154. package/lib/module/handlers/gestures/longPressGesture.js +1 -0
  155. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  156. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -16
  157. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  158. package/lib/module/handlers/gestures/tapGesture.js +1 -0
  159. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  160. package/lib/module/index.js +4 -4
  161. package/lib/module/index.js.map +1 -1
  162. package/lib/module/utils.js +0 -4
  163. package/lib/module/utils.js.map +1 -1
  164. package/lib/module/web/handlers/FlingGestureHandler.js +0 -5
  165. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/GestureHandler.js +3 -0
  167. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/LongPressGestureHandler.js +0 -1
  169. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/ManualGestureHandler.js +0 -5
  171. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  172. package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -6
  173. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  174. package/lib/module/web/handlers/PanGestureHandler.js +2 -9
  175. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  176. package/lib/module/web/handlers/PinchGestureHandler.js +0 -5
  177. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  178. package/lib/module/web/handlers/RotationGestureHandler.js +0 -6
  179. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  180. package/lib/module/web/handlers/TapGestureHandler.js +0 -7
  181. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  182. package/lib/module/web/tools/CircularBuffer.js +50 -0
  183. package/lib/module/web/tools/CircularBuffer.js.map +1 -0
  184. package/lib/module/web/tools/LeastSquareSolver.js +195 -0
  185. package/lib/module/web/tools/LeastSquareSolver.js.map +1 -0
  186. package/lib/module/web/tools/PointerEventManager.js +27 -0
  187. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  188. package/lib/module/web/tools/PointerTracker.js +8 -7
  189. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  190. package/lib/module/web/tools/VelocityTracker.js +98 -0
  191. package/lib/module/web/tools/VelocityTracker.js.map +1 -0
  192. package/lib/module/web_hammer/GestureHandler.js +1 -1
  193. package/lib/module/web_hammer/GestureHandler.js.map +1 -1
  194. package/lib/typescript/EnableNewWebImplementation.d.ts +3 -0
  195. package/lib/typescript/GestureHandlerRootViewContext.d.ts +3 -0
  196. package/lib/typescript/components/DrawerLayout.d.ts +3 -1
  197. package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
  198. package/lib/typescript/components/Swipeable.d.ts +14 -2
  199. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +3 -0
  200. package/lib/typescript/index.d.ts +4 -4
  201. package/lib/typescript/{fabric → specs}/RNGestureHandlerButtonNativeComponent.d.ts +1 -1
  202. package/lib/typescript/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.d.ts +1 -1
  203. package/lib/typescript/utils.d.ts +0 -1
  204. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
  205. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
  206. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  207. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -1
  208. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
  209. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
  210. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -1
  211. package/lib/typescript/web/tools/CircularBuffer.d.ts +11 -0
  212. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +12 -0
  213. package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
  214. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  215. package/lib/typescript/web/tools/VelocityTracker.d.ts +13 -0
  216. package/package.json +6 -7
  217. package/src/EnableNewWebImplementation.ts +35 -0
  218. package/src/GestureHandlerRootViewContext.ts +3 -0
  219. package/src/RNGestureHandlerModule.macos.ts +6 -6
  220. package/src/RNGestureHandlerModule.web.ts +6 -6
  221. package/src/RNGestureHandlerModule.windows.ts +6 -6
  222. package/src/components/DrawerLayout.tsx +8 -4
  223. package/src/components/GestureComponents.web.tsx +5 -6
  224. package/src/components/GestureHandlerButton.tsx +2 -7
  225. package/src/components/GestureHandlerRootView.android.tsx +24 -0
  226. package/src/{GestureHandlerRootView.tsx → components/GestureHandlerRootView.tsx} +7 -2
  227. package/src/{GestureHandlerRootView.web.tsx → components/GestureHandlerRootView.web.tsx} +6 -1
  228. package/src/components/Swipeable.tsx +43 -12
  229. package/src/{gestureHandlerRootHOC.tsx → components/gestureHandlerRootHOC.tsx} +4 -1
  230. package/src/handlers/LongPressGestureHandler.ts +3 -1
  231. package/src/handlers/TapGestureHandler.ts +3 -1
  232. package/src/handlers/createHandler.tsx +20 -9
  233. package/src/handlers/gestureHandlerCommon.ts +5 -6
  234. package/src/handlers/gestures/GestureDetector.tsx +99 -36
  235. package/src/handlers/gestures/longPressGesture.ts +1 -0
  236. package/src/handlers/gestures/reanimatedWrapper.ts +21 -20
  237. package/src/handlers/gestures/tapGesture.ts +1 -0
  238. package/src/index.ts +7 -3
  239. package/src/utils.ts +0 -5
  240. package/src/web/handlers/FlingGestureHandler.ts +0 -5
  241. package/src/web/handlers/GestureHandler.ts +3 -0
  242. package/src/web/handlers/LongPressGestureHandler.ts +0 -1
  243. package/src/web/handlers/ManualGestureHandler.ts +0 -5
  244. package/src/web/handlers/NativeViewGestureHandler.ts +0 -6
  245. package/src/web/handlers/PanGestureHandler.ts +2 -9
  246. package/src/web/handlers/PinchGestureHandler.ts +0 -5
  247. package/src/web/handlers/RotationGestureHandler.ts +0 -7
  248. package/src/web/handlers/TapGestureHandler.ts +0 -7
  249. package/src/web/tools/CircularBuffer.ts +42 -0
  250. package/src/web/tools/LeastSquareSolver.ts +182 -0
  251. package/src/web/tools/PointerEventManager.ts +29 -0
  252. package/src/web/tools/PointerTracker.ts +7 -7
  253. package/src/web/tools/VelocityTracker.ts +98 -0
  254. package/src/web_hammer/GestureHandler.ts +1 -1
  255. package/lib/commonjs/EnableExperimentalWebImplementation.js +0 -31
  256. package/lib/commonjs/EnableExperimentalWebImplementation.js.map +0 -1
  257. package/lib/commonjs/GestureHandlerRootView.android.js.map +0 -1
  258. package/lib/commonjs/GestureHandlerRootView.js.map +0 -1
  259. package/lib/commonjs/GestureHandlerRootView.web.js.map +0 -1
  260. package/lib/commonjs/gestureHandlerRootHOC.js.map +0 -1
  261. package/lib/module/EnableExperimentalWebImplementation.js +0 -20
  262. package/lib/module/EnableExperimentalWebImplementation.js.map +0 -1
  263. package/lib/module/GestureHandlerRootView.android.js +0 -14
  264. package/lib/module/GestureHandlerRootView.android.js.map +0 -1
  265. package/lib/module/GestureHandlerRootView.js.map +0 -1
  266. package/lib/module/GestureHandlerRootView.web.js +0 -6
  267. package/lib/module/GestureHandlerRootView.web.js.map +0 -1
  268. package/lib/module/gestureHandlerRootHOC.js.map +0 -1
  269. package/lib/typescript/EnableExperimentalWebImplementation.d.ts +0 -2
  270. package/lib/typescript/gestureHandlerRootHOC.d.ts +0 -3
  271. package/src/EnableExperimentalWebImplementation.ts +0 -27
  272. package/src/GestureHandlerRootView.android.tsx +0 -24
  273. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  274. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  275. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  276. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  277. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  278. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  279. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  280. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  281. /package/lib/typescript/{GestureHandlerRootView.android.d.ts → components/GestureHandlerRootView.android.d.ts} +0 -0
  282. /package/lib/typescript/{GestureHandlerRootView.d.ts → components/GestureHandlerRootView.d.ts} +0 -0
  283. /package/lib/typescript/{GestureHandlerRootView.web.d.ts → components/GestureHandlerRootView.web.d.ts} +0 -0
  284. /package/src/{fabric → specs}/RNGestureHandlerButtonNativeComponent.ts +0 -0
  285. /package/src/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.ts +0 -0
package/README.md CHANGED
@@ -39,6 +39,7 @@ You will need to have an Android or iOS device or emulator connected as well as
39
39
 
40
40
  | version | react-native version |
41
41
  | ------- | -------------------- |
42
+ | 2.10.0+ | 0.64.0+ |
42
43
  | 2.0.0+ | 0.63.0+ |
43
44
  | 1.4.0+ | 0.60.0+ |
44
45
  | 1.1.0+ | 0.57.2+ |
@@ -2,7 +2,7 @@ require "json"
2
2
 
3
3
  fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
4
4
 
5
- isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
5
+ isUserApp = File.exist?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
6
6
  if isUserApp
7
7
  libInstances = %x[find ../../ -name "package.json" | grep "/react-native-gesture-handler/package.json" | grep -v "/.yarn/"]
8
8
  libInstancesArray = libInstances.split("\n")
@@ -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 + ' -DRN_FABRIC_ENABLED'
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
@@ -1,5 +1,7 @@
1
1
  import groovy.json.JsonSlurper
2
- import java.nio.file.Paths
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']
@@ -27,25 +29,33 @@ def isNewArchitectureEnabled() {
27
29
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
28
30
  }
29
31
 
30
- static def findNodeModulePath(baseDir, packageName) {
31
- def basePath = baseDir.toPath().normalize()
32
- // Node's module resolution algorithm searches up to the root directory,
33
- // after which the base path will be null
34
- while (basePath) {
35
- def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
36
- if (candidatePath.toFile().exists()) {
37
- return candidatePath.toString()
38
- }
39
- basePath = basePath.getParent()
40
- }
41
- return null
32
+ def safeExtGet(prop, fallback) {
33
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
42
34
  }
43
35
 
44
- def findNodeModulePath(packageName) {
45
- // Don't start in the project dir, as its path ends with node_modules/react-native-gesture-handler/android
46
- // we want to go two levels up, so we end up in the first_node modules and eventually
47
- // search upwards if the package is not found there
48
- return findNodeModulePath(projectDir.toPath().parent.parent.toFile(), packageName)
36
+ def resolveReactNativeDirectory() {
37
+ def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
38
+ if (reactNativeLocation != null) {
39
+ return file(reactNativeLocation)
40
+ }
41
+
42
+ // monorepo workaround
43
+ // react-native can be hoisted or in project's own node_modules
44
+ def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
45
+ if (reactNativeFromProjectNodeModules.exists()) {
46
+ return reactNativeFromProjectNodeModules
47
+ }
48
+
49
+ def reactNativeFromNodeModulesWithReanimated = file("${projectDir}/../../react-native")
50
+ if (reactNativeFromNodeModulesWithReanimated.exists()) {
51
+ return reactNativeFromNodeModulesWithReanimated
52
+ }
53
+
54
+ throw new Exception(
55
+ "[react-native-gesture-handler] Unable to resolve react-native location in " +
56
+ "node_modules. You should add project extension property (in app/build.gradle) " +
57
+ "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
58
+ )
49
59
  }
50
60
 
51
61
  if (isNewArchitectureEnabled()) {
@@ -58,8 +68,12 @@ if (project == rootProject) {
58
68
  apply from: "spotless.gradle"
59
69
  }
60
70
 
61
- def safeExtGet(prop, fallback) {
62
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
71
+ def shouldAssertNoMultipleInstances() {
72
+ if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
73
+ return rootProject.property("disableMultipleInstancesCheck") != "true"
74
+ } else {
75
+ return true
76
+ }
63
77
  }
64
78
 
65
79
  // Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
@@ -81,46 +95,83 @@ def reactNativeArchitectures() {
81
95
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
82
96
  }
83
97
 
84
- def shouldAssertNoMultipleInstances() {
85
- if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
86
- return rootProject.property("disableMultipleInstancesCheck") != "true"
87
- } else {
88
- return true
89
- }
90
- }
98
+ def REACT_NATIVE_DIR = resolveReactNativeDirectory()
91
99
 
92
- def noMultipleInstancesAssertion() {
93
- Set<File> files = fileTree(rootDir.parent) {
94
- include "node_modules/**/react-native-gesture-handler/package.json"
95
- exclude "**/.yarn/**"
96
- }.files
100
+ def reactProperties = new Properties()
101
+ file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
97
102
 
98
- if (files.size() > 1) {
99
- String parsedLocation = files.stream().map({ File file -> "- " + file.toString().replace("/package.json", "") }).collect().join("\n")
100
- 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";
101
- throw new Exception(exceptionMessage);
103
+ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
104
+ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
105
+
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()
102
120
  }
103
- }
104
121
 
105
- def REACT_NATIVE_DIR = findNodeModulePath("react-native")
122
+ @TaskAction
123
+ def check() {
124
+ if (shouldCheck.get()) {
125
+ // Assert there are no multiple installations of Gesture Handler
126
+ Set<File> files
106
127
 
107
- def assertionTask = task assertNoMultipleInstances {
108
- onlyIf { shouldAssertNoMultipleInstances() }
109
- doFirst {
110
- noMultipleInstancesAssertion()
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
+ }
111
152
  }
112
153
  }
113
154
 
114
- tasks.preBuild {
115
- dependsOn assertionTask
155
+ tasks.register('assertNoMultipleInstances', NoMultipleInstancesAssertionTask) {
156
+ shouldCheck = shouldAssertNoMultipleInstances()
157
+ rootDirFile = rootDir
158
+ projectDirFile = projectDir
116
159
  }
117
160
 
161
+ tasks.preBuild {
162
+ dependsOn assertNoMultipleInstances
163
+ }
164
+
118
165
  repositories {
119
166
  mavenCentral()
120
167
  }
121
168
 
122
169
  android {
123
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
+ }
124
175
 
125
176
  // Used to override the NDK path/version on internal CI or by allowing
126
177
  // users to customize the NDK path/version from their root project (e.g. for M1 support)
@@ -131,17 +182,25 @@ android {
131
182
  ndkVersion rootProject.ext.ndkVersion
132
183
  }
133
184
 
185
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
186
+ buildFeatures {
187
+ prefab true
188
+ }
189
+ }
190
+
134
191
  defaultConfig {
135
192
  minSdkVersion safeExtGet('minSdkVersion', 16)
136
193
  targetSdkVersion safeExtGet('targetSdkVersion', 28)
137
194
  versionCode 1
138
195
  versionName "1.0"
139
196
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
197
+ buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()
198
+
140
199
  if (isNewArchitectureEnabled()) {
141
200
  var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
142
201
  externalNativeBuild {
143
202
  cmake {
144
- cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
203
+ cppFlags "-O2", "-frtti", "-fexceptions", "-Wall", "-Werror", "-std=c++17"
145
204
  arguments "-DAPP_BUILD_DIR=${appProject.buildDir}",
146
205
  "-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
147
206
  "-DANDROID_STL=c++_shared"
@@ -198,10 +257,10 @@ def kotlin_version = safeExtGet('kotlinVersion', project.properties['RNGH_kotlin
198
257
 
199
258
  dependencies {
200
259
  //noinspection GradleDynamicVersion
201
- if (isNewArchitectureEnabled()) {
202
- implementation project(':ReactAndroid')
260
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
261
+ implementation "com.facebook.react:react-android" // version substituted by RNGP
203
262
  } else {
204
- implementation 'com.facebook.react:react-native:+'
263
+ implementation 'com.facebook.react:react-native:+' // from node_modules
205
264
  }
206
265
 
207
266
  if (shouldUseCommonInterfaceFromReanimated()) {
@@ -215,20 +274,3 @@ dependencies {
215
274
  implementation "androidx.core:core-ktx:1.6.0"
216
275
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
217
276
  }
218
-
219
- if (isNewArchitectureEnabled()) {
220
- // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
221
- tasks.whenTaskAdded { task ->
222
- if (task.name.contains("configureCMakeDebug")) {
223
- rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
224
- task.dependsOn(it)
225
- }
226
- }
227
- // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
228
- if (task.name.contains("configureCMakeRel")) {
229
- rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
230
- task.dependsOn(it)
231
- }
232
- }
233
- }
234
- }
@@ -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
- private var orchestrator: GestureHandlerOrchestrator? = null
67
+ protected var orchestrator: GestureHandlerOrchestrator? = null
68
68
  private var onTouchEventListener: OnTouchEventListener? = null
69
69
  private var interactionController: GestureHandlerInteractionController? = null
70
70
 
@@ -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) {
@@ -331,6 +337,7 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
331
337
  // don't preform click when a child button is pressed (mainly to prevent sound effect of
332
338
  // a parent button from playing)
333
339
  return if (!isChildTouched() && soundResponder == this) {
340
+ tryFreeingResponder()
334
341
  soundResponder = null
335
342
  super.performClick()
336
343
  } else {
@@ -16,13 +16,23 @@ import com.swmansion.gesturehandler.core.GestureHandler
16
16
  class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>() {
17
17
  private var extraData: WritableMap? = null
18
18
  private var coalescingKey: Short = 0
19
+
20
+ // On the new architecture, native animated expects event names prefixed with `top` instead of `on`,
21
+ // since we know when the native animated node is the target of the event we can use the different
22
+ // event name where appropriate.
23
+ // TODO: This is a workaround not as solution, but doing this properly would require a total overhaul of
24
+ // how GH sends events (which needs to be done, but maybe wait until the RN's apis stop changing)
25
+ private var useTopPrefixedName: Boolean = false
26
+
19
27
  private fun <T : GestureHandler<T>> init(
20
28
  handler: T,
21
29
  dataExtractor: RNGestureHandlerEventDataExtractor<T>?,
30
+ useNativeAnimatedName: Boolean
22
31
  ) {
23
32
  super.init(handler.view!!.id)
24
33
  extraData = createEventData(handler, dataExtractor)
25
34
  coalescingKey = handler.eventCoalescingKey
35
+ this.useTopPrefixedName = useNativeAnimatedName
26
36
  }
27
37
 
28
38
  override fun onDispose() {
@@ -30,7 +40,7 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
30
40
  EVENTS_POOL.release(this)
31
41
  }
32
42
 
33
- override fun getEventName() = EVENT_NAME
43
+ override fun getEventName() = if (useTopPrefixedName) NATIVE_ANIMATED_EVENT_NAME else EVENT_NAME
34
44
 
35
45
  override fun canCoalesce() = true
36
46
 
@@ -42,15 +52,17 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
42
52
 
43
53
  companion object {
44
54
  const val EVENT_NAME = "onGestureHandlerEvent"
55
+ const val NATIVE_ANIMATED_EVENT_NAME = "topGestureHandlerEvent"
45
56
  private const val TOUCH_EVENTS_POOL_SIZE = 7 // magic
46
57
  private val EVENTS_POOL = Pools.SynchronizedPool<RNGestureHandlerEvent>(TOUCH_EVENTS_POOL_SIZE)
47
58
 
48
59
  fun <T : GestureHandler<T>> obtain(
49
60
  handler: T,
50
61
  dataExtractor: RNGestureHandlerEventDataExtractor<T>?,
62
+ useTopPrefixedName: Boolean = false
51
63
  ): RNGestureHandlerEvent =
52
64
  (EVENTS_POOL.acquire() ?: RNGestureHandlerEvent()).apply {
53
- init(handler, dataExtractor)
65
+ init(handler, dataExtractor, useTopPrefixedName)
54
66
  }
55
67
 
56
68
  fun <T : GestureHandler<T>> createEventData(
@@ -538,7 +538,11 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
538
538
  sendEventForReanimated(event)
539
539
  } else if (handler.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT) {
540
540
  // Animated with useNativeDriver: true
541
- val event = RNGestureHandlerEvent.obtain(handler, handlerFactory)
541
+ val event = RNGestureHandlerEvent.obtain(
542
+ handler,
543
+ handlerFactory,
544
+ useTopPrefixedName = BuildConfig.REACT_NATIVE_MINOR_VERSION >= 71
545
+ )
542
546
  sendEventForNativeAnimatedEvent(event)
543
547
  } else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API) {
544
548
  // JS function, Animated.event with useNativeDriver: false using old API
@@ -3,57 +3,23 @@ cmake_minimum_required(VERSION 3.9.0)
3
3
 
4
4
  set(CMAKE_VERBOSE_MAKEFILE ON)
5
5
  set(CMAKE_CXX_STANDARD 17)
6
- set(CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1")
6
+
7
+ set(REACT_ANDROID_DIR "${REACT_NATIVE_DIR}/ReactAndroid")
8
+
9
+ include(${REACT_ANDROID_DIR}/cmake-utils/folly-flags.cmake)
10
+ add_compile_options(${folly_FLAGS})
7
11
 
8
12
  add_library(gesturehandler
9
13
  SHARED
10
14
  cpp-adapter.cpp
11
15
  )
12
16
 
13
- set(REACT_ANDROID_DIR "${REACT_NATIVE_DIR}/ReactAndroid")
14
- set(REACT_COMMON_DIR "${REACT_NATIVE_DIR}/ReactCommon")
15
- set(REACT_NDK_EXPORT_DIR "${APP_BUILD_DIR}/react-ndk/exported")
16
-
17
- # copied from react-native/ReactAndroid/cmake-utils/Android-prebuilt.cmake
18
-
19
- ## jsi
20
- add_library(jsi SHARED IMPORTED GLOBAL)
21
- set_target_properties(jsi
22
- PROPERTIES
23
- IMPORTED_LOCATION
24
- ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libjsi.so)
25
- target_include_directories(jsi INTERFACE ${REACT_COMMON_DIR}/jsi)
26
-
27
- ## react_render_core
28
- add_library(react_render_core SHARED IMPORTED GLOBAL)
29
- set_target_properties(react_render_core
30
- PROPERTIES
31
- IMPORTED_LOCATION
32
- ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_core.so)
33
- target_include_directories(react_render_core
34
- INTERFACE
35
- ${REACT_COMMON_DIR}
36
- ${REACT_COMMON_DIR}/react/renderer/core)
37
-
38
- ## react_render_uimanager
39
- add_library(react_render_uimanager SHARED IMPORTED GLOBAL)
40
- set_target_properties(react_render_uimanager
41
- PROPERTIES
42
- IMPORTED_LOCATION
43
- ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_uimanager.so)
44
- target_include_directories(react_render_uimanager INTERFACE ${REACT_COMMON_DIR}/react/renderer/uimanager)
45
-
46
- target_include_directories(
47
- gesturehandler
48
- PRIVATE
49
- "${REACT_ANDROID_DIR}/build/third-party-ndk/boost/boost_1_76_0"
50
- "${REACT_ANDROID_DIR}/build/third-party-ndk/double-conversion"
51
- "${REACT_ANDROID_DIR}/build/third-party-ndk/folly"
52
- )
17
+ find_package(ReactAndroid REQUIRED CONFIG)
53
18
 
54
19
  target_link_libraries(
55
20
  gesturehandler
56
- jsi
57
- react_render_uimanager
58
- react_render_core
21
+ ReactAndroid::react_render_core
22
+ ReactAndroid::react_render_uimanager
23
+ ReactAndroid::jsi
24
+ ReactAndroid::react_nativemodule_core
59
25
  )
@@ -6,8 +6,7 @@
6
6
  using namespace facebook;
7
7
  using namespace react;
8
8
 
9
- void decorateRuntime(jsi::Runtime &runtime)
10
- {
9
+ void decorateRuntime(jsi::Runtime &runtime) {
11
10
  auto isFormsStackingContext = jsi::Function::createFromHostFunction(
12
11
  runtime,
13
12
  jsi::PropNameID::forAscii(runtime, "isFormsStackingContext"),
@@ -15,27 +14,31 @@ void decorateRuntime(jsi::Runtime &runtime)
15
14
  [](jsi::Runtime &runtime,
16
15
  const jsi::Value &thisValue,
17
16
  const jsi::Value *arguments,
18
- size_t count) -> jsi::Value
19
- {
20
- if (!arguments[0].isObject())
21
- {
17
+ size_t count) -> jsi::Value {
18
+ if (!arguments[0].isObject()) {
22
19
  return jsi::Value::null();
23
20
  }
24
21
 
25
- auto shadowNode = arguments[0].asObject(runtime).getHostObject<ShadowNodeWrapper>(runtime)->shadowNode;
26
- bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext);
22
+ auto shadowNode = arguments[0]
23
+ .asObject(runtime)
24
+ .getHostObject<ShadowNodeWrapper>(runtime)
25
+ ->shadowNode;
26
+ bool isFormsStackingContext = shadowNode->getTraits().check(
27
+ ShadowNodeTraits::FormsStackingContext);
27
28
 
28
29
  return jsi::Value(isFormsStackingContext);
29
30
  });
30
- runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext));
31
+ runtime.global().setProperty(
32
+ runtime, "isFormsStackingContext", std::move(isFormsStackingContext));
31
33
  }
32
34
 
33
35
  extern "C" JNIEXPORT void JNICALL
34
- Java_com_swmansion_gesturehandler_react_RNGestureHandlerModule_decorateRuntime(JNIEnv *env, jobject clazz, jlong jsiPtr)
35
- {
36
+ Java_com_swmansion_gesturehandler_react_RNGestureHandlerModule_decorateRuntime(
37
+ JNIEnv *env,
38
+ jobject clazz,
39
+ jlong jsiPtr) {
36
40
  jsi::Runtime *runtime = reinterpret_cast<jsi::Runtime *>(jsiPtr);
37
- if (runtime)
38
- {
41
+ if (runtime) {
39
42
  decorateRuntime(*runtime);
40
43
  }
41
44
  }