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
|
@@ -8,12 +8,14 @@ import com.facebook.react.uimanager.ViewManager;
|
|
|
8
8
|
import java.util.ArrayList;
|
|
9
9
|
import java.util.Arrays;
|
|
10
10
|
import java.util.HashMap;
|
|
11
|
+
import java.util.List;
|
|
11
12
|
|
|
12
13
|
public class Snapshot {
|
|
13
14
|
public static final String WIDTH = "width";
|
|
14
15
|
public static final String HEIGHT = "height";
|
|
15
16
|
public static final String ORIGIN_X = "originX";
|
|
16
17
|
public static final String ORIGIN_Y = "originY";
|
|
18
|
+
public static final String TRANSFORM_MATRIX = "transformMatrix";
|
|
17
19
|
public static final String GLOBAL_ORIGIN_X = "globalOriginX";
|
|
18
20
|
public static final String GLOBAL_ORIGIN_Y = "globalOriginY";
|
|
19
21
|
|
|
@@ -21,6 +23,7 @@ public class Snapshot {
|
|
|
21
23
|
public static final String CURRENT_HEIGHT = "currentHeight";
|
|
22
24
|
public static final String CURRENT_ORIGIN_X = "currentOriginX";
|
|
23
25
|
public static final String CURRENT_ORIGIN_Y = "currentOriginY";
|
|
26
|
+
public static final String CURRENT_TRANSFORM_MATRIX = "currentTransformMatrix";
|
|
24
27
|
public static final String CURRENT_GLOBAL_ORIGIN_X = "currentGlobalOriginX";
|
|
25
28
|
public static final String CURRENT_GLOBAL_ORIGIN_Y = "currentGlobalOriginY";
|
|
26
29
|
|
|
@@ -28,6 +31,7 @@ public class Snapshot {
|
|
|
28
31
|
public static final String TARGET_HEIGHT = "targetHeight";
|
|
29
32
|
public static final String TARGET_ORIGIN_X = "targetOriginX";
|
|
30
33
|
public static final String TARGET_ORIGIN_Y = "targetOriginY";
|
|
34
|
+
public static final String TARGET_TRANSFORM_MATRIX = "targetTransformMatrix";
|
|
31
35
|
public static final String TARGET_GLOBAL_ORIGIN_X = "targetGlobalOriginX";
|
|
32
36
|
public static final String TARGET_GLOBAL_ORIGIN_Y = "targetGlobalOriginY";
|
|
33
37
|
|
|
@@ -41,9 +45,30 @@ public class Snapshot {
|
|
|
41
45
|
public int originY;
|
|
42
46
|
public int globalOriginX;
|
|
43
47
|
public int globalOriginY;
|
|
48
|
+
public List<Float> transformMatrix =
|
|
49
|
+
new ArrayList<>(Arrays.asList(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f));
|
|
50
|
+
public int originXByParent;
|
|
51
|
+
public int originYByParent;
|
|
52
|
+
private float[] identityMatrix = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
|
44
53
|
|
|
45
|
-
public static ArrayList<String> targetKeysToTransform
|
|
46
|
-
|
|
54
|
+
public static ArrayList<String> targetKeysToTransform =
|
|
55
|
+
new ArrayList<>(
|
|
56
|
+
Arrays.asList(
|
|
57
|
+
Snapshot.TARGET_WIDTH,
|
|
58
|
+
Snapshot.TARGET_HEIGHT,
|
|
59
|
+
Snapshot.TARGET_ORIGIN_X,
|
|
60
|
+
Snapshot.TARGET_ORIGIN_Y,
|
|
61
|
+
Snapshot.TARGET_GLOBAL_ORIGIN_X,
|
|
62
|
+
Snapshot.TARGET_GLOBAL_ORIGIN_Y));
|
|
63
|
+
public static ArrayList<String> currentKeysToTransform =
|
|
64
|
+
new ArrayList<>(
|
|
65
|
+
Arrays.asList(
|
|
66
|
+
Snapshot.CURRENT_WIDTH,
|
|
67
|
+
Snapshot.CURRENT_HEIGHT,
|
|
68
|
+
Snapshot.CURRENT_ORIGIN_X,
|
|
69
|
+
Snapshot.CURRENT_ORIGIN_Y,
|
|
70
|
+
Snapshot.CURRENT_GLOBAL_ORIGIN_X,
|
|
71
|
+
Snapshot.CURRENT_GLOBAL_ORIGIN_Y));
|
|
47
72
|
|
|
48
73
|
Snapshot(View view, NativeViewHierarchyManager viewHierarchyManager) {
|
|
49
74
|
parent = (ViewGroup) view.getParent();
|
|
@@ -62,25 +87,34 @@ public class Snapshot {
|
|
|
62
87
|
view.getLocationOnScreen(location);
|
|
63
88
|
globalOriginX = location[0];
|
|
64
89
|
globalOriginY = location[1];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public Snapshot(View view) {
|
|
93
|
+
int[] location = new int[2];
|
|
94
|
+
view.getLocationOnScreen(location);
|
|
95
|
+
originX = location[0];
|
|
96
|
+
originY = location[1];
|
|
97
|
+
width = view.getWidth();
|
|
98
|
+
height = view.getHeight();
|
|
99
|
+
|
|
100
|
+
View transformedView = findTransformedView(view);
|
|
101
|
+
if (transformedView != null) {
|
|
102
|
+
float[] transformMatrixArray = new float[9];
|
|
103
|
+
transformedView.getMatrix().getValues(transformMatrixArray);
|
|
104
|
+
transformMatrix = new ArrayList<>();
|
|
105
|
+
for (int i = 0; i < 9; i++) {
|
|
106
|
+
transformMatrix.add(transformMatrixArray[i]);
|
|
107
|
+
}
|
|
108
|
+
transformMatrix.set(0, transformedView.getScaleX());
|
|
109
|
+
transformMatrix.set(4, transformedView.getScaleY());
|
|
110
|
+
transformMatrix.set(2, transformedView.getTranslationX());
|
|
111
|
+
transformMatrix.set(5, transformedView.getTranslationY());
|
|
65
112
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Snapshot.TARGET_ORIGIN_X,
|
|
72
|
-
Snapshot.TARGET_ORIGIN_Y,
|
|
73
|
-
Snapshot.TARGET_GLOBAL_ORIGIN_X,
|
|
74
|
-
Snapshot.TARGET_GLOBAL_ORIGIN_Y));
|
|
75
|
-
currentKeysToTransform =
|
|
76
|
-
new ArrayList<>(
|
|
77
|
-
Arrays.asList(
|
|
78
|
-
Snapshot.CURRENT_WIDTH,
|
|
79
|
-
Snapshot.CURRENT_HEIGHT,
|
|
80
|
-
Snapshot.CURRENT_ORIGIN_X,
|
|
81
|
-
Snapshot.CURRENT_ORIGIN_Y,
|
|
82
|
-
Snapshot.CURRENT_GLOBAL_ORIGIN_X,
|
|
83
|
-
Snapshot.CURRENT_GLOBAL_ORIGIN_Y));
|
|
113
|
+
originX -= (width - width * transformedView.getScaleX()) / 2;
|
|
114
|
+
originY -= (height - height * transformedView.getScaleY()) / 2;
|
|
115
|
+
}
|
|
116
|
+
originXByParent = view.getLeft();
|
|
117
|
+
originYByParent = view.getTop();
|
|
84
118
|
}
|
|
85
119
|
|
|
86
120
|
private void addTargetConfig(HashMap<String, Object> data) {
|
|
@@ -90,6 +124,7 @@ public class Snapshot {
|
|
|
90
124
|
data.put(Snapshot.TARGET_GLOBAL_ORIGIN_X, globalOriginX);
|
|
91
125
|
data.put(Snapshot.TARGET_HEIGHT, height);
|
|
92
126
|
data.put(Snapshot.TARGET_WIDTH, width);
|
|
127
|
+
data.put(Snapshot.TARGET_TRANSFORM_MATRIX, transformMatrix);
|
|
93
128
|
}
|
|
94
129
|
|
|
95
130
|
private void addCurrentConfig(HashMap<String, Object> data) {
|
|
@@ -99,6 +134,17 @@ public class Snapshot {
|
|
|
99
134
|
data.put(Snapshot.CURRENT_GLOBAL_ORIGIN_X, globalOriginX);
|
|
100
135
|
data.put(Snapshot.CURRENT_HEIGHT, height);
|
|
101
136
|
data.put(Snapshot.CURRENT_WIDTH, width);
|
|
137
|
+
data.put(Snapshot.CURRENT_TRANSFORM_MATRIX, transformMatrix);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private void addBasicConfig(HashMap<String, Object> data) {
|
|
141
|
+
data.put(Snapshot.ORIGIN_Y, originY);
|
|
142
|
+
data.put(Snapshot.ORIGIN_X, originX);
|
|
143
|
+
data.put(Snapshot.GLOBAL_ORIGIN_Y, globalOriginY);
|
|
144
|
+
data.put(Snapshot.GLOBAL_ORIGIN_X, globalOriginX);
|
|
145
|
+
data.put(Snapshot.HEIGHT, height);
|
|
146
|
+
data.put(Snapshot.WIDTH, width);
|
|
147
|
+
data.put(Snapshot.TRANSFORM_MATRIX, transformMatrix);
|
|
102
148
|
}
|
|
103
149
|
|
|
104
150
|
public HashMap<String, Object> toTargetMap() {
|
|
@@ -113,9 +159,33 @@ public class Snapshot {
|
|
|
113
159
|
return data;
|
|
114
160
|
}
|
|
115
161
|
|
|
116
|
-
public HashMap<String, Object>
|
|
117
|
-
HashMap<String, Object> data =
|
|
118
|
-
|
|
162
|
+
public HashMap<String, Object> toBasicMap() {
|
|
163
|
+
HashMap<String, Object> data = new HashMap<>();
|
|
164
|
+
addBasicConfig(data);
|
|
119
165
|
return data;
|
|
120
166
|
}
|
|
167
|
+
|
|
168
|
+
private View findTransformedView(View view) {
|
|
169
|
+
View transformedView = null;
|
|
170
|
+
boolean isTransformed = false;
|
|
171
|
+
do {
|
|
172
|
+
if (transformedView == null) {
|
|
173
|
+
transformedView = view;
|
|
174
|
+
} else {
|
|
175
|
+
if (!(transformedView.getParent() instanceof View)) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
transformedView = (View) transformedView.getParent();
|
|
179
|
+
}
|
|
180
|
+
if (transformedView == null) {
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
float[] transformArray = new float[9];
|
|
184
|
+
transformedView.getMatrix().getValues(transformArray);
|
|
185
|
+
isTransformed = !Arrays.equals(transformArray, identityMatrix);
|
|
186
|
+
} while (!isTransformed
|
|
187
|
+
&& transformedView != null
|
|
188
|
+
&& !transformedView.getClass().getSimpleName().equals("Screen"));
|
|
189
|
+
return (isTransformed && transformedView != null) ? transformedView : null;
|
|
190
|
+
}
|
|
121
191
|
}
|
package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nativeProxy;
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData;
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
5
|
+
import com.swmansion.reanimated.NodesManager;
|
|
6
|
+
|
|
7
|
+
@DoNotStrip
|
|
8
|
+
public class AnimationFrameCallback implements NodesManager.OnAnimationFrame {
|
|
9
|
+
|
|
10
|
+
@DoNotStrip private final HybridData mHybridData;
|
|
11
|
+
|
|
12
|
+
@DoNotStrip
|
|
13
|
+
private AnimationFrameCallback(HybridData hybridData) {
|
|
14
|
+
mHybridData = hybridData;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
public native void onAnimationFrame(double timestampMs);
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nativeProxy;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.facebook.jni.HybridData;
|
|
5
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
6
|
+
import com.facebook.react.bridge.WritableArray;
|
|
7
|
+
import com.facebook.react.bridge.WritableMap;
|
|
8
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
9
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
10
|
+
|
|
11
|
+
@DoNotStrip
|
|
12
|
+
public class EventHandler implements RCTEventEmitter {
|
|
13
|
+
|
|
14
|
+
@DoNotStrip private final HybridData mHybridData;
|
|
15
|
+
UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
|
|
16
|
+
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
private EventHandler(HybridData hybridData) {
|
|
19
|
+
mHybridData = hybridData;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Override
|
|
23
|
+
public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
|
|
24
|
+
String resolvedEventName = mCustomEventNamesResolver.resolveCustomEventName(eventName);
|
|
25
|
+
receiveEvent(targetTag + resolvedEventName, event);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public native void receiveEvent(String eventKey, @Nullable WritableMap event);
|
|
29
|
+
|
|
30
|
+
@Override
|
|
31
|
+
public void receiveTouches(
|
|
32
|
+
String eventName, WritableArray touches, WritableArray changedIndices) {
|
|
33
|
+
// not interested in processing touch events this way, we process raw events only
|
|
34
|
+
}
|
|
35
|
+
}
|
package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nativeProxy;
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData;
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
5
|
+
|
|
6
|
+
@DoNotStrip
|
|
7
|
+
public class KeyboardEventDataUpdater {
|
|
8
|
+
@DoNotStrip private final HybridData mHybridData;
|
|
9
|
+
|
|
10
|
+
@DoNotStrip
|
|
11
|
+
private KeyboardEventDataUpdater(HybridData hybridData) {
|
|
12
|
+
mHybridData = hybridData;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public native void keyboardEventDataUpdater(int keyboardState, int height);
|
|
16
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nativeProxy;
|
|
2
|
+
|
|
3
|
+
import android.os.SystemClock;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
import com.facebook.jni.HybridData;
|
|
6
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
7
|
+
import com.facebook.react.ReactApplication;
|
|
8
|
+
import com.facebook.react.bridge.NativeModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.facebook.react.bridge.ReadableNativeArray;
|
|
12
|
+
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
13
|
+
import com.facebook.soloader.SoLoader;
|
|
14
|
+
import com.swmansion.common.GestureHandlerStateManager;
|
|
15
|
+
import com.swmansion.reanimated.NativeProxy;
|
|
16
|
+
import com.swmansion.reanimated.NodesManager;
|
|
17
|
+
import com.swmansion.reanimated.ReanimatedModule;
|
|
18
|
+
import com.swmansion.reanimated.Scheduler;
|
|
19
|
+
import com.swmansion.reanimated.Utils;
|
|
20
|
+
import com.swmansion.reanimated.keyboardObserver.ReanimatedKeyboardEventListener;
|
|
21
|
+
import com.swmansion.reanimated.layoutReanimation.AnimationsManager;
|
|
22
|
+
import com.swmansion.reanimated.layoutReanimation.LayoutAnimations;
|
|
23
|
+
import com.swmansion.reanimated.sensor.ReanimatedSensorContainer;
|
|
24
|
+
import com.swmansion.reanimated.sensor.ReanimatedSensorType;
|
|
25
|
+
import java.lang.ref.WeakReference;
|
|
26
|
+
import java.util.ArrayList;
|
|
27
|
+
import java.util.HashSet;
|
|
28
|
+
import java.util.Map;
|
|
29
|
+
import java.util.Set;
|
|
30
|
+
|
|
31
|
+
public abstract class NativeProxyCommon {
|
|
32
|
+
static {
|
|
33
|
+
SoLoader.loadLibrary("reanimated");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected NodesManager mNodesManager;
|
|
37
|
+
protected final WeakReference<ReactApplicationContext> mContext;
|
|
38
|
+
protected Scheduler mScheduler;
|
|
39
|
+
private ReanimatedSensorContainer reanimatedSensorContainer;
|
|
40
|
+
private final GestureHandlerStateManager gestureHandlerStateManager;
|
|
41
|
+
private ReanimatedKeyboardEventListener reanimatedKeyboardEventListener;
|
|
42
|
+
private Long firstUptime = SystemClock.uptimeMillis();
|
|
43
|
+
private boolean slowAnimationsEnabled = false;
|
|
44
|
+
|
|
45
|
+
protected NativeProxyCommon(ReactApplicationContext context) {
|
|
46
|
+
mScheduler = new Scheduler(context);
|
|
47
|
+
mContext = new WeakReference<>(context);
|
|
48
|
+
reanimatedSensorContainer = new ReanimatedSensorContainer(mContext);
|
|
49
|
+
reanimatedKeyboardEventListener = new ReanimatedKeyboardEventListener(mContext);
|
|
50
|
+
addDevMenuOption();
|
|
51
|
+
|
|
52
|
+
GestureHandlerStateManager tempHandlerStateManager;
|
|
53
|
+
try {
|
|
54
|
+
Class<NativeModule> gestureHandlerModuleClass =
|
|
55
|
+
(Class<NativeModule>)
|
|
56
|
+
Class.forName("com.swmansion.gesturehandler.react.RNGestureHandlerModule");
|
|
57
|
+
tempHandlerStateManager =
|
|
58
|
+
(GestureHandlerStateManager) context.getNativeModule(gestureHandlerModuleClass);
|
|
59
|
+
} catch (ClassCastException | ClassNotFoundException e) {
|
|
60
|
+
tempHandlerStateManager = null;
|
|
61
|
+
}
|
|
62
|
+
gestureHandlerStateManager = tempHandlerStateManager;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public Scheduler getScheduler() {
|
|
66
|
+
return mScheduler;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private void toggleSlowAnimations() {
|
|
70
|
+
slowAnimationsEnabled = !slowAnimationsEnabled;
|
|
71
|
+
if (slowAnimationsEnabled) {
|
|
72
|
+
firstUptime = SystemClock.uptimeMillis();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private void addDevMenuOption() {
|
|
77
|
+
// In Expo, `ApplicationContext` is not an instance of `ReactApplication`
|
|
78
|
+
if (mContext.get().getApplicationContext() instanceof ReactApplication) {
|
|
79
|
+
final DevSupportManager devSupportManager =
|
|
80
|
+
((ReactApplication) mContext.get().getApplicationContext())
|
|
81
|
+
.getReactNativeHost()
|
|
82
|
+
.getReactInstanceManager()
|
|
83
|
+
.getDevSupportManager();
|
|
84
|
+
|
|
85
|
+
devSupportManager.addCustomDevOption(
|
|
86
|
+
"Toggle slow animations (Reanimated)", this::toggleSlowAnimations);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@DoNotStrip
|
|
91
|
+
private void requestRender(AnimationFrameCallback callback) {
|
|
92
|
+
mNodesManager.postOnAnimation(callback);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@DoNotStrip
|
|
96
|
+
private void updateProps(int viewTag, Map<String, Object> props) {
|
|
97
|
+
mNodesManager.updateProps(viewTag, props);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@DoNotStrip
|
|
101
|
+
private void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
|
|
102
|
+
mNodesManager.synchronouslyUpdateUIProps(viewTag, uiProps);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@DoNotStrip
|
|
106
|
+
private String obtainProp(int viewTag, String propName) {
|
|
107
|
+
return mNodesManager.obtainProp(viewTag, propName);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@DoNotStrip
|
|
111
|
+
private void scrollTo(int viewTag, double x, double y, boolean animated) {
|
|
112
|
+
mNodesManager.scrollTo(viewTag, x, y, animated);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@DoNotStrip
|
|
116
|
+
private void setGestureState(int handlerTag, int newState) {
|
|
117
|
+
if (gestureHandlerStateManager != null) {
|
|
118
|
+
gestureHandlerStateManager.setGestureHandlerState(handlerTag, newState);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@DoNotStrip
|
|
123
|
+
private long getCurrentTime() {
|
|
124
|
+
if (slowAnimationsEnabled) {
|
|
125
|
+
final long ANIMATIONS_DRAG_FACTOR = 10;
|
|
126
|
+
return this.firstUptime
|
|
127
|
+
+ (SystemClock.uptimeMillis() - this.firstUptime) / ANIMATIONS_DRAG_FACTOR;
|
|
128
|
+
} else {
|
|
129
|
+
return SystemClock.uptimeMillis();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@DoNotStrip
|
|
134
|
+
private float[] measure(int viewTag) {
|
|
135
|
+
return mNodesManager.measure(viewTag);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@DoNotStrip
|
|
139
|
+
private void configureProps(ReadableNativeArray uiProps, ReadableNativeArray nativeProps) {
|
|
140
|
+
Set<String> uiPropsSet = convertProps(uiProps);
|
|
141
|
+
Set<String> nativePropsSet = convertProps(nativeProps);
|
|
142
|
+
mNodesManager.configureProps(uiPropsSet, nativePropsSet);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private Set<String> convertProps(ReadableNativeArray props) {
|
|
146
|
+
Set<String> propsSet = new HashSet<>();
|
|
147
|
+
ArrayList<Object> propsList = props.toArrayList();
|
|
148
|
+
for (int i = 0; i < propsList.size(); i++) {
|
|
149
|
+
propsSet.add((String) propsList.get(i));
|
|
150
|
+
}
|
|
151
|
+
return propsSet;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@DoNotStrip
|
|
155
|
+
private void registerEventHandler(EventHandler handler) {
|
|
156
|
+
handler.mCustomEventNamesResolver = mNodesManager.getEventNameResolver();
|
|
157
|
+
mNodesManager.registerEventHandler(handler);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@DoNotStrip
|
|
161
|
+
private int registerSensor(int sensorType, int interval, SensorSetter setter) {
|
|
162
|
+
return reanimatedSensorContainer.registerSensor(
|
|
163
|
+
ReanimatedSensorType.getInstanceById(sensorType), interval, setter);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@DoNotStrip
|
|
167
|
+
private void unregisterSensor(int sensorId) {
|
|
168
|
+
reanimatedSensorContainer.unregisterSensor(sensorId);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@DoNotStrip
|
|
172
|
+
private int subscribeForKeyboardEvents(
|
|
173
|
+
KeyboardEventDataUpdater keyboardEventDataUpdater, boolean isStatusBarTranslucent) {
|
|
174
|
+
return reanimatedKeyboardEventListener.subscribeForKeyboardEvents(
|
|
175
|
+
keyboardEventDataUpdater, isStatusBarTranslucent);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@DoNotStrip
|
|
179
|
+
private void unsubscribeFromKeyboardEvents(int listenerId) {
|
|
180
|
+
reanimatedKeyboardEventListener.unsubscribeFromKeyboardEvents(listenerId);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
protected abstract HybridData getHybridData();
|
|
184
|
+
|
|
185
|
+
public void onCatalystInstanceDestroy() {
|
|
186
|
+
mScheduler.deactivate();
|
|
187
|
+
getHybridData().resetNative();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public void prepareLayoutAnimations(LayoutAnimations layoutAnimations) {
|
|
191
|
+
if (Utils.isChromeDebugger) {
|
|
192
|
+
Log.w("[REANIMATED]", "You can not use LayoutAnimation with enabled Chrome Debugger");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
mNodesManager = mContext.get().getNativeModule(ReanimatedModule.class).getNodesManager();
|
|
196
|
+
|
|
197
|
+
AnimationsManager animationsManager =
|
|
198
|
+
mContext
|
|
199
|
+
.get()
|
|
200
|
+
.getNativeModule(ReanimatedModule.class)
|
|
201
|
+
.getNodesManager()
|
|
202
|
+
.getAnimationsManager();
|
|
203
|
+
|
|
204
|
+
animationsManager.setNativeMethods(NativeProxy.createNativeMethodsHolder(layoutAnimations));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nativeProxy;
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData;
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
5
|
+
|
|
6
|
+
@DoNotStrip
|
|
7
|
+
public class SensorSetter {
|
|
8
|
+
|
|
9
|
+
@DoNotStrip private final HybridData mHybridData;
|
|
10
|
+
|
|
11
|
+
@DoNotStrip
|
|
12
|
+
private SensorSetter(HybridData hybridData) {
|
|
13
|
+
mHybridData = hybridData;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public native void sensorSetter(float[] value, int orientationDegrees);
|
|
17
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
package com.swmansion.reanimated.sensor;
|
|
2
2
|
|
|
3
|
+
import static android.content.Context.WINDOW_SERVICE;
|
|
4
|
+
|
|
3
5
|
import android.hardware.Sensor;
|
|
4
6
|
import android.hardware.SensorManager;
|
|
7
|
+
import android.view.Display;
|
|
8
|
+
import android.view.WindowManager;
|
|
5
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
-
import com.swmansion.reanimated.
|
|
10
|
+
import com.swmansion.reanimated.nativeProxy.SensorSetter;
|
|
7
11
|
import java.lang.ref.WeakReference;
|
|
8
12
|
|
|
9
13
|
public class ReanimatedSensor {
|
|
@@ -18,8 +22,10 @@ public class ReanimatedSensor {
|
|
|
18
22
|
WeakReference<ReactApplicationContext> reactContext,
|
|
19
23
|
ReanimatedSensorType sensorType,
|
|
20
24
|
int interval,
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
SensorSetter setter) {
|
|
26
|
+
WindowManager wm = (WindowManager) reactContext.get().getSystemService(WINDOW_SERVICE);
|
|
27
|
+
Display display = wm.getDefaultDisplay();
|
|
28
|
+
listener = new ReanimatedSensorListener(setter, interval, display);
|
|
23
29
|
sensorManager =
|
|
24
30
|
(SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE);
|
|
25
31
|
this.sensorType = sensorType;
|
package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java
CHANGED
|
@@ -2,7 +2,7 @@ package com.swmansion.reanimated.sensor;
|
|
|
2
2
|
|
|
3
3
|
import android.util.Log;
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
-
import com.swmansion.reanimated.
|
|
5
|
+
import com.swmansion.reanimated.nativeProxy.SensorSetter;
|
|
6
6
|
import java.lang.ref.WeakReference;
|
|
7
7
|
import java.util.HashMap;
|
|
8
8
|
|
|
@@ -16,14 +16,13 @@ public class ReanimatedSensorContainer {
|
|
|
16
16
|
this.reactContext = reactContext;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
public int registerSensor(
|
|
20
|
-
ReanimatedSensorType sensorType, int interval, NativeProxy.SensorSetter setter) {
|
|
19
|
+
public int registerSensor(ReanimatedSensorType sensorType, int interval, SensorSetter setter) {
|
|
21
20
|
ReanimatedSensor sensor = new ReanimatedSensor(reactContext, sensorType, interval, setter);
|
|
22
21
|
int sensorId = -1;
|
|
23
22
|
if (sensor.initialize()) {
|
|
24
23
|
sensorId = nextSensorId;
|
|
25
24
|
nextSensorId++;
|
|
26
|
-
sensors.put(sensorId,
|
|
25
|
+
sensors.put(sensorId, sensor);
|
|
27
26
|
}
|
|
28
27
|
return sensorId;
|
|
29
28
|
}
|
|
@@ -4,11 +4,13 @@ import android.hardware.Sensor;
|
|
|
4
4
|
import android.hardware.SensorEvent;
|
|
5
5
|
import android.hardware.SensorEventListener;
|
|
6
6
|
import android.hardware.SensorManager;
|
|
7
|
-
import
|
|
7
|
+
import android.view.Display;
|
|
8
|
+
import android.view.Surface;
|
|
9
|
+
import com.swmansion.reanimated.nativeProxy.SensorSetter;
|
|
8
10
|
|
|
9
11
|
public class ReanimatedSensorListener implements SensorEventListener {
|
|
10
12
|
|
|
11
|
-
private
|
|
13
|
+
private SensorSetter setter;
|
|
12
14
|
private double lastRead = (double) System.currentTimeMillis();
|
|
13
15
|
private final double interval;
|
|
14
16
|
|
|
@@ -16,9 +18,12 @@ public class ReanimatedSensorListener implements SensorEventListener {
|
|
|
16
18
|
private float[] orientation = new float[3];
|
|
17
19
|
private float[] quaternion = new float[4];
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
private final Display display;
|
|
22
|
+
|
|
23
|
+
ReanimatedSensorListener(SensorSetter setter, double interval, Display display) {
|
|
20
24
|
this.setter = setter;
|
|
21
25
|
this.interval = interval;
|
|
26
|
+
this.display = display;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
@Override
|
|
@@ -29,6 +34,23 @@ public class ReanimatedSensorListener implements SensorEventListener {
|
|
|
29
34
|
}
|
|
30
35
|
int sensorType = event.sensor.getType();
|
|
31
36
|
lastRead = current;
|
|
37
|
+
|
|
38
|
+
int orientationDegrees;
|
|
39
|
+
switch (display.getRotation()) {
|
|
40
|
+
case Surface.ROTATION_90:
|
|
41
|
+
orientationDegrees = 90;
|
|
42
|
+
break;
|
|
43
|
+
case Surface.ROTATION_180:
|
|
44
|
+
orientationDegrees = 180;
|
|
45
|
+
break;
|
|
46
|
+
case Surface.ROTATION_270:
|
|
47
|
+
orientationDegrees = 270;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
orientationDegrees = 0;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
|
|
32
54
|
if (sensorType == Sensor.TYPE_ROTATION_VECTOR) {
|
|
33
55
|
SensorManager.getQuaternionFromVector(quaternion, event.values);
|
|
34
56
|
SensorManager.getRotationMatrixFromVector(rotation, event.values);
|
|
@@ -39,13 +61,15 @@ public class ReanimatedSensorListener implements SensorEventListener {
|
|
|
39
61
|
quaternion[2], // qy
|
|
40
62
|
quaternion[3], // qz
|
|
41
63
|
quaternion[0], // qw
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
// make Android consistent with iOS, which is better documented here:
|
|
65
|
+
// https://developer.apple.com/documentation/coremotion/getting_processed_device-motion_data/understanding_reference_frames_and_device_attitude
|
|
66
|
+
-orientation[0], // yaw
|
|
67
|
+
-orientation[1], // pitch
|
|
44
68
|
orientation[2] // roll
|
|
45
69
|
};
|
|
46
|
-
setter.sensorSetter(data);
|
|
70
|
+
setter.sensorSetter(data, orientationDegrees);
|
|
47
71
|
} else {
|
|
48
|
-
setter.sensorSetter(event.values);
|
|
72
|
+
setter.sensorSetter(event.values, orientationDegrees);
|
|
49
73
|
}
|
|
50
74
|
}
|
|
51
75
|
|