react-native-reanimated 3.0.0-rc.9 → 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 (329) 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 +105 -109
  10. package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
  11. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
  12. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
  13. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
  14. package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
  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 +9 -63
  19. package/Common/cpp/SharedItems/Shareables.h +77 -72
  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 +49 -230
  27. package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
  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 +28 -4
  62. package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
  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 +64 -17
  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 +16 -33
  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/core.js +33 -14
  97. package/lib/commonjs/reanimated2/core.js.map +1 -1
  98. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  99. package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  100. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  101. package/lib/commonjs/reanimated2/hook/index.js +0 -6
  102. package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
  103. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  104. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  105. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
  106. package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  107. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
  108. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  109. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
  110. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  111. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
  112. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  113. package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
  114. package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
  115. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
  116. package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  117. package/lib/commonjs/reanimated2/hook/utils.js +18 -65
  118. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  119. package/lib/commonjs/reanimated2/index.js +13 -0
  120. package/lib/commonjs/reanimated2/index.js.map +1 -1
  121. package/lib/commonjs/reanimated2/initializers.js +71 -32
  122. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  123. package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
  124. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  125. package/lib/commonjs/reanimated2/jestUtils.js +1 -1
  126. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  127. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
  128. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  129. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
  130. package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
  131. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
  132. package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  133. package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  134. package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
  135. package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
  136. package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
  137. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  138. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
  139. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  140. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
  141. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  142. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
  143. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  144. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
  145. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  146. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
  147. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  148. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
  149. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  150. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
  151. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  152. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
  153. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  154. package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
  155. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  156. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
  157. package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  158. package/lib/commonjs/reanimated2/mappers.js +18 -6
  159. package/lib/commonjs/reanimated2/mappers.js.map +1 -1
  160. package/lib/commonjs/reanimated2/mock.js +20 -1
  161. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  162. package/lib/commonjs/reanimated2/mutables.js +4 -2
  163. package/lib/commonjs/reanimated2/mutables.js.map +1 -1
  164. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
  165. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
  166. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
  167. package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  168. package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
  169. package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
  170. package/lib/commonjs/reanimated2/shareables.js +36 -15
  171. package/lib/commonjs/reanimated2/shareables.js.map +1 -1
  172. package/lib/commonjs/reanimated2/threads.js +114 -4
  173. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  174. package/lib/commonjs/reanimated2/utils.js +7 -0
  175. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  176. package/lib/commonjs/reanimated2/valueSetter.js +1 -3
  177. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
  178. package/lib/module/createAnimatedComponent.js +229 -29
  179. package/lib/module/createAnimatedComponent.js.map +1 -1
  180. package/lib/module/reanimated2/Colors.js +35 -19
  181. package/lib/module/reanimated2/Colors.js.map +1 -1
  182. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
  183. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  184. package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
  185. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  186. package/lib/module/reanimated2/animation/util.js +17 -16
  187. package/lib/module/reanimated2/animation/util.js.map +1 -1
  188. package/lib/module/reanimated2/commonTypes.js +29 -0
  189. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  190. package/lib/module/reanimated2/core.js +32 -7
  191. package/lib/module/reanimated2/core.js.map +1 -1
  192. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
  193. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  194. package/lib/module/reanimated2/globals.d.js.map +1 -1
  195. package/lib/module/reanimated2/hook/index.js +1 -1
  196. package/lib/module/reanimated2/hook/index.js.map +1 -1
  197. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
  198. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  199. package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
  200. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  201. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  202. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  203. package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
  204. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  205. package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
  206. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  207. package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
  208. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  209. package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
  210. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  211. package/lib/module/reanimated2/hook/utils.js +17 -60
  212. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  213. package/lib/module/reanimated2/index.js +1 -0
  214. package/lib/module/reanimated2/index.js.map +1 -1
  215. package/lib/module/reanimated2/initializers.js +72 -33
  216. package/lib/module/reanimated2/initializers.js.map +1 -1
  217. package/lib/module/reanimated2/interpolateColor.js +96 -19
  218. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  219. package/lib/module/reanimated2/jestUtils.js +1 -1
  220. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  221. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
  222. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  223. package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
  224. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
  225. package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
  226. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
  227. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  228. package/lib/module/reanimated2/js-reanimated/global.js +0 -2
  229. package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
  230. package/lib/module/reanimated2/js-reanimated/index.js +0 -1
  231. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  232. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
  233. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  234. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
  235. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  236. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
  237. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  238. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
  239. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  240. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
  241. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  242. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  243. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  244. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
  245. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  246. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
  247. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  248. package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
  249. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  250. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
  251. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
  252. package/lib/module/reanimated2/mappers.js +16 -6
  253. package/lib/module/reanimated2/mappers.js.map +1 -1
  254. package/lib/module/reanimated2/mock.js +20 -1
  255. package/lib/module/reanimated2/mock.js.map +1 -1
  256. package/lib/module/reanimated2/mutables.js +4 -2
  257. package/lib/module/reanimated2/mutables.js.map +1 -1
  258. package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
  259. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
  260. package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
  261. package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
  262. package/lib/module/reanimated2/pluginUtils.js +4 -0
  263. package/lib/module/reanimated2/pluginUtils.js.map +1 -0
  264. package/lib/module/reanimated2/shareables.js +36 -12
  265. package/lib/module/reanimated2/shareables.js.map +1 -1
  266. package/lib/module/reanimated2/threads.js +105 -4
  267. package/lib/module/reanimated2/threads.js.map +1 -1
  268. package/lib/module/reanimated2/utils.js +5 -0
  269. package/lib/module/reanimated2/utils.js.map +1 -1
  270. package/lib/module/reanimated2/valueSetter.js +1 -2
  271. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  272. package/package.json +10 -10
  273. package/{plugin.js → plugin/index.js} +128 -249
  274. package/react-native-reanimated.d.ts +57 -10
  275. package/scripts/reanimated_utils.rb +15 -2
  276. package/src/createAnimatedComponent.tsx +238 -28
  277. package/src/reanimated2/Colors.ts +38 -11
  278. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
  279. package/src/reanimated2/animation/styleAnimation.ts +8 -1
  280. package/src/reanimated2/animation/util.ts +29 -16
  281. package/src/reanimated2/commonTypes.ts +28 -1
  282. package/src/reanimated2/core.ts +42 -9
  283. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
  284. package/src/reanimated2/globals.d.ts +12 -15
  285. package/src/reanimated2/hook/index.ts +1 -1
  286. package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
  287. package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
  288. package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
  289. package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
  290. package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
  291. package/src/reanimated2/hook/useDerivedValue.ts +8 -1
  292. package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
  293. package/src/reanimated2/hook/utils.ts +15 -61
  294. package/src/reanimated2/index.ts +1 -0
  295. package/src/reanimated2/initializers.ts +76 -35
  296. package/src/reanimated2/interpolateColor.ts +104 -20
  297. package/src/reanimated2/jestUtils.ts +1 -1
  298. package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
  299. package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
  300. package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
  301. package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
  302. package/src/reanimated2/js-reanimated/global.ts +0 -1
  303. package/src/reanimated2/js-reanimated/index.ts +0 -1
  304. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
  305. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  306. package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
  307. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  308. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  309. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  310. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  311. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  312. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  313. package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
  314. package/src/reanimated2/mappers.ts +17 -6
  315. package/src/reanimated2/mock.ts +24 -1
  316. package/src/reanimated2/mutables.ts +2 -0
  317. package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
  318. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  319. package/src/reanimated2/pluginUtils.ts +8 -0
  320. package/src/reanimated2/shareables.ts +45 -16
  321. package/src/reanimated2/threads.ts +103 -1
  322. package/src/reanimated2/utils.ts +6 -0
  323. package/src/reanimated2/valueSetter.ts +1 -2
  324. package/lib/commonjs/reanimated2/time.js +0 -55
  325. package/lib/commonjs/reanimated2/time.js.map +0 -1
  326. package/lib/module/reanimated2/time.js +0 -37
  327. package/lib/module/reanimated2/time.js.map +0 -1
  328. package/src/reanimated2/time.ts +0 -30
  329. /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,7 +295,7 @@ 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
 
