react-native-reanimated 3.0.0-rc.8 → 3.0.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 (339) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
  3. package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
  4. package/Common/cpp/Fabric/FabricUtils.h +3 -24
  5. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
  7. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
  8. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
  9. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
  15. package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
  16. package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
  17. package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
  18. package/Common/cpp/SharedItems/Shareables.cpp +11 -63
  19. package/Common/cpp/SharedItems/Shareables.h +113 -93
  20. package/Common/cpp/Tools/CollectionUtils.h +14 -0
  21. package/Common/cpp/Tools/JsiUtils.cpp +26 -0
  22. package/Common/cpp/Tools/JsiUtils.h +176 -0
  23. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
  24. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  25. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  26. package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
  27. package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
  28. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
  29. package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
  30. package/RNReanimated.podspec +2 -1
  31. package/android/CMakeLists.txt +188 -181
  32. package/android/build.gradle +362 -311
  33. package/android/proguard-rules.pro +2 -0
  34. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
  35. package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
  36. package/android/src/main/cpp/LayoutAnimations.h +23 -6
  37. package/android/src/main/cpp/NativeProxy.cpp +143 -98
  38. package/android/src/main/cpp/NativeProxy.h +22 -28
  39. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  40. package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
  41. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
  42. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
  43. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
  44. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
  45. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
  46. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
  47. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
  48. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
  49. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
  50. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
  51. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
  52. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
  53. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
  54. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
  55. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
  56. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
  57. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  58. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  59. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  60. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
  61. package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
  63. package/ios/LayoutReanimation/REAFrame.h +10 -0
  64. package/ios/LayoutReanimation/REAFrame.m +15 -0
  65. package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
  66. package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
  67. package/ios/LayoutReanimation/REASharedElement.h +15 -0
  68. package/ios/LayoutReanimation/REASharedElement.m +16 -0
  69. package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
  70. package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
  71. package/ios/LayoutReanimation/REASnapshot.h +1 -0
  72. package/ios/LayoutReanimation/REASnapshot.m +96 -11
  73. package/ios/LayoutReanimation/REAUIManager.mm +67 -60
  74. package/ios/REAModule.mm +2 -7
  75. package/ios/REANodesManager.mm +1 -21
  76. package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
  77. package/ios/native/NativeProxy.mm +75 -114
  78. package/ios/native/REAInitializer.mm +2 -7
  79. package/ios/native/REAJSIUtils.h +60 -2
  80. package/ios/sensor/ReanimatedSensor.h +6 -2
  81. package/ios/sensor/ReanimatedSensor.m +43 -7
  82. package/ios/sensor/ReanimatedSensorContainer.h +4 -1
  83. package/ios/sensor/ReanimatedSensorContainer.m +8 -2
  84. package/lib/commonjs/createAnimatedComponent.js +232 -28
  85. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  86. package/lib/commonjs/reanimated2/Colors.js +43 -22
  87. package/lib/commonjs/reanimated2/Colors.js.map +1 -1
  88. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
  89. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  90. package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
  91. package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
  92. package/lib/commonjs/reanimated2/animation/util.js +17 -15
  93. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  94. package/lib/commonjs/reanimated2/commonTypes.js +33 -1
  95. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  96. package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
  97. package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
  98. package/lib/commonjs/reanimated2/core.js +34 -83
  99. package/lib/commonjs/reanimated2/core.js.map +1 -1
  100. package/lib/commonjs/reanimated2/errors.js +66 -0
  101. package/lib/commonjs/reanimated2/errors.js.map +1 -0
  102. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  103. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  104. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  106. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  108. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  110. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  112. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  114. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
  116. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  118. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  119. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  120. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  121. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  122. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  123. package/lib/commonjs/reanimated2/index.js +13 -0
  124. package/lib/commonjs/reanimated2/index.js.map +1 -1
  125. package/lib/commonjs/reanimated2/initializers.js +196 -0
  126. package/lib/commonjs/reanimated2/initializers.js.map +1 -0
  127. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  128. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  129. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  130. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
  132. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  133. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  134. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  135. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  136. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  137. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  138. package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
  139. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  140. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  141. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  145. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
  147. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  155. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  157. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  158. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  159. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  160. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  161. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  162. package/lib/commonjs/reanimated2/mappers.js +18 -6
  163. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  164. package/lib/commonjs/reanimated2/mock.js +45 -0
  165. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  166. package/lib/commonjs/reanimated2/mutables.js +4 -2
  167. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  168. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  169. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  170. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  171. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  172. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  173. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  174. package/lib/commonjs/reanimated2/shareables.js +38 -11
  175. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  176. package/lib/commonjs/reanimated2/threads.js +114 -4
  177. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  178. package/lib/commonjs/reanimated2/utils.js +7 -0
  179. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  180. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  181. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  182. package/lib/module/createAnimatedComponent.js +229 -29
  183. package/lib/module/createAnimatedComponent.js.map +1 -1
  184. package/lib/module/reanimated2/Colors.js +35 -19
  185. package/lib/module/reanimated2/Colors.js.map +1 -1
  186. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
  187. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  188. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  189. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  190. package/lib/module/reanimated2/animation/util.js +17 -16
  191. package/lib/module/reanimated2/animation/util.js.map +1 -1
  192. package/lib/module/reanimated2/commonTypes.js +29 -0
  193. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  194. package/lib/module/reanimated2/component/FlatList.js +18 -4
  195. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  196. package/lib/module/reanimated2/core.js +30 -76
  197. package/lib/module/reanimated2/core.js.map +1 -1
  198. package/lib/module/reanimated2/errors.js +58 -0
  199. package/lib/module/reanimated2/errors.js.map +1 -0
  200. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  201. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  202. package/lib/module/reanimated2/globals.d.js.map +1 -1
  203. package/lib/module/reanimated2/hook/index.js +1 -1
  204. package/lib/module/reanimated2/hook/index.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  206. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  208. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  210. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  211. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  212. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  213. package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
  214. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  215. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  216. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  217. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  218. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  219. package/lib/module/reanimated2/hook/utils.js +17 -60
  220. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  221. package/lib/module/reanimated2/index.js +1 -0
  222. package/lib/module/reanimated2/index.js.map +1 -1
  223. package/lib/module/reanimated2/initializers.js +182 -0
  224. package/lib/module/reanimated2/initializers.js.map +1 -0
  225. package/lib/module/reanimated2/interpolateColor.js +96 -19
  226. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  227. package/lib/module/reanimated2/jestUtils.js +1 -1
  228. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  229. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
  230. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  231. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  232. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  233. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  234. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  235. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  236. package/lib/module/reanimated2/js-reanimated/global.js +4 -9
  237. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  238. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  239. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  241. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  243. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
  245. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  249. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  251. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  252. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  253. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  254. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  255. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  256. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  257. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  258. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  259. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  260. package/lib/module/reanimated2/mappers.js +16 -6
  261. package/lib/module/reanimated2/mappers.js.map +1 -1
  262. package/lib/module/reanimated2/mock.js +45 -0
  263. package/lib/module/reanimated2/mock.js.map +1 -1
  264. package/lib/module/reanimated2/mutables.js +4 -2
  265. package/lib/module/reanimated2/mutables.js.map +1 -1
  266. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  267. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  268. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  269. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  270. package/lib/module/reanimated2/pluginUtils.js +4 -0
  271. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  272. package/lib/module/reanimated2/shareables.js +38 -9
  273. package/lib/module/reanimated2/shareables.js.map +1 -1
  274. package/lib/module/reanimated2/threads.js +105 -4
  275. package/lib/module/reanimated2/threads.js.map +1 -1
  276. package/lib/module/reanimated2/utils.js +5 -0
  277. package/lib/module/reanimated2/utils.js.map +1 -1
  278. package/lib/module/reanimated2/valueSetter.js +1 -2
  279. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  280. package/package.json +9 -8
  281. package/{plugin.js → plugin/index.js} +173 -228
  282. package/react-native-reanimated.d.ts +57 -10
  283. package/scripts/reanimated_utils.rb +15 -2
  284. package/src/createAnimatedComponent.tsx +238 -28
  285. package/src/reanimated2/Colors.ts +38 -11
  286. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
  287. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  288. package/src/reanimated2/animation/util.ts +29 -16
  289. package/src/reanimated2/commonTypes.ts +28 -1
  290. package/src/reanimated2/component/FlatList.tsx +30 -5
  291. package/src/reanimated2/core.ts +45 -75
  292. package/src/reanimated2/errors.ts +57 -0
  293. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  294. package/src/reanimated2/globals.d.ts +34 -18
  295. package/src/reanimated2/hook/index.ts +1 -1
  296. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  297. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  298. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  299. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  300. package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
  301. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  302. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  303. package/src/reanimated2/hook/utils.ts +15 -61
  304. package/src/reanimated2/index.ts +1 -0
  305. package/src/reanimated2/initializers.ts +184 -0
  306. package/src/reanimated2/interpolateColor.ts +104 -20
  307. package/src/reanimated2/jestUtils.ts +1 -1
  308. package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
  309. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  310. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  311. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  312. package/src/reanimated2/js-reanimated/global.ts +4 -8
  313. package/src/reanimated2/js-reanimated/index.ts +0 -1
  314. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  315. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  316. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
  317. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  318. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  319. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  320. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  321. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  322. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  323. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  324. package/src/reanimated2/mappers.ts +17 -6
  325. package/src/reanimated2/mock.ts +128 -0
  326. package/src/reanimated2/mutables.ts +2 -0
  327. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  328. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  329. package/src/reanimated2/pluginUtils.ts +8 -0
  330. package/src/reanimated2/shareables.ts +47 -11
  331. package/src/reanimated2/threads.ts +103 -1
  332. package/src/reanimated2/utils.ts +6 -0
  333. package/src/reanimated2/valueSetter.ts +1 -2
  334. package/lib/commonjs/reanimated2/time.js +0 -55
  335. package/lib/commonjs/reanimated2/time.js.map +0 -1
  336. package/lib/module/reanimated2/time.js +0 -37
  337. package/lib/module/reanimated2/time.js.map +0 -1
  338. package/src/reanimated2/time.ts +0 -30
  339. /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
