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.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +24 -1
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /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
|
-
|
|
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
|
|
102
|
-
|
|
103
|
-
|
|
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 = [
|
|
111
|
-
|
|
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
|
|
159
|
+
- (void)progressLayoutAnimationWithStyle:(NSDictionary *)newStyle
|
|
160
|
+
forTag:(NSNumber *)tag
|
|
161
|
+
isSharedTransition:(BOOL)isSharedTransition
|
|
140
162
|
{
|
|
141
|
-
|
|
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
|
-
|
|
157
|
-
|
|
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" : [
|
|
198
|
-
@"windowHeight" : [
|
|
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" : [
|
|
210
|
-
@"windowHeight" : [
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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,
|
|
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
|
-
|
|
256
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
502
|
+
_startAnimationForTag(view.reactTag, LAYOUT, preparedValues, @(0));
|
|
397
503
|
}
|
|
398
504
|
|
|
399
505
|
- (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view
|
|
400
506
|
{
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
-
|
|
410
|
-
|
|
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)
|
|
545
|
+
- (void)viewsDidLayout
|
|
421
546
|
{
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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,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
|