@@ -251,11 +306,22 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
251
306
 
252
307
  - (void)registerExitingAncestors:(UIView *)child exitingSubviewsCount:(int)exitingSubviewsCount
253
308
  {
309
+ NSNumber *childTag = child.reactTag;
254
310
  UIView *parent = child.superview;
255
- while (parent != nil && ![parent isKindOfClass:[RCTRootView class]]) {
256
- if (parent.reactTag != nil) {
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) {
257
321
  _exitingSubviewsCountMap[parent.reactTag] =
258
322
  @([_exitingSubviewsCountMap[parent.reactTag] intValue] + exitingSubviewsCount);
323
+ _exitingParentTags[childTag] = parentTag;
324
+ childTag = parentTag;
259
325
  }
260
326
  parent = parent.superview;
261
327
  }
@@ -264,12 +330,37 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
264
330
  - (void)maybeDropAncestors:(UIView *)child
265
331
  {
266
332
  UIView *parent = child.superview;
267
- 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]]) {
268
337
  UIView *view = parent;
338
+ NSNumber *viewTag = parentTag;
339
+ parentTag = _exitingParentTags[viewTag];
340
+ UIView *viewByTag = [self viewForTag:viewTag];
269
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
+
270
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;
271
361
  continue;
272
362
  }
363
+
273
364
  int trackingCount = [_exitingSubviewsCountMap[view.reactTag] intValue] - 1;