@@ -1,4 +1,6 @@
1
1
  #import <RNReanimated/REAAnimationsManager.h>
2
+ #import <RNReanimated/REASharedElement.h>
3
+ #import <RNReanimated/REASharedTransitionManager.h>
2
4
  #import <RNReanimated/REAUIManager.h>
3
5
  #import <React/RCTComponentData.h>
4
6
  #import <React/RCTTextView.h>
@@ -7,7 +9,7 @@
7
9
 
8
10
  typedef NS_ENUM(NSInteger, FrameConfigType) { EnteringFrame, ExitingFrame };
9
11
 
10
- static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
12
+ BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
11
13
  {
12
14
  if (!view.reactTag) {
13
15
  return NO;
@@ -29,14 +31,18 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
29
31
  @implementation REAAnimationsManager {
30
32
  RCTUIManager *_uiManager;
31
33
  REAUIManager *_reaUiManager;
34
+ NSMutableSet<NSNumber *> *_enteringViews;
35
+ NSMutableDictionary<NSNumber *, REASnapshot *> *_enteringViewTargetValues;
32
36
  NSMutableDictionary<NSNumber *, UIView *> *_exitingViews;
33
37
  NSMutableDictionary<NSNumber *, NSNumber *> *_exitingSubviewsCountMap;
38
+ NSMutableDictionary<NSNumber *, NSNumber *> *_exitingParentTags;
34
39
  NSMutableSet<NSNumber *> *_ancestorsToRemove;
35
40
  NSMutableArray<NSString *> *_targetKeys;
36
41
  NSMutableArray<NSString *> *_currentKeys;
37
42
  REAAnimationStartingBlock _startAnimationForTag;
38
43
  REAHasAnimationBlock _hasAnimationForTag;
39
44
  REAAnimationRemovingBlock _clearAnimationConfigForTag;
45
+ REASharedTransitionManager *_sharedTransitionManager;
40
46
  }
41
47
 
42
48
  + (NSArray *)layoutKeys
@@ -57,6 +63,9 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
57
63
  _exitingViews = [NSMutableDictionary new];
58
64
  _exitingSubviewsCountMap = [NSMutableDictionary new];
59
65
  _ancestorsToRemove = [NSMutableSet new];
66
+ _exitingParentTags = [NSMutableDictionary new];
67
+ _enteringViews = [NSMutableSet new];
68
+ _enteringViewTargetValues = [NSMutableDictionary new];
60
69
 
61
70
  _targetKeys = [NSMutableArray new];
62
71
  _currentKeys = [NSMutableArray new];
@@ -64,15 +73,13 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
64
73
  [_targetKeys addObject:[NSString stringWithFormat:@"target%@", [key capitalizedString]]];
65
74
  [_currentKeys addObject:[NSString stringWithFormat:@"current%@", [key capitalizedString]]];
66
75
  }
76
+ _sharedTransitionManager = [[REASharedTransitionManager alloc] initWithAnimationsManager:self];
67
77
  }
