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,27 +1,112 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <RNReanimated/REAScreensHelper.h>
|
|
2
3
|
#import <RNReanimated/REASnapshot.h>
|
|
4
|
+
#import <React/UIView+React.h>
|
|
3
5
|
|
|
4
6
|
NS_ASSUME_NONNULL_BEGIN
|
|
5
7
|
|
|
6
|
-
@implementation REASnapshot
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
@implementation REASnapshot
|
|
9
|
+
|
|
10
|
+
const int ScreenStackPresentationModal = 1; // RNSScreenStackPresentationModal
|
|
11
|
+
const int DEFAULT_MODAL_TOP_OFFSET = 69; // Default iOS modal is shifted from screen top edge by 69px
|
|
9
12
|
|
|
10
13
|
- (instancetype)init:(UIView *)view
|
|
11
14
|
{
|
|
12
15
|
self = [super init];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
[self makeSnapshotForView:view useAbsolutePositionOnly:NO];
|
|
17
|
+
return self;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (instancetype)initWithAbsolutePosition:(UIView *)view
|
|
21
|
+
{
|
|
22
|
+
self = [super init];
|
|
23
|
+
[self makeSnapshotForView:view useAbsolutePositionOnly:YES];
|
|
24
|
+
return self;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (void)makeSnapshotForView:(UIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly
|
|
28
|
+
{
|
|
29
|
+
UIView *mainWindow = UIApplication.sharedApplication.keyWindow;
|
|
30
|
+
CGPoint absolutePosition = [[view superview] convertPoint:view.center toView:mainWindow];
|
|
16
31
|
_values = [NSMutableDictionary new];
|
|
32
|
+
_values[@"windowWidth"] = [NSNumber numberWithDouble:mainWindow.bounds.size.width];
|
|
33
|
+
_values[@"windowHeight"] = [NSNumber numberWithDouble:mainWindow.bounds.size.height];
|
|
17
34
|
_values[@"width"] = [NSNumber numberWithDouble:(double)(view.bounds.size.width)];
|
|
18
35
|
_values[@"height"] = [NSNumber numberWithDouble:(double)(view.bounds.size.height)];
|
|
19
|
-
_values[@"
|
|
20
|
-
_values[@"
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
_values[@"globalOriginX"] = [NSNumber numberWithDouble:absolutePosition.x - view.bounds.size.width / 2.0];
|
|
37
|
+
_values[@"globalOriginY"] = [NSNumber numberWithDouble:absolutePosition.y - view.bounds.size.height / 2.0];
|
|
38
|
+
if (useAbsolutePositionOnly) {
|
|
39
|
+
_values[@"originX"] = _values[@"globalOriginX"];
|
|
40
|
+
_values[@"originY"] = _values[@"globalOriginY"];
|
|
41
|
+
_values[@"originXByParent"] = [NSNumber numberWithDouble:view.center.x - view.bounds.size.width / 2.0];
|
|
42
|
+
_values[@"originYByParent"] = [NSNumber numberWithDouble:view.center.y - view.bounds.size.height / 2.0];
|
|
23
43
|
|
|
24
|
-
|
|
44
|
+
UIView *navigationContainer = view.reactViewController.navigationController.view;
|
|
45
|
+
UIView *header = [navigationContainer.subviews count] > 1 ? navigationContainer.subviews[1] : nil;
|
|
46
|
+
if (header != nil) {
|
|
47
|
+
CGFloat headerHeight = header.frame.size.height;
|
|
48
|
+
CGFloat headerOriginY = header.frame.origin.y;
|
|
49
|
+
UIView *screen = [REAScreensHelper getScreenForView:view];
|
|
50
|
+
if ([REAScreensHelper isScreenModal:screen] && screen.superview == nil) {
|
|
51
|
+
int additionalModalOffset = 0;
|
|
52
|
+
UIView *screenWrapper = [REAScreensHelper getScreenWrapper:view];
|
|
53
|
+
int screenType = [REAScreensHelper getScreenType:screenWrapper];
|
|
54
|
+
if (screenType == ScreenStackPresentationModal) {
|
|
55
|
+
additionalModalOffset = DEFAULT_MODAL_TOP_OFFSET;
|
|
56
|
+
}
|
|
57
|
+
float originY = [_values[@"originY"] doubleValue] + headerHeight + headerOriginY + additionalModalOffset;
|
|
58
|
+
_values[@"originY"] = @(originY);
|
|
59
|
+
}
|
|
60
|
+
_values[@"headerHeight"] = @(headerHeight);
|
|
61
|
+
} else {
|
|
62
|
+
_values[@"headerHeight"] = @(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
UIView *transformedView = [self findTransformedView:view];
|
|
66
|
+
if (transformedView != nil) {
|
|
67
|
+
// iOS affine matrix: https://developer.apple.com/documentation/corefoundation/cgaffinetransform?language=objc
|
|
68
|
+
CGAffineTransform transform = transformedView.transform;
|
|
69
|
+
NSNumber *a = @(transform.a);
|
|
70
|
+
NSNumber *b = @(transform.b);
|
|
71
|
+
NSNumber *c = @(transform.c);
|
|
72
|
+
NSNumber *d = @(transform.d);
|
|
73
|
+
NSNumber *tx = @(transform.tx);
|
|
74
|
+
NSNumber *ty = @(transform.tx);
|
|
75
|
+
_values[@"transformMatrix"] = @[ a, b, @(0), c, d, @(0), tx, ty, @(1) ];
|
|
76
|
+
_values[@"originX"] = @([_values[@"originX"] doubleValue] - [tx doubleValue]);
|
|
77
|
+
_values[@"originY"] = @([_values[@"originY"] doubleValue] - [ty doubleValue]);
|
|
78
|
+
} else {
|
|
79
|
+
// Identity matrix is an default value
|
|
80
|
+
_values[@"transformMatrix"] = @[ @(1), @(0), @(0), @(0), @(1), @(0), @(0), @(0), @(1) ];
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
_values[@"originX"] = [NSNumber numberWithDouble:view.center.x - view.bounds.size.width / 2.0];
|
|
84
|
+
_values[@"originY"] = [NSNumber numberWithDouble:view.center.y - view.bounds.size.height / 2.0];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (UIView *)findTransformedView:(UIView *)view
|
|
89
|
+
{
|
|
90
|
+
UIView *transformedView;
|
|
91
|
+
bool isTransformed = false;
|
|
92
|
+
do {
|
|
93
|
+
if (transformedView == nil) {
|
|
94
|
+
transformedView = view;
|
|
95
|
+
} else {
|
|
96
|
+
transformedView = transformedView.superview;
|
|
97
|
+
}
|
|
98
|
+
CGAffineTransform transform = transformedView.transform;
|
|
99
|
+
isTransformed = transform.a != 1 || transform.b != 0 || transform.c != 0 || transform.d != 1 || transform.tx != 0 ||
|
|
100
|
+
transform.ty != 0;
|
|
101
|
+
} while (!isTransformed &&
|
|
102
|
+
transformedView != nil
|
|
103
|
+
// Ignore views above screen
|
|
104
|
+
&& ![REAScreensHelper isRNSScreenType:transformedView]);
|
|
105
|
+
|
|
106
|
+
if (isTransformed && transformedView != nil) {
|
|
107
|
+
return transformedView;
|
|
108
|
+
}
|
|
109
|
+
return nil;
|
|
25
110
|
}
|
|
26
111
|
|
|
27
112
|
@end
|
|
@@ -24,12 +24,6 @@
|
|
|
24
24
|
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
25
25
|
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
|
|
26
26
|
|
|
27
|
-
- (void)_removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container;
|
|
28
|
-
|
|
29
|
-
- (void)_removeChildren:(NSArray<UIView *> *)children
|
|
30
|
-
fromContainer:(UIView *)container
|
|
31
|
-
withAnimation:(RCTLayoutAnimationGroup *)animation;
|
|
32
|
-
|
|
33
27
|
- (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *)rootShadowView;
|
|
34
28
|
|
|
35
29
|
- (NSArray<id<RCTComponent>> *)_childrenToRemoveFromContainer:(id<RCTComponent>)container
|
|
@@ -37,7 +31,6 @@
|
|
|
37
31
|
@end
|
|
38
32
|
|
|
39
33
|
@implementation REAUIManager {
|
|
40
|
-
RCTLayoutAnimationGroup *_reactLayoutAnimationGroup;
|
|
41
34
|
NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> *_toBeRemovedRegister;
|
|
42
35
|
NSMutableDictionary<NSNumber *, NSNumber *> *_parentMapper;
|
|
43
36
|
REAAnimationsManager *_animationsManager;
|
|
@@ -49,15 +42,14 @@
|
|
|
49
42
|
return NSStringFromClass([RCTUIManager class]);
|
|
50
43
|
}
|
|
51
44
|
|
|
45
|
+
- (void)invalidate
|
|
46
|
+
{
|
|
47
|
+
[_animationsManager invalidate];
|
|
48
|
+
[super invalidate];
|
|
49
|
+
}
|
|
50
|
+
|
|
52
51
|
- (void)setBridge:(RCTBridge *)bridge
|
|
53
52
|
{
|
|
54
|
-
// setting a layout animation group with a deleting animation in order to
|
|
55
|
-
// allows us to call a different method in RCTUIManager for cleaning up exiting views
|
|
56
|
-
RCTLayoutAnimation *deletingAnimation = [[RCTLayoutAnimation alloc] initWithDuration:0 config:@{}];
|
|
57
|
-
_reactLayoutAnimationGroup = [[RCTLayoutAnimationGroup alloc] initWithCreatingLayoutAnimation:nil
|
|
58
|
-
updatingLayoutAnimation:nil
|
|
59
|
-
deletingLayoutAnimation:deletingAnimation
|
|
60
|
-
callback:nil];
|
|
61
53
|
if (!_blockSetter) {
|
|
62
54
|
_blockSetter = true;
|
|
63
55
|
|
|
@@ -79,21 +71,6 @@
|
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
73
|
|
|
82
|
-
- (void)_removeChildren:(NSArray<UIView *> *)children
|
|
83
|
-
fromContainer:(UIView *)container
|
|
84
|
-
withAnimation:(RCTLayoutAnimationGroup *)animation
|
|
85
|
-
{
|
|
86
|
-
if (animation == _reactLayoutAnimationGroup) {
|
|
87
|
-
// if a removed view in this batch has an `exiting` animation,
|
|
88
|
-
// let REAAnimationsManager handle the removal
|
|
89
|
-
[_animationsManager removeChildren:children fromContainer:container];
|
|
90
|
-
} else {
|
|
91
|
-
// otherwise, if there's a layout animation group set,
|
|
92
|
-
// delegate to the React Native implementation for layout animations
|
|
93
|
-
[super _removeChildren:children fromContainer:container withAnimation:animation];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
74
|
- (void)_manageChildren:(NSNumber *)containerTag
|
|
98
75
|
moveFromIndices:(NSArray<NSNumber *> *)moveFromIndices
|
|
99
76
|
moveToIndices:(NSArray<NSNumber *> *)moveToIndices
|
|
@@ -102,40 +79,32 @@
|
|
|
102
79
|
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
103
80
|
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
|
104
81
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
bool isLayoutAnimationEnabled = reanimated::FeaturesConfig::isLayoutAnimationEnabled();
|
|
83
|
+
id<RCTComponent> container;
|
|
84
|
+
NSArray<id<RCTComponent>> *permanentlyRemovedChildren;
|
|
85
|
+
BOOL containerIsRootOfViewController = NO;
|
|
86
|
+
if (isLayoutAnimationEnabled) {
|
|
87
|
+
container = registry[containerTag];
|
|
88
|
+
permanentlyRemovedChildren = [self _childrenToRemoveFromContainer:container atIndices:removeAtIndices];
|
|
89
|
+
|
|
90
|
+
if ([container isKindOfClass:[UIView class]]) {
|
|
91
|
+
UIViewController *controller = ((UIView *)container).reactViewController;
|
|
92
|
+
UIViewController *parentController = ((UIView *)container).superview.reactViewController;
|
|
93
|
+
containerIsRootOfViewController = controller != parentController;
|
|
94
|
+
}
|
|
115
95
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
BOOL wantProxyRemoval = NO;
|
|
121
|
-
if (!wasProxyRemovalSet) {
|
|
122
|
-
id<RCTComponent> container = registry[containerTag];
|
|
96
|
+
// we check if the container we`re removing from is a root view
|
|
97
|
+
// of some view controller. In that case, we skip running exiting animations
|
|
98
|
+
// in its children, to prevent issues with RN Screens.
|
|
99
|
+
if (containerIsRootOfViewController) {
|
|
123
100
|
NSArray<id<RCTComponent>> *permanentlyRemovedChildren = [self _childrenToRemoveFromContainer:container
|
|
124
101
|
atIndices:removeAtIndices];
|
|
125
|
-
for (UIView *
|
|
126
|
-
|
|
127
|
-
wantProxyRemoval = YES;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
[_animationsManager removeAnimationsFromSubtree:removedChild];
|
|
131
|
-
}
|
|
132
|
-
if (wantProxyRemoval) {
|
|
133
|
-
// set layout animation group
|
|
134
|
-
[super setNextLayoutAnimationGroup:_reactLayoutAnimationGroup];
|
|
102
|
+
for (UIView *view in permanentlyRemovedChildren) {
|
|
103
|
+
[_animationsManager endAnimationsRecursive:view];
|
|
135
104
|
}
|
|
105
|
+
[_animationsManager removeAnimationsFromSubtree:(UIView *)container];
|
|
136
106
|
}
|
|
137
107
|
}
|
|
138
|
-
// Reanimated changes /end
|
|
139
108
|
|
|
140
109
|
[super _manageChildren:containerTag
|
|
141
110
|
moveFromIndices:moveFromIndices
|
|
@@ -144,6 +113,28 @@
|
|
|
144
113
|
addAtIndices:addAtIndices
|
|
145
114
|
removeAtIndices:removeAtIndices
|
|
146
115
|
registry:registry];
|
|
116
|
+
|
|
117
|
+
if (!isLayoutAnimationEnabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (containerIsRootOfViewController) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// we sort the (index, view) pairs to make sure we insert views back in order
|
|
126
|
+
NSMutableArray<NSArray<id> *> *removedViewsWithIndices = [NSMutableArray new];
|
|
127
|
+
for (int i = 0; i < removeAtIndices.count; i++) {
|
|
128
|
+
removedViewsWithIndices[i] = @[ removeAtIndices[i], permanentlyRemovedChildren[i] ];
|
|
129
|
+
}
|
|
130
|
+
[removedViewsWithIndices
|
|
131
|
+
sortUsingComparator:^NSComparisonResult(NSArray<id> *_Nonnull obj1, NSArray<id> *_Nonnull obj2) {
|
|
132
|
+
return [(NSNumber *)obj1[0] compare:(NSNumber *)obj2[0]];
|
|
133
|
+
}];
|
|
134
|
+
|
|
135
|
+
[_animationsManager reattachAnimatedChildren:permanentlyRemovedChildren
|
|
136
|
+
toContainer:container
|
|
137
|
+
atIndices:removeAtIndices];
|
|
147
138
|
}
|
|
148
139
|
|
|
149
140
|
- (void)callAnimationForTree:(UIView *)view parentTag:(NSNumber *)parentTag
|
|
@@ -238,6 +229,8 @@
|
|
|
238
229
|
|
|
239
230
|
__block NSUInteger completionsCalled = 0;
|
|
240
231
|
|
|
232
|
+
NSMutableDictionary<NSNumber *, REASnapshot *> *snapshotsBefore = [NSMutableDictionary dictionary];
|
|
233
|
+
|
|
241
234
|
NSInteger index = 0;
|
|
242
235
|
for (NSNumber *reactTag in reactTags) {
|
|
243
236
|
RCTFrameData frameData = frameDataArray[index++];
|
|
@@ -274,6 +267,7 @@
|
|
|
274
267
|
|
|
275
268
|
// Reanimated changes /start
|
|
276
269
|
REASnapshot *snapshotBefore = isNew ? nil : [self->_animationsManager prepareSnapshotBeforeMountForView:view];
|
|
270
|
+
snapshotsBefore[reactTag] = snapshotBefore;
|
|
277
271
|
// Reanimated changes /end
|
|
278
272
|
|
|
279
273
|
if (creatingLayoutAnimation) {
|
|
@@ -320,17 +314,30 @@
|
|
|
320
314
|
[view reactSetFrame:frame];
|
|
321
315
|
completion(YES);
|
|
322
316
|
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Reanimated changes /start
|
|
320
|
+
index = 0;
|
|
321
|
+
for (NSNumber *reactTag in reactTags) {
|
|
322
|
+
RCTFrameData frameData = frameDataArray[index++];
|
|
323
|
+
UIView *view = viewRegistry[reactTag];
|
|
324
|
+
BOOL isNew = frameData.isNew;
|
|
325
|
+
CGRect frame = frameData.frame;
|
|
326
|
+
|
|
327
|
+
REASnapshot *snapshotBefore = snapshotsBefore[reactTag];
|
|
323
328
|
|
|
324
|
-
// Reanimated changes /start
|
|
325
329
|
if (isNew || snapshotBefore != nil) {
|
|
326
|
-
[self->_animationsManager viewDidMount:view withBeforeSnapshot:snapshotBefore];
|
|
330
|
+
[self->_animationsManager viewDidMount:view withBeforeSnapshot:snapshotBefore withNewFrame:frame];
|
|
327
331
|
}
|
|
328
|
-
// Reanimated changes /end
|
|
329
332
|
}
|
|
333
|
+
|
|
330
334
|
// Clean up
|
|
331
335
|
// below line serves as this one uiManager->_layoutAnimationGroup = nil;, because we don't have access to the
|
|
332
336
|
// private field
|
|
333
337
|
[uiManager setNextLayoutAnimationGroup:nil];
|
|
338
|
+
|
|
339
|
+
[self->_animationsManager viewsDidLayout];
|
|
340
|
+
// Reanimated changes /end
|
|
334
341
|
};
|
|
335
342
|
}
|
|
336
343
|
|
package/ios/REAModule.mm
CHANGED
|
@@ -19,14 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
#import <RNReanimated/REAModule.h>
|
|
21
21
|
#import <RNReanimated/REANodesManager.h>
|
|
22
|
+
#import <RNReanimated/ReanimatedVersion.h>
|
|
22
23
|
#import <RNReanimated/SingleInstanceChecker.h>
|
|
23
24
|
|
|
24
|
-
#ifdef REANIMATED_VERSION
|
|
25
|
-
#define STRINGIZE(x) #x
|
|
26
|
-
#define STRINGIZE2(x) STRINGIZE(x)
|
|
27
|
-
#define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
|
|
28
|
-
#endif // REANIMATED_VERSION
|
|
29
|
-
|
|
30
25
|
using namespace facebook::react;
|
|
31
26
|
using namespace reanimated;
|
|
32
27
|
|
|
@@ -222,7 +217,7 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installTurboModule)
|
|
|
222
217
|
|
|
223
218
|
runtime.global().setProperty(runtime, "_IS_FABRIC", true);
|
|
224
219
|
|
|
225
|
-
auto version =
|
|
220
|
+
auto version = getReanimatedVersionString(runtime);
|
|
226
221
|
runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
|
|
227
222
|
|
|
228
223
|
runtime.global().setProperty(
|
package/ios/REANodesManager.mm
CHANGED
|
@@ -313,24 +313,6 @@ using namespace facebook::react;
|
|
|
313
313
|
}
|
|
314
314
|
#endif
|
|
315
315
|
|
|
316
|
-
- (BOOL)isDirectEvent:(id<RCTEvent>)event
|
|
317
|
-
{
|
|
318
|
-
static NSArray<NSString *> *directEventNames;
|
|
319
|
-
static dispatch_once_t directEventNamesToken;
|
|
320
|
-
dispatch_once(&directEventNamesToken, ^{
|
|
321
|
-
directEventNames = @[
|
|
322
|
-
@"topContentSizeChange",
|
|
323
|
-
@"topMomentumScrollBegin",
|
|
324
|
-
@"topMomentumScrollEnd",
|
|
325
|
-
@"topScroll",
|
|
326
|
-
@"topScrollBeginDrag",
|
|
327
|
-
@"topScrollEndDrag"
|
|
328
|
-
];
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
return [directEventNames containsObject:RCTNormalizeInputEventName(event.eventName)];
|
|
332
|
-
}
|
|
333
|
-
|
|
334
316
|
- (void)dispatchEvent:(id<RCTEvent>)event
|
|
335
317
|
{
|
|
336
318
|
NSString *key = [NSString stringWithFormat:@"%@%@", event.viewTag, RCTNormalizeInputEventName(event.eventName)];
|
|
@@ -349,9 +331,7 @@ using namespace facebook::react;
|
|
|
349
331
|
return;
|
|
350
332
|
}
|
|
351
333
|
eventHandler(eventHash, event);
|
|
352
|
-
|
|
353
|
-
[strongSelf performOperations];
|
|
354
|
-
}
|
|
334
|
+
[strongSelf performOperations];
|
|
355
335
|
});
|
|
356
336
|
}
|
|
357
337
|
}
|
|
@@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
18
18
|
int _windowsCount;
|
|
19
19
|
UIView *_keyboardView;
|
|
20
20
|
KeyboardState _state;
|
|
21
|
+
bool _shouldInvalidateDisplayLink;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
- (instancetype)init
|
|
@@ -26,6 +27,14 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
26
27
|
_listeners = [[NSMutableDictionary alloc] init];
|
|
27
28
|
_nextListenerId = @0;
|
|
28
29
|
_state = UNKNOWN;
|
|
30
|
+
_shouldInvalidateDisplayLink = false;
|
|
31
|
+
|
|
32
|
+
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
|
33
|
+
|
|
34
|
+
[notificationCenter addObserver:self
|
|
35
|
+
selector:@selector(clearListeners)
|
|
36
|
+
name:RCTBridgeDidInvalidateModulesNotification
|
|
37
|
+
object:nil];
|
|
29
38
|
return self;
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -79,15 +88,19 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
79
88
|
|
|
80
89
|
- (void)runAnimation
|
|
81
90
|
{
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
if (!displayLink) {
|
|
92
|
+
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateKeyboardFrame)];
|
|
93
|
+
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
94
|
+
}
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
- (void)stopAnimation
|
|
87
98
|
{
|
|
88
|
-
[displayLink invalidate];
|
|
89
|
-
displayLink = nil;
|
|
90
99
|
[self updateKeyboardFrame];
|
|
100
|
+
// there might be a case that keyboard will change height in the next frame
|
|
101
|
+
// (for example changing keyboard language so that suggestions appear)
|
|
102
|
+
// so we invalidate display link after we handle that in the next frame
|
|
103
|
+
_shouldInvalidateDisplayLink = true;
|
|
91
104
|
}
|
|
92
105
|
|
|
93
106
|
- (void)updateKeyboardFrame
|
|
@@ -101,6 +114,12 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
101
114
|
for (NSString *key in _listeners.allKeys) {
|
|
102
115
|
((KeyboardEventListenerBlock)_listeners[key])(_state, keyboardHeight);
|
|
103
116
|
}
|
|
117
|
+
|
|
118
|
+
if (_shouldInvalidateDisplayLink) {
|
|
119
|
+
_shouldInvalidateDisplayLink = false;
|
|
120
|
+
[displayLink invalidate];
|
|
121
|
+
displayLink = nil;
|
|
122
|
+
}
|
|
104
123
|
}
|
|
105
124
|
|
|
106
125
|
- (CGFloat)computeKeyboardHeight:(UIView *)keyboardView
|
|
@@ -139,44 +158,51 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
139
158
|
{
|
|
140
159
|
NSNumber *listenerId = [_nextListenerId copy];
|
|
141
160
|
_nextListenerId = [NSNumber numberWithInt:[_nextListenerId intValue] + 1];
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
RCTExecuteOnMainQueue(^() {
|
|
162
|
+
if ([self->_listeners count] == 0) {
|
|
163
|
+
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
|
164
|
+
|
|
165
|
+
[notificationCenter addObserver:self
|
|
166
|
+
selector:@selector(keyboardWillHide:)
|
|
167
|
+
name:UIKeyboardWillHideNotification
|
|
168
|
+
object:nil];
|
|
169
|
+
|
|
170
|
+
[notificationCenter addObserver:self
|
|
171
|
+
selector:@selector(keyboardWillShow:)
|
|
172
|
+
name:UIKeyboardWillShowNotification
|
|
173
|
+
object:nil];
|
|
174
|
+
|
|
175
|
+
[notificationCenter addObserver:self
|
|
176
|
+
selector:@selector(keyboardDidHide:)
|
|
177
|
+
name:UIKeyboardDidHideNotification
|
|
178
|
+
object:nil];
|
|
179
|
+
|
|
180
|
+
[notificationCenter addObserver:self
|
|
181
|
+
selector:@selector(keyboardDidShow:)
|
|
182
|
+
name:UIKeyboardDidShowNotification
|
|
183
|
+
object:nil];
|
|
184
|
+
}
|
|
165
185
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
[self->_listeners setObject:listener forKey:listenerId];
|
|
187
|
+
if (self->_state == UNKNOWN) {
|
|
188
|
+
[self recognizeInitialKeyboardState];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
170
191
|
return [listenerId intValue];
|
|
171
192
|
}
|
|
172
193
|
|
|
173
194
|
- (void)unsubscribeFromKeyboardEvents:(int)listenerId
|
|
174
195
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
[
|
|
179
|
-
|
|
196
|
+
RCTExecuteOnMainQueue(^() {
|
|
197
|
+
NSNumber *_listenerId = [NSNumber numberWithInt:listenerId];
|
|
198
|
+
[self->_listeners removeObjectForKey:_listenerId];
|
|
199
|
+
if ([self->_listeners count] == 0) {
|
|
200
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
|
201
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
|
202
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidHideNotification object:nil];
|
|
203
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardDidShowNotification object:nil];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
180
206
|
}
|
|
181
207
|
|
|
182
208
|
- (void)recognizeInitialKeyboardState
|
|
@@ -193,6 +219,16 @@ typedef NS_ENUM(NSUInteger, KeyboardState) {
|
|
|
193
219
|
});
|
|
194
220
|
}
|
|
195
221
|
|
|
222
|
+
- (void)clearListeners
|
|
223
|
+
{
|
|
224
|
+
RCTUnsafeExecuteOnMainQueueSync(^() {
|
|
225
|
+
[self->_listeners removeAllObjects];
|
|
226
|
+
[self->displayLink invalidate];
|
|
227
|
+
self->displayLink = nil;
|
|
228
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
196
232
|
#endif
|
|
197
233
|
|
|
198
234
|
@end
|