274
365
  if (trackingCount <= 0) {
275
366
  if ([_ancestorsToRemove containsObject:view.reactTag]) {
@@ -279,6 +370,7 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
279
370
  }
280
371
  }
281
372
  [_exitingSubviewsCountMap removeObjectForKey:view.reactTag];
373
+ [_exitingParentTags removeObjectForKey:view.reactTag];
282
374
  } else {
283
375
  _exitingSubviewsCountMap[view.reactTag] = @(trackingCount);
284
376
  }
@@ -291,7 +383,20 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
291
383
  if (!view.reactTag) {
292
384
  return NO;
293
385
  }
294
- 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];
295
400
  BOOL hasAnimatedChildren = NO;
296
401
  shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
297
402
  NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init];
@@ -321,7 +426,7 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
321
426
  NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:before.values frameConfig:ExitingFrame];
322
427
  [_exitingViews setObject:view forKey:view.reactTag];
323
428
  [self registerExitingAncestors:view];
324
- _startAnimationForTag(view.reactTag, @"exiting", preparedValues, @(0));
429
+ _startAnimationForTag(view.reactTag, EXITING, preparedValues, @(0));
325
430
  }
326
431
 
327
432
  if (hasAnimatedChildren) {
@@ -384,7 +489,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
384
489
  {
385
490
  NSMutableDictionary *targetValues = after.values;
386
491
  NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
387
- _startAnimationForTag(view.reactTag, @"entering", preparedValues, @(0));
492
+ [_enteringViews addObject:view.reactTag];
493
+ _startAnimationForTag(view.reactTag, ENTERING, preparedValues, @(0));
388
494
  }
389
495
 
390
496
  - (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after
@@ -393,36 +499,85 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
393
499
  NSMutableDictionary *currentValues = before.values;
394
500
 
395
501
  NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
396
- _startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
502
+ _startAnimationForTag(view.reactTag, LAYOUT, preparedValues, @(0));
397
503
  }
398
504
 
399
505
  - (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view
400
506
  {
401
- if (_hasAnimationForTag(view.reactTag, @"layout")) {
402
- return [[REASnapshot alloc] init:view];
403
- }
404
- return nil;
507
+ return [[REASnapshot alloc] init:view];
508
+ }
509
+
510
+ - (void)removeAnimationsFromSubtree:(UIView *)view
511
+ {
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
+ });
405
518
  }