68
78
  return self;
69
79
  }
70
80
 
71
81
  - (void)invalidate
72
82
  {
73
- for (NSNumber *tag in [[_exitingViews allKeys] copy]) {
74
- [self endLayoutAnimationForTag:tag cancelled:true removeView:true];
75
- }
76
83
  _startAnimationForTag = nil;
77
84
  _hasAnimationForTag = nil;
78
85
  _uiManager = nil;
@@ -98,20 +105,33 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
98
105
 
99
106
  - (UIView *)viewForTag:(NSNumber *)tag
100
107
  {
101
- UIView *view = [_reaUiManager viewForReactTag:tag];
102
- if (view == nil) {
103
- return [_exitingViews objectForKey:tag];
104
- }
108
+ UIView *view;
109
+ (view = [_reaUiManager viewForReactTag:tag]) || (view = [_exitingViews objectForKey:tag]) ||
110
+ (view = [_sharedTransitionManager getTransitioningView:tag]);
105
111
  return view;
106
112
  }
107
113
 
108
114
  - (void)endLayoutAnimationForTag:(NSNumber *)tag cancelled:(BOOL)cancelled removeView:(BOOL)removeView
109
115
  {
110
- UIView *view = [_exitingViews objectForKey:tag];
111
- if (removeView && view != nil) {
116
+ UIView *view = [self viewForTag:tag];
117
+
118
+ if (view == nil) {
119
+ return;
120
+ }
121
+ if ([_enteringViews containsObject:tag] && !removeView) {
122
+ REASnapshot *target = _enteringViewTargetValues[tag];
123
+ if (target != nil) {
124
+ [self setNewProps:target.values forView:view];
125
+ }
126
+ }
127
+ [_enteringViews removeObject:tag];
128
+ [_enteringViewTargetValues removeObjectForKey:tag];
129
+
130
+ if (removeView) {
112
131
  [self endAnimationsRecursive:view];
113
132
  [view removeFromSuperview];
114
133
  }
134
+ [_sharedTransitionManager finishSharedAnimation:[self viewForTag:tag]];
115
135
  }
116
136
 
117
137
  - (void)endAnimationsRecursive:(UIView *)view
@@ -136,11 +156,11 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
136
156
  }
137
157
  }
