react-native-reanimated 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- 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 +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- 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 +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- 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 +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- 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 +67 -60
- 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 +18 -35
- 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/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- 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 -50
- 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 +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 +16 -12
- 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 +45 -0
- 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 +38 -11
- 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 +18 -34
- 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/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- 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 +45 -52
- 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 +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 -10
- 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 +45 -0
- 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 +38 -9
- 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 +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- 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 +63 -41
- 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/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- 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 +43 -45
- 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 +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- 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 +4 -8
- 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 -12
- 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 +128 -0
- 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 +47 -11
- 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,16 +295,33 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
240
295
|
{
|
|
241
296
|
return REANodeFind(view, ^(id<RCTComponent> view) {
|
|
242
297
|
return [self->_exitingSubviewsCountMap objectForKey:view.reactTag] != nil ||
|
|
243
|
-
self->_hasAnimationForTag(view.reactTag,
|
|
298
|
+
self->_hasAnimationForTag(view.reactTag, EXITING);
|
|
244
299
|
});
|
|
245
300
|
}
|
|
246
301
|
|
|
247
302
|
- (void)registerExitingAncestors:(UIView *)child
|
|
248
303
|
{
|
|
304
|
+
[self registerExitingAncestors:child exitingSubviewsCount:1];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
- (void)registerExitingAncestors:(UIView *)child exitingSubviewsCount:(int)exitingSubviewsCount
|
|
308
|
+
{
|
|
309
|
+
NSNumber *childTag = child.reactTag;
|
|
249
310
|
UIView *parent = child.superview;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
311
|
+
|
|
312
|
+
UIViewController *childController = child.reactViewController;
|
|
313
|
+
|
|
314
|
+
// only register ancestors whose `reactViewController` is the same as `child`'s.
|
|
315
|
+
// The idea is that, if a whole ViewController is unmounted, we won't want to run
|
|
316
|
+
// the exiting animation since all the views will disappear immediately anyway
|
|
317
|
+
while (parent != nil && parent.reactViewController == childController &&
|
|
318
|
+
![parent isKindOfClass:[RCTRootView class]]) {
|
|
319
|
+
NSNumber *parentTag = parent.reactTag;
|
|
320
|
+
if (parentTag != nil) {
|
|
321
|
+
_exitingSubviewsCountMap[parent.reactTag] =
|
|
322
|
+
@([_exitingSubviewsCountMap[parent.reactTag] intValue] + exitingSubviewsCount);
|
|
323
|
+
_exitingParentTags[childTag] = parentTag;
|
|
324
|
+
childTag = parentTag;
|
|
253
325
|
}
|
|
254
326
|
parent = parent.superview;
|
|
255
327
|
}
|
|
@@ -258,12 +330,37 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
258
330
|
- (void)maybeDropAncestors:(UIView *)child
|
|
259
331
|
{
|
|
260
332
|
UIView *parent = child.superview;
|
|
261
|
-
|
|
333
|
+
NSNumber *parentTag = _exitingParentTags[child.reactTag];
|
|
334
|
+
[_exitingParentTags removeObjectForKey:child.reactTag];
|
|
335
|
+
|
|
336
|
+
while ((parent != nil || parentTag != nil) && ![parent isKindOfClass:[RCTRootView class]]) {
|
|
262
337
|
UIView *view = parent;
|
|
338
|
+
NSNumber *viewTag = parentTag;
|
|
339
|
+
parentTag = _exitingParentTags[viewTag];
|
|
340
|
+
UIView *viewByTag = [self viewForTag:viewTag];
|
|
263
341
|
parent = view.superview;
|
|
342
|
+
|
|
343
|
+
if (view == nil) {
|
|
344
|
+
if (viewByTag == nil) {
|
|
345
|
+
// the view was already removed from both native and RN hierarchies
|
|
346
|
+
// we can safely forget that it had any animated children
|
|
347
|
+
[_ancestorsToRemove removeObject:viewTag];
|
|
348
|
+
[_exitingSubviewsCountMap removeObjectForKey:viewTag];
|
|
349
|
+
[_exitingParentTags removeObjectForKey:viewTag];
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
// the child was dettached from view, but view is still
|
|
353
|
+
// in the native and RN hierarchy
|
|
354
|
+
view = viewByTag;
|
|
355
|
+
}
|
|
356
|
+
|
|
264
357
|
if (view.reactTag == nil) {
|
|
358
|
+
// we skip over views with no tag when registering parent tags,
|
|
359
|
+
// so we shouldn't go to the parent of viewTag yet
|
|
360
|
+
parentTag = viewTag;
|
|
265
361
|
continue;
|
|
266
362
|
}
|
|
363
|
+
|
|
267
364
|
int trackingCount = [_exitingSubviewsCountMap[view.reactTag] intValue] - 1;
|
|
268
365
|
if (trackingCount <= 0) {
|
|
269
366
|
if ([_ancestorsToRemove containsObject:view.reactTag]) {
|
|
@@ -273,26 +370,42 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
273
370
|
}
|
|
274
371
|
}
|
|
275
372
|
[_exitingSubviewsCountMap removeObjectForKey:view.reactTag];
|
|
373
|
+
[_exitingParentTags removeObjectForKey:view.reactTag];
|
|
276
374
|
} else {
|
|
277
375
|
_exitingSubviewsCountMap[view.reactTag] = @(trackingCount);
|
|
278
376
|
}
|
|
279
377
|
}
|
|
280
378
|
}
|
|
281
379
|
|
|
282
|
-
- (BOOL)
|
|
380
|
+
- (BOOL)startAnimationsRecursive:(UIView *)view
|
|
381
|
+
shouldRemoveSubviewsWithoutAnimations:(BOOL)shouldRemoveSubviewsWithoutAnimations;
|
|
283
382
|
{
|
|
284
383
|
if (!view.reactTag) {
|
|
285
384
|
return NO;
|
|
286
385
|
}
|
|
287
|
-
|
|
386
|
+
|
|
387
|
+
UIViewController *viewController = view.reactViewController;
|
|
388
|
+
|
|
389
|
+
// `startAnimationsRecursive:shouldRemoveSubviewsWithoutAnimations:`
|
|
390
|
+
// is called on a detached view tree, so the `viewController` should be `nil`.
|
|
391
|
+
// If it's not, we're descending into another `UIViewController`.
|
|
392
|
+
// We don't want to run animations inside it (since it causes issues with RNScreens),
|
|
393
|
+
// so instead clean up the subtree and return `NO`.
|
|
394
|
+
if (viewController != nil) {
|
|
395
|
+
[self removeAnimationsFromSubtree:view];
|
|
396
|
+
return NO;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, EXITING) || [_exitingViews objectForKey:view.reactTag];
|
|
288
400
|
BOOL hasAnimatedChildren = NO;
|
|
289
|
-
|
|
401
|
+
shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
|
|
290
402
|
NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init];
|
|
291
403
|
|
|
292
404
|
for (UIView *subview in [view.reactSubviews copy]) {
|
|
293
|
-
if ([self
|
|
405
|
+
if ([self startAnimationsRecursive:subview
|
|
406
|
+
shouldRemoveSubviewsWithoutAnimations:shouldRemoveSubviewsWithoutAnimations]) {
|
|
294
407
|
hasAnimatedChildren = YES;
|
|
295
|
-
} else if (
|
|
408
|
+
} else if (shouldRemoveSubviewsWithoutAnimations) {
|
|
296
409
|
[toBeRemoved addObject:subview];
|
|
297
410
|
}
|
|
298
411
|
}
|
|
@@ -307,19 +420,13 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
307
420
|
if (hasExitAnimation) {
|
|
308
421
|
before = [[REASnapshot alloc] init:view];
|
|
309
422
|
}
|
|
310
|
-
// start exit animation
|
|
311
|
-
UIView *originalSuperview = view.superview;
|
|
312
|
-
NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:view];
|
|
313
|
-
[container removeReactSubview:view];
|
|
314
|
-
// we don't want user interaction on exiting views
|
|
315
|
-
view.userInteractionEnabled = NO;
|
|
316
|
-
[originalSuperview insertSubview:view atIndex:originalIndex];
|
|
317
423
|
|
|
424
|
+
// start exit animation
|
|
318
425
|
if (hasExitAnimation && ![_exitingViews objectForKey:view.reactTag]) {
|
|
319
426
|
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:before.values frameConfig:ExitingFrame];
|
|
320
427
|
[_exitingViews setObject:view forKey:view.reactTag];
|
|
321
428
|
[self registerExitingAncestors:view];
|
|
322
|
-
_startAnimationForTag(view.reactTag,
|
|
429
|
+
_startAnimationForTag(view.reactTag, EXITING, preparedValues, @(0));
|
|
323
430
|
}
|
|
324
431
|
|
|
325
432
|
if (hasAnimatedChildren) {
|
|
@@ -335,14 +442,45 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
335
442
|
// start new animations for it, and might as well remove
|
|
336
443
|
// the layout animation config now
|
|
337
444
|
_clearAnimationConfigForTag(view.reactTag);
|
|
445
|
+
|
|
446
|
+
// we don't want user interaction on exiting views
|
|
447
|
+
view.userInteractionEnabled = NO;
|
|
448
|
+
|
|
338
449
|
return YES;
|
|
339
450
|
}
|
|
340
451
|
|
|
341
|
-
- (void)
|
|
452
|
+
- (void)reattachAnimatedChildren:(NSArray<id<RCTComponent>> *)children
|
|
453
|
+
toContainer:(id<RCTComponent>)container
|
|
454
|
+
atIndices:(NSArray<NSNumber *> *)indices
|
|
342
455
|
{
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
456
|
+
if (![container isKindOfClass:[UIView class]]) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// since we reattach only some of the views,
|
|
461
|
+
// we count the views we DIDN'T reattach
|
|
462
|
+
// and shift later views' indices by that number
|
|
463
|
+
// to make sure they appear at correct relative posisitons
|
|
464
|
+
// in the `subviews` array
|
|
465
|
+
int skippedViewsCount = 0;
|
|
466
|
+
|
|
467
|
+
for (int i = 0; i < children.count; i++) {
|
|
468
|
+
id<RCTComponent> child = children[i];
|
|
469
|
+
if (![child isKindOfClass:[UIView class]]) {
|
|
470
|
+
skippedViewsCount++;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
UIView *childView = (UIView *)child;
|
|
474
|
+
NSNumber *originalIndex = indices[i];
|
|
475
|
+
if ([self startAnimationsRecursive:childView shouldRemoveSubviewsWithoutAnimations:YES]) {
|
|
476
|
+
[(UIView *)container insertSubview:childView atIndex:[originalIndex intValue] - skippedViewsCount];
|
|
477
|
+
int exitingSubviewsCount = [_exitingSubviewsCountMap[childView.reactTag] intValue];
|
|
478
|
+
if ([_exitingViews objectForKey:childView.reactTag] != nil) {
|
|
479
|
+
exitingSubviewsCount++;
|
|
480
|
+
}
|
|
481
|
+
[self registerExitingAncestors:childView exitingSubviewsCount:exitingSubviewsCount];
|
|
482
|
+
} else {
|
|
483
|
+
skippedViewsCount++;
|
|
346
484
|
}
|
|
347
485
|
}
|
|
348
486
|
}
|
|
@@ -351,7 +489,8 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
351
489
|
{
|
|
352
490
|
NSMutableDictionary *targetValues = after.values;
|
|
353
491
|
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
|
|
354
|
-
|
|
492
|
+
[_enteringViews addObject:view.reactTag];
|
|
493
|
+
_startAnimationForTag(view.reactTag, ENTERING, preparedValues, @(0));
|
|
355
494
|
}
|
|
356
495
|
|
|
357
496
|
- (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after
|
|
@@ -360,36 +499,85 @@ static BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
|
|
|
360
499
|
NSMutableDictionary *currentValues = before.values;
|
|
361
500
|
|
|
362
501
|
NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
|
|
363
|
-
_startAnimationForTag(view.reactTag,
|
|
502
|
+
_startAnimationForTag(view.reactTag, LAYOUT, preparedValues, @(0));
|
|
364
503
|
}
|
|
365
504
|
|
|
366
505
|
- (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view
|
|
367
506
|
{
|
|
368
|
-
|
|
369
|
-
return [[REASnapshot alloc] init:view];
|
|
370
|
-
}
|
|
371
|
-
return nil;
|
|
507
|
+
return [[REASnapshot alloc] init:view];
|
|
372
508
|
}
|
|
373
509
|
|
|
374
|
-
- (void)
|
|
510
|
+
- (void)removeAnimationsFromSubtree:(UIView *)view
|
|
375
511
|
{
|
|
376
|
-
|
|
377
|
-
|
|
512
|
+
REANodeFind(view, ^int(id<RCTComponent> view) {
|
|
513
|
+
if (!self->_hasAnimationForTag(view.reactTag, SHARED_ELEMENT_TRANSITION)) {
|
|
514
|
+
self->_clearAnimationConfigForTag(view.reactTag);
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
- (void)viewDidMount:(UIView *)view withBeforeSnapshot:(nonnull REASnapshot *)before withNewFrame:(CGRect)frame
|
|
521
|
+
{
|
|
522
|
+
LayoutAnimationType type = before == nil ? ENTERING : LAYOUT;
|
|
523
|
+
NSNumber *viewTag = view.reactTag;
|
|
524
|
+
if (_hasAnimationForTag(viewTag, type)) {
|
|
378
525
|
REASnapshot *after = [[REASnapshot alloc] init:view];
|
|
379
526
|
if (before == nil) {
|
|
380
527
|
[self onViewCreate:view after:after];
|
|
381
528
|
} else {
|
|
382
529
|
[self onViewUpdate:view before:before after:after];
|
|
383
530
|
}
|
|
531
|
+
} else if (type == LAYOUT && [_enteringViews containsObject:[view reactTag]]) {
|
|
532
|
+
_enteringViewTargetValues[[view reactTag]] = [[REASnapshot alloc] init:view];
|
|
533
|
+
[self setNewProps:before.values forView:view];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (_hasAnimationForTag(viewTag, SHARED_ELEMENT_TRANSITION)) {
|
|
537
|
+
if (type == ENTERING) {
|
|
538
|
+
[_sharedTransitionManager notifyAboutNewView:view];
|
|
539
|
+
} else {
|
|
540
|
+
[_sharedTransitionManager notifyAboutViewLayout:view withViewFrame:frame];
|
|
541
|
+
}
|
|
384
542
|
}
|
|
385
543
|
}
|
|
386
544
|
|
|
387
|
-
- (void)
|
|
545
|
+
- (void)viewsDidLayout
|
|
388
546
|
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
547
|
+
[_sharedTransitionManager viewsDidLayout];
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
- (void)setFindPrecedingViewTagForTransitionBlock:
|
|
551
|
+
(REAFindPrecedingViewTagForTransitionBlock)findPrecedingViewTagForTransition
|
|
552
|
+
{
|
|
553
|
+
[_sharedTransitionManager setFindPrecedingViewTagForTransitionBlock:findPrecedingViewTagForTransition];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
- (void)setCancelAnimationBlock:(REACancelAnimationBlock)animationCancellingBlock
|
|
557
|
+
{
|
|
558
|
+
[_sharedTransitionManager setCancelAnimationBlock:animationCancellingBlock];
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
- (BOOL)hasAnimationForTag:(NSNumber *)tag type:(LayoutAnimationType)type
|
|
562
|
+
{
|
|
563
|
+
if (!_hasAnimationForTag) {
|
|
564
|
+
// It can happen during reload.
|
|
565
|
+
return NO;
|
|
566
|
+
}
|
|
567
|
+
return _hasAnimationForTag(tag, type);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
- (void)clearAnimationConfigForTag:(NSNumber *)tag
|
|
571
|
+
{
|
|
572
|
+
_clearAnimationConfigForTag(tag);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
- (void)startAnimationForTag:(NSNumber *)tag
|
|
576
|
+
type:(LayoutAnimationType)type
|
|
577
|
+
yogaValues:(NSDictionary *)yogaValues
|
|
578
|
+
depth:(NSNumber *)depth;
|
|
579
|
+
{
|
|
580
|
+
_startAnimationForTag(tag, type, yogaValues, depth);
|
|
393
581
|
}
|
|
394
582
|
|
|
395
583
|
@end
|
|
@@ -0,0 +1,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
|