406
519
 
407
- - (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)before
520
+ - (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)before withNewFrame:(CGRect)frame
408
521
  {
409
- NSString *type = before == nil ? @"entering" : @"layout";
410
- if (_hasAnimationForTag(view.reactTag, type)) {
522
+ LayoutAnimationType type = before == nil ? ENTERING : LAYOUT;
523
+ NSNumber *viewTag = view.reactTag;
524
+ if (_hasAnimationForTag(viewTag, type)) {
411
525
  REASnapshot *after = [[REASnapshot alloc] init:view];
412
526
  if (before == nil) {
413
527
  [self onViewCreate:view after:after];
414
528
  } else {
415
529
  [self onViewUpdate:view before:before after:after];
416
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
+ }
417
542
  }
418
543
  }
419
544
 
420
- - (void)removeAnimationsFromSubtree:(UIView *)view
545
+ - (void)viewsDidLayout
421
546
  {
422
- REANodeFind(view, ^int(id<RCTComponent> view) {
423
- self->_clearAnimationConfigForTag(view.reactTag);
424
- return false;
425
- });
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);
426
581
  }
427
582
 
428
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
@@ -0,0 +1,106 @@
1
+ #import <RNReanimated/REAScreensHelper.h>
2
+
3
+ @implementation REAScreensHelper
4
+
5
+ #if LOAD_SCREENS_HEADERS
6
+
7
+ + (UIView *)getScreenForView:(UIView *)view
8
+ {
9
+ UIView *screen = view;
10
+ while (![screen isKindOfClass:[RNSScreenView class]] && screen.superview != nil) {
11
+ screen = screen.superview;
12
+ }
13
+ if ([screen isKindOfClass:[RNSScreenView class]]) {
14
+ return screen;
15
+ }
16
+ return nil;
17
+ }
18
+
19
+ + (UIView *)getStackForView:(UIView *)view
20
+ {
21
+ if ([view isKindOfClass:[RNSScreenView class]]) {
22
+ if (view.reactSuperview != nil) {
23
+ if ([view.reactSuperview isKindOfClass:[RNSScreenStackView class]]) {
24
+ return view.reactSuperview;
25
+ }
26
+ }
27
+ }
28
+ while (view != nil && ![view isKindOfClass:[RNSScreenStackView class]] && view.superview != nil) {
29
+ view = view.superview;
30
+ }
31
+ if ([view isKindOfClass:[RNSScreenStackView class]]) {
32
+ return view;
33
+ }
34
+ return nil;
35
+ }
36
+
37
+ + (bool)isScreenModal:(UIView *)screen
38
+ {
39
+ if ([screen isKindOfClass:[RNSScreenView class]]) {
40
+ NSNumber *presentationMode = [screen valueForKey:@"stackPresentation"];
41
+ bool isModal = ![presentationMode isEqual:@(0)];
42
+ if (!isModal) {
43
+ // case for modal with header
44
+ UIView *parentScreen = [REAScreensHelper getScreenForView:screen.reactSuperview];
45
+ if (parentScreen != nil) {
46
+ isModal = [parentScreen valueForKey:@"stackPresentation"];
47
+ }
48
+ }
49
+ return isModal;
50
+ }
51
+ return false;
52
+ }
53
+
54
+ + (UIView *)getScreenWrapper:(UIView *)view
55
+ {
56
+ UIView *screen = [REAScreensHelper getScreenForView:view];
57
+ UIView *stack = [REAScreensHelper getStackForView:screen];
58
+ UIView *screenWrapper = [REAScreensHelper getScreenForView:stack];
59
+ return screenWrapper;
60
+ }
61
+
62
+ + (int)getScreenType:(UIView *)screen;
63
+ {
64
+ return [[screen valueForKey:@"stackPresentation"] intValue];
65
+ }
66
+
67
+ + (bool)isRNSScreenType:(UIView *)view
68
+ {
69
+ return [view isKindOfClass:[RNSScreen class]] == YES;
70
+ }
71
+
72
+ #else
73
+
74
+ + (UIView *)getScreenForView:(UIView *)view
75
+ {
76
+ return nil;
77
+ }
78
+
79
+ + (UIView *)getStackForView:(UIView *)view
80
+ {
81
+ return nil;
82
+ }
83
+
84
+ + (bool)isScreenModal:(UIView *)screen
85
+ {
86
+ return false;
87
+ }
88
+
89
+ + (UIView *)getScreenWrapper:(UIView *)view
90
+ {
91
+ return nil;
92
+ }
93
+
94
+ + (int)getScreenType:(UIView *)screen;
95
+ {
96
+ return 0;
97
+ }
98
+
99
+ + (bool)isRNSScreenType:(UIView *)screen
100
+ {
101
+ return false;
102
+ }
103
+
104
+ #endif // LOAD_SCREENS_HEADERS
105
+
106
+ @end
@@ -0,0 +1,15 @@
1
+ #import <RNReanimated/REASnapshot.h>
2
+
3
+ @interface REASharedElement : NSObject
4
+
5
+ - (instancetype)initWithSourceView:(UIView *)sourceView
6
+ sourceViewSnapshot:(REASnapshot *)sourceViewSnapshot
7
+ targetView:(UIView *)targetView
8
+ targetViewSnapshot:(REASnapshot *)targetViewSnapshot;
9
+
10
+ @property UIView *sourceView;
11
+ @property REASnapshot *sourceViewSnapshot;
12
+ @property UIView *targetView;
13
+ @property REASnapshot *targetViewSnapshot;
14
+
15
+ @end
@@ -0,0 +1,16 @@
1
+ #import <RNReanimated/REASharedElement.h>
2
+
3
+ @implementation REASharedElement
4
+ - (instancetype)initWithSourceView:(UIView *)sourceView
5
+ sourceViewSnapshot:(REASnapshot *)sourceViewSnapshot
6
+ targetView:(UIView *)targetView
7
+ targetViewSnapshot:(REASnapshot *)targetViewSnapshot
8
+ {
9
+ self = [super init];
10
+ _sourceView = sourceView;
11
+ _sourceViewSnapshot = sourceViewSnapshot;
12
+ _targetView = targetView;
13
+ _targetViewSnapshot = targetViewSnapshot;
14
+ return self;
15
+ }
16
+ @end
@@ -0,0 +1,17 @@
1
+ #import <RNReanimated/REAAnimationsManager.h>
2
+ #import <RNReanimated/REASnapshot.h>
3
+
4
+ @interface REASharedTransitionManager : NSObject
5
+
6
+ - (void)notifyAboutNewView:(UIView *)view;
7
+ - (void)notifyAboutViewLayout:(UIView *)view withViewFrame:(CGRect)frame;
8
+ - (void)viewsDidLayout;
9
+ - (BOOL)configureAndStartSharedTransitionForViews:(NSArray<UIView *> *)views;
10
+ - (void)finishSharedAnimation:(UIView *)view;
11
+ - (void)setFindPrecedingViewTagForTransitionBlock:
12
+ (REAFindPrecedingViewTagForTransitionBlock)findPrecedingViewTagForTransition;
13
+ - (void)setCancelAnimationBlock:(REACancelAnimationBlock)cancelAnimationBlock;
14
+ - (instancetype)initWithAnimationsManager:(REAAnimationsManager *)animationManager;
15
+ - (UIView *)getTransitioningView:(NSNumber *)tag;
16
+
17
+ @end