138
158
 
139
- - (void)progressLayoutAnimationWithStyle:(NSDictionary *)newStyle forTag:(NSNumber *)tag
159
+ - (void)progressLayoutAnimationWithStyle:(NSDictionary *)newStyle
160
+ forTag:(NSNumber *)tag
161
+ isSharedTransition:(BOOL)isSharedTransition
140
162
  {
141
- NSMutableDictionary *dataComponenetsByName = [_uiManager valueForKey:@"_componentDataByName"];
142
- RCTComponentData *componentData = dataComponenetsByName[@"RCTView"];
143
- [self setNewProps:[newStyle mutableCopy] forView:[self viewForTag:tag] withComponentData:componentData];
163
+ [self setNewProps:[newStyle mutableCopy] forView:[self viewForTag:tag] convertFromAbsolute:isSharedTransition];
144
164
  }
145
165
 
146
166
  - (double)getDoubleOrZero:(NSNumber *)number
@@ -152,9 +172,12 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
152
172
  return doubleValue;
153
173
  }
154
174
 
155
- - (void)setNewProps:(NSMutableDictionary *)newProps
156
- forView:(UIView *)view
157
- withComponentData:(RCTComponentData *)componentData
175
+ - (void)setNewProps:(NSMutableDictionary *)newProps forView:(UIView *)view
176
+ {
177
+ [self setNewProps:newProps forView:view convertFromAbsolute:NO];
178
+ }
179
+
180
+ - (void)setNewProps:(NSMutableDictionary *)newProps forView:(UIView *)view convertFromAbsolute:(BOOL)convertFromAbsolute
158
181
  {
159
182
  if (newProps[@"height"]) {
160
183
  double height = [self getDoubleOrZero:newProps[@"height"]];
@@ -170,22 +193,52 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
170
193
  view.center = CGPointMake(view.center.x + view.bounds.size.width / 2.0 - oldWidth / 2.0, view.center.y);
171
194
  [newProps removeObjectForKey:@"width"];
172
195
  }
196
+
197
+ bool needsViewPositionUpdate = false;
198
+ double centerX = view.center.x;
199
+ double centerY = view.center.y;
173
200
  if (newProps[@"originX"]) {
201
+ needsViewPositionUpdate = true;
174
202
  double originX = [self getDoubleOrZero:newProps[@"originX"]];
175
- view.center = CGPointMake(originX + view.bounds.size.width / 2.0, view.center.y);
176
203
  [newProps removeObjectForKey:@"originX"];
204
+ centerX = originX + view.bounds.size.width / 2.0;
177
205
  }
178
206
  if (newProps[@"originY"]) {
207
+ needsViewPositionUpdate = true;
179
208
  double originY = [self getDoubleOrZero:newProps[@"originY"]];
180
- view.center = CGPointMake(view.center.x, originY + view.bounds.size.height / 2.0);
181
209
  [newProps removeObjectForKey:@"originY"];
210
+ centerY = originY + view.bounds.size.height / 2.0;
211
+ }
212
+ if (needsViewPositionUpdate) {
213
+ CGPoint newCenter = CGPointMake(centerX, centerY);
214
+ if (convertFromAbsolute) {
215
+ UIView *window = UIApplication.sharedApplication.keyWindow;
216
+ CGPoint convertedCenter = [window convertPoint:newCenter toView:view.superview];
217
+ view.center = convertedCenter;
218
+ } else {
219
+ view.center = newCenter;
220
+ }
182
221
  }
222
+
223
+ if (newProps[@"transformMatrix"]) {
224
+ NSArray *matrix = newProps[@"transformMatrix"];
225
+ CGFloat a = [matrix[0] floatValue];
226
+ CGFloat b = [matrix[1] floatValue];
227
+ CGFloat c = [matrix[3] floatValue];
228
+ CGFloat d = [matrix[4] floatValue];
229
+ CGFloat tx = [matrix[6] floatValue];
230
+ CGFloat ty = [matrix[7] floatValue];
231
+ view.transform = CGAffineTransformMake(a, b, c, d, tx, ty);
232
+ [newProps removeObjectForKey:@"transformMatrix"];
233
+ }
234
+
235
+ NSMutableDictionary *componentDataByName = [_uiManager valueForKey:@"_componentDataByName"];
236
+ RCTComponentData *componentData = componentDataByName[@"RCTView"];
183
237
  [componentData setProps:newProps forView:view];
184
238
  }
185
239
 
186
240
  - (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values frameConfig:(FrameConfigType)frameConfig
187
241
  {
188
- UIView *windowView = UIApplication.sharedApplication.keyWindow;
189
242
  if (frameConfig == EnteringFrame) {
190
243
  NSDictionary *preparedData = @{
191
244
  @"targetWidth" : values[@"width"],
@@ -194,8 +247,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
194
247
  @"targetOriginY" : values[@"originY"],
195
248
  @"targetGlobalOriginX" : values[@"globalOriginX"],
196
249
  @"targetGlobalOriginY" : values[@"globalOriginY"],
197
- @"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
198
- @"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
250
+ @"windowWidth" : values[@"windowWidth"],
251
+ @"windowHeight" : values[@"windowHeight"]
199
252
  };
200
253
  return preparedData;
201
254
  } else {
@@ -206,8 +259,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
206
259
  @"currentOriginY" : values[@"originY"],
207
260
  @"currentGlobalOriginX" : values[@"globalOriginX"],
208
261
  @"currentGlobalOriginY" : values[@"globalOriginY"],
209
- @"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
210
- @"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
262
+ @"windowWidth" : values[@"windowWidth"],
263
+ @"windowHeight" : values[@"windowHeight"]
211
264
  };
212
265
  return preparedData;
213
266
  }
@@ -216,23 +269,25 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
216
269
  - (NSDictionary *)prepareDataForLayoutAnimatingWorklet:(NSMutableDictionary *)currentValues
217
270
  targetValues:(NSMutableDictionary *)targetValues
218
271
  {
219
- UIView *windowView = UIApplication.sharedApplication.keyWindow;
220
- NSDictionary *preparedData = @{
221
- @"currentWidth" : currentValues[@"width"],
222
- @"currentHeight" : currentValues[@"height"],
223
- @"currentOriginX" : currentValues[@"originX"],
224
- @"currentOriginY" : currentValues[@"originY"],
225
- @"currentGlobalOriginX" : currentValues[@"globalOriginX"],
226
- @"currentGlobalOriginY" : currentValues[@"globalOriginY"],
227
- @"targetWidth" : targetValues[@"width"],
228
- @"targetHeight" : targetValues[@"height"],
229
- @"targetOriginX" : targetValues[@"originX"],
230
- @"targetOriginY" : targetValues[@"originY"],
231
- @"targetGlobalOriginX" : targetValues[@"globalOriginX"],
232
- @"targetGlobalOriginY" : targetValues[@"globalOriginY"],
233
- @"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
234
- @"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
235
- };
272
+ NSMutableDictionary *preparedData = [NSMutableDictionary new];
273
+ preparedData[@"currentWidth"] = currentValues[@"width"];
274
+ preparedData[@"currentHeight"] = currentValues[@"height"];
275
+ preparedData[@"currentOriginX"] = currentValues[@"originX"];
276
+ preparedData[@"currentOriginY"] = currentValues[@"originY"];
277
+ preparedData[@"currentGlobalOriginX"] = currentValues[@"globalOriginX"];
278
+ preparedData[@"currentGlobalOriginY"] = currentValues[@"globalOriginY"];
279
+ preparedData[@"targetWidth"] = targetValues[@"width"];
280
+ preparedData[@"targetHeight"] = targetValues[@"height"];
281
+ preparedData[@"targetOriginX"] = targetValues[@"originX"];
282
+ preparedData[@"targetOriginY"] = targetValues[@"originY"];
283
+ preparedData[@"targetGlobalOriginX"] = targetValues[@"globalOriginX"];
284
+ preparedData[@"targetGlobalOriginY"] = targetValues[@"globalOriginY"];
285
+ preparedData[@"windowWidth"] = currentValues[@"windowWidth"];
286
+ preparedData[@"windowHeight"] = currentValues[@"windowHeight"];
287
+ if (currentValues[@"transformMatrix"] != nil && targetValues[@"transformMatrix"] != nil) {
288
+ preparedData[@"currentTransformMatrix"] = currentValues[@"transformMatrix"];
289
+ preparedData[@"targetTransformMatrix"] = targetValues[@"transformMatrix"];
290
+ }
236
291
  return preparedData;
237
292
  }
238
293
 
@@ -240,16 +295,33 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
240
295
  {
241
296
  return REANodeFind(view, ^(id<RCTComponent> view) {
242
297
  return [self->_exitingSubviewsCountMap objectForKey:view.reactTag] != nil ||
243
- self->_hasAnimationForTag(view.reactTag, @"exiting");
298
+ self->_hasAnimationForTag(view.reactTag, EXITING);
244
299
  });
245
300
  }
246
301
 
247
302
  - (void)registerExitingAncestors:(UIView *)child
248
303
  {
304
+ [self registerExitingAncestors:child exitingSubviewsCount:1];
305
+ }
306
+
307
+ - (void)registerExitingAncestors:(UIView *)child exitingSubviewsCount:(int)exitingSubviewsCount
308
+ {
309
+ NSNumber *childTag = child.reactTag;
249
310
  UIView *parent = child.superview;
250
- while (parent != nil && ![parent isKindOfClass:[RCTRootView class]]) {
251
- if (parent.reactTag != nil) {
252
- _exitingSubviewsCountMap[parent.reactTag] = @([_exitingSubviewsCountMap[parent.reactTag] intValue] + 1);
311
+
312
+ UIViewController *childController = child.reactViewController;
313
+
314
+ // only register ancestors whose `reactViewController` is the same as `child`'s.
315
+ // The idea is that, if a whole ViewController is unmounted, we won't want to run
316
+ // the exiting animation since all the views will disappear immediately anyway
317
+ while (parent != nil && parent.reactViewController == childController &&
318
+ ![parent isKindOfClass:[RCTRootView class]]) {
319
+ NSNumber *parentTag = parent.reactTag;
320
+ if (parentTag != nil) {
321
+ _exitingSubviewsCountMap[parent.reactTag] =
322
+ @([_exitingSubviewsCountMap[parent.reactTag] intValue] + exitingSubviewsCount);
323
+ _exitingParentTags[childTag] = parentTag;
324
+ childTag = parentTag;
253
325
  }
254
326
  parent = parent.superview;
255
327
  }
@@ -258,12 +330,37 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
258
330
  - (void)maybeDropAncestors:(UIView *)child
259
331
  {
260
332
  UIView *parent = child.superview;
261
- while (parent != nil && ![parent isKindOfClass:[RCTRootView class]]) {
333
+ NSNumber *parentTag = _exitingParentTags[child.reactTag];
334
+ [_exitingParentTags removeObjectForKey:child.reactTag];
335
+
336
+ while ((parent != nil || parentTag != nil) && ![parent isKindOfClass:[RCTRootView class]]) {
262
337
  UIView *view = parent;
338
+ NSNumber *viewTag = parentTag;
339
+ parentTag = _exitingParentTags[viewTag];
340
+ UIView *viewByTag = [self viewForTag:viewTag];
263
341
  parent = view.superview;
342
+
343
+ if (view == nil) {
344
+ if (viewByTag == nil) {
345
+ // the view was already removed from both native and RN hierarchies
346
+ // we can safely forget that it had any animated children
347
+ [_ancestorsToRemove removeObject:viewTag];
348
+ [_exitingSubviewsCountMap removeObjectForKey:viewTag];
349
+ [_exitingParentTags removeObjectForKey:viewTag];
350
+ continue;
351
+ }
352
+ // the child was dettached from view, but view is still
353
+ // in the native and RN hierarchy
354
+ view = viewByTag;
355
+ }
356
+
264
357
  if (view.reactTag == nil) {
358
+ // we skip over views with no tag when registering parent tags,
359
+ // so we shouldn't go to the parent of viewTag yet
360
+ parentTag = viewTag;
265
361
  continue;
266
362
  }
363
+
267
364
  int trackingCount = [_exitingSubviewsCountMap[view.reactTag] intValue] - 1;
268
365
  if (trackingCount <= 0) {
269
366
  if ([_ancestorsToRemove containsObject:view.reactTag]) {
@@ -273,26 +370,42 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
273
370
  }
274
371
  }
275
372
  [_exitingSubviewsCountMap removeObjectForKey:view.reactTag];
373
+ [_exitingParentTags removeObjectForKey:view.reactTag];
276
374
  } else {
277
375
  _exitingSubviewsCountMap[view.reactTag] = @(trackingCount);
278
376
  }
279
377
  }
280
378
  }
281
379
 
282
- - (BOOL)removeRecursive:(UIView *)view fromContainer:(UIView *)container withoutAnimation:(BOOL)removeImmediately;
380
+ - (BOOL)startAnimationsRecursive:(UIView *)view
381
+ shouldRemoveSubviewsWithoutAnimations:(BOOL)shouldRemoveSubviewsWithoutAnimations;
283
382
  {
284
383
  if (!view.reactTag) {
285
384
  return NO;
286
385
  }
287
- BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, @"exiting") || [_exitingViews objectForKey:view.reactTag];
386
+
387
+ UIViewController *viewController = view.reactViewController;
388
+
389
+ // `startAnimationsRecursive:shouldRemoveSubviewsWithoutAnimations:`
390
+ // is called on a detached view tree, so the `viewController` should be `nil`.
391
+ // If it's not, we're descending into another `UIViewController`.
392
+ // We don't want to run animations inside it (since it causes issues with RNScreens),
393
+ // so instead clean up the subtree and return `NO`.
394
+ if (viewController != nil) {
395
+ [self removeAnimationsFromSubtree:view];
396
+ return NO;
397
+ }
398
+
399
+ BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, EXITING) || [_exitingViews objectForKey:view.reactTag];
288
400
  BOOL hasAnimatedChildren = NO;
289
- removeImmediately = removeImmediately && !hasExitAnimation;
401
+ shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
290
402
  NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init];
291
403
 
292
404
  for (UIView *subview in [view.reactSubviews copy]) {
293
- if ([self removeRecursive:subview fromContainer:view withoutAnimation:removeImmediately]) {
405
+ if ([self startAnimationsRecursive:subview
406
+ shouldRemoveSubviewsWithoutAnimations:shouldRemoveSubviewsWithoutAnimations]) {
294
407
  hasAnimatedChildren = YES;
295
- } else if (removeImmediately) {
408
+ } else if (shouldRemoveSubviewsWithoutAnimations) {
296
409
  [toBeRemoved addObject:subview];
297
410
  }
298
411
  }
@@ -307,19 +420,13 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
307
420
  if (hasExitAnimation) {
308
421
  before = [[REASnapshot alloc] init:view];
309
422
  }
310
- // start exit animation
311
- UIView *originalSuperview = view.superview;
312
- NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:view];
313
- [container removeReactSubview:view];
314
- // we don't want user interaction on exiting views
315
- view.userInteractionEnabled = NO;
316
- [originalSuperview insertSubview:view atIndex:originalIndex];
317
423
 
424
+ // start exit animation
318
425
  if (hasExitAnimation && ![_exitingViews objectForKey:view.reactTag]) {
319
426
  NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:before.values frameConfig:ExitingFrame];
320
427
  [_exitingViews setObject:view forKey:view.reactTag];
321
428
  [self registerExitingAncestors:view];
322
- _startAnimationForTag(view.reactTag, @"exiting", preparedValues, @(0));
429
+ _startAnimationForTag(view.reactTag, EXITING, preparedValues, @(0));
323
430
  }
324
431
 
325
432
  if (hasAnimatedChildren) {
@@ -335,14 +442,45 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
335
442
  // start new animations for it, and might as well remove
336
443
  // the layout animation config now
337
444
  _clearAnimationConfigForTag(view.reactTag);
445
+
446
+ // we don't want user interaction on exiting views
447
+ view.userInteractionEnabled = NO;
448
+
338
449
  return YES;
339
450
  }
340
451
 
341
- - (void)removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container
452
+ - (void)reattachAnimatedChildren:(NSArray<id<RCTComponent>> *)children
453
+ toContainer:(id<RCTComponent>)container
454
+ atIndices:(NSArray<NSNumber *> *)indices
342
455
  {
343
- for (UIView *removedChild in children) {
344
- if (![self removeRecursive:removedChild fromContainer:container withoutAnimation:true]) {
345
- [removedChild removeFromSuperview];
456
+ if (![container isKindOfClass:[UIView class]]) {
457
+ return;
458
+ }
459
+
460
+ // since we reattach only some of the views,
461
+ // we count the views we DIDN'T reattach
462
+ // and shift later views' indices by that number
463
+ // to make sure they appear at correct relative posisitons
464
+ // in the `subviews` array
465
+ int skippedViewsCount = 0;
466
+
467
+ for (int i = 0; i < children.count; i++) {
468
+ id<RCTComponent> child = children[i];
469
+ if (![child isKindOfClass:[UIView class]]) {
470
+ skippedViewsCount++;
471
+ continue;
472
+ }
473
+ UIView *childView = (UIView *)child;
474
+ NSNumber *originalIndex = indices[i];
475
+ if ([self startAnimationsRecursive:childView shouldRemoveSubviewsWithoutAnimations:YES]) {
476
+ [(UIView *)container insertSubview:childView atIndex:[originalIndex intValue] - skippedViewsCount];
477
+ int exitingSubviewsCount = [_exitingSubviewsCountMap[childView.reactTag] intValue];
478
+ if ([_exitingViews objectForKey:childView.reactTag] != nil) {
479
+ exitingSubviewsCount++;
480
+ }
481
+ [self registerExitingAncestors:childView exitingSubviewsCount:exitingSubviewsCount];
482
+ } else {
483
+ skippedViewsCount++;
346
484
  }
347
485
  }
348
486
  }
@@ -351,7 +489,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
351
489
  {
352
490
  NSMutableDictionary *targetValues = after.values;
353
491
  NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
354
- _startAnimationForTag(view.reactTag, @"entering", preparedValues, @(0));
492
+ [_enteringViews addObject:view.reactTag];
493
+ _startAnimationForTag(view.reactTag, ENTERING, preparedValues, @(0));
355
494
  }
356
495
 
357
496
  - (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after
@@ -360,36 +499,85 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
360
499
  NSMutableDictionary *currentValues = before.values;
361
500
 
362
501
  NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
363
- _startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
502
+ _startAnimationForTag(view.reactTag, LAYOUT, preparedValues, @(0));
364
503
  }
365
504
 
366
505
  - (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view
367
506
  {
368
- if (_hasAnimationForTag(view.reactTag, @"layout")) {
369
- return [[REASnapshot alloc] init:view];
370
- }
371
- return nil;
507
+ return [[REASnapshot alloc] init:view];
372
508
  }
373
509
 
374
- - (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)before
510
+ - (void)removeAnimationsFromSubtree:(UIView *)view
375
511
  {
376
- NSString *type = before == nil ? @"entering" : @"layout";
377
- if (_hasAnimationForTag(view.reactTag, type)) {
512
+ REANodeFind(view, ^int(id<RCTComponent> view) {
513
+ if (!self->_hasAnimationForTag(view.reactTag, SHARED_ELEMENT_TRANSITION)) {
514
+ self->_clearAnimationConfigForTag(view.reactTag);
515
+ }
516
+ return false;
517
+ });
518
+ }
519
+
520
+ - (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)before withNewFrame:(CGRect)frame
521
+ {
522
+ LayoutAnimationType type = before == nil ? ENTERING : LAYOUT;
523
+ NSNumber *viewTag = view.reactTag;
524
+ if (_hasAnimationForTag(viewTag, type)) {
378
525
  REASnapshot *after = [[REASnapshot alloc] init:view];
379
526
  if (before == nil) {
380
527
  [self onViewCreate:view after:after];
381
528
  } else {
382
529
  [self onViewUpdate:view before:before after:after];
383
530
  }
531
+ } else if (type == LAYOUT && [_enteringViews containsObject:[view reactTag]]) {
532
+ _enteringViewTargetValues[[view reactTag]] = [[REASnapshot alloc] init:view];
533
+ [self setNewProps:before.values forView:view];
534
+ }
535
+
536
+ if (_hasAnimationForTag(viewTag, SHARED_ELEMENT_TRANSITION)) {
537
+ if (type == ENTERING) {
538
+ [_sharedTransitionManager notifyAboutNewView:view];
539
+ } else {
540
+ [_sharedTransitionManager notifyAboutViewLayout:view withViewFrame:frame];
541
+ }
384
542
  }
385
543
  }
386
544
 
387
- - (void)removeAnimationsFromSubtree:(UIView *)view
545
+ - (void)viewsDidLayout
388
546
  {
389
- REANodeFind(view, ^int(id<RCTComponent> view) {
390
- self->_clearAnimationConfigForTag(view.reactTag);
391
- return false;
392
- });
547
+ [_sharedTransitionManager viewsDidLayout];
548
+ }
549
+
550
+ - (void)setFindPrecedingViewTagForTransitionBlock:
551
+ (REAFindPrecedingViewTagForTransitionBlock)findPrecedingViewTagForTransition
552
+ {
553
+ [_sharedTransitionManager setFindPrecedingViewTagForTransitionBlock:findPrecedingViewTagForTransition];
554
+ }
555
+
556
+ - (void)setCancelAnimationBlock:(REACancelAnimationBlock)animationCancellingBlock
557
+ {
558
+ [_sharedTransitionManager setCancelAnimationBlock:animationCancellingBlock];
559
+ }
560
+
561
+ - (BOOL)hasAnimationForTag:(NSNumber *)tag type:(LayoutAnimationType)type
562
+ {
563
+ if (!_hasAnimationForTag) {
564
+ // It can happen during reload.
565
+ return NO;
566
+ }
567
+ return _hasAnimationForTag(tag, type);
568
+ }
569
+
570
+ - (void)clearAnimationConfigForTag:(NSNumber *)tag
571
+ {
572
+ _clearAnimationConfigForTag(tag);
573
+ }
574
+
575
+ - (void)startAnimationForTag:(NSNumber *)tag
576
+ type:(LayoutAnimationType)type
577
+ yogaValues:(NSDictionary *)yogaValues
578
+ depth:(NSNumber *)depth;
579
+ {
580
+ _startAnimationForTag(tag, type, yogaValues, depth);
393
581
  }
394
582
 
395
583
  @end
@@ -0,0 +1,10 @@
1
+ @interface REAFrame : NSObject
2
+
3
+ @property float x;
4
+ @property float y;
5
+ @property float width;
6
+ @property float height;
7
+
8
+ - (instancetype)initWithX:(float)x y:(float)y width:(float)width height:(float)height;
9
+
10
+ @end
@@ -0,0 +1,15 @@
1
+ #import <RNReanimated/REAFrame.h>
2
+
3
+ @implementation REAFrame
4
+
5
+ - (instancetype)initWithX:(float)x y:(float)y width:(float)width height:(float)height
6
+ {
7
+ self = [super init];
8
+ _x = x;
9
+ _y = y;
10
+ _width = width;
11
+ _height = height;
12
+ return self;
13
+ }
14
+
15
+ @end
@@ -0,0 +1,19 @@
1
+ #define LOAD_SCREENS_HEADERS \
2
+ ((!RCT_NEW_ARCH_ENABLED && __has_include(<RNScreens/RNSScreen.h>)) \
3
+ || (RCT_NEW_ARCH_ENABLED && __has_include(<RNScreens/RNSScreen.h>) && __cplusplus))
4
+
5
+ #if LOAD_SCREENS_HEADERS
6
+ #import <RNScreens/RNSScreen.h>
7
+ #import <RNScreens/RNSScreenStack.h>
8
+ #endif
9
+
10
+ @interface REAScreensHelper : NSObject
11
+
12
+ + (UIView *)getScreenForView:(UIView *)view;
13
+ + (UIView *)getStackForView:(UIView *)view;
14
+ + (bool)isScreenModal:(UIView *)screen;
15
+ + (UIView *)getScreenWrapper:(UIView *)view;
16
+ + (int)getScreenType:(UIView *)screen;
17
+ + (bool)isRNSScreenType:(UIView *)screen;
18
+
19
+ @end