react-native-reanimated 2.3.0-beta.3 → 2.4.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/NativeModules/NativeReanimatedModule.cpp +9 -0
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +38 -2
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +3 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +5 -0
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +8 -7
- package/README.md +1 -1
- package/RNReanimated.podspec +20 -3
- package/android/build.gradle +31 -5
- package/android/expo/linking.gradle +46 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +68 -19
- package/ios/LayoutReanimation/REAUIManager.mm +63 -18
- package/ios/Nodes/REAPropsNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +0 -3
- package/ios/REANodesManager.m +1 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/native/NativeMethods.h +5 -0
- package/ios/native/NativeMethods.mm +8 -1
- package/ios/native/NativeProxy.h +1 -0
- package/ios/native/NativeProxy.mm +19 -3
- package/ios/native/REAInitializer.mm +7 -3
- package/lib/src/Animated.js +31 -0
- package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
- package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
- package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
- package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
- package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
- package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
- package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
- package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +55 -37
- package/lib/src/index.js +31 -0
- package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +1 -1
- package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Colors.js +1 -97
- package/lib/{reanimated2 → src/reanimated2}/Easing.js +5 -0
- package/lib/src/reanimated2/NativeMethods.js +42 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +2 -2
- package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +1 -1
- package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +4 -2
- package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +5 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
- package/lib/src/reanimated2/component/FlatList.js +30 -0
- package/lib/src/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/src/reanimated2/component/index.js +4 -0
- package/lib/{reanimated2 → src/reanimated2}/core.js +27 -3
- package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +5 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +1 -2
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +31 -14
- package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +14 -11
- package/lib/{reanimated2 → src/reanimated2}/index.js +2 -0
- package/lib/src/reanimated2/interpolateColor.js +98 -0
- package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +4 -1
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +4 -1
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
- package/lib/{reanimated2/layoutReanimation/animationBuilder → src/reanimated2/js-reanimated}/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +3 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
- package/lib/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
- package/lib/src/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +16 -16
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
- package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
- package/mock.js +2 -1
- package/package.json +7 -4
- package/plugin.js +11 -3
- package/react-native-reanimated.d.ts +94 -23
- package/src/Animated.js +11 -5
- package/src/createAnimatedComponent.tsx +86 -43
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/Colors.ts +6 -150
- package/src/reanimated2/Easing.ts +11 -0
- package/src/reanimated2/NativeMethods.ts +31 -6
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -0
- package/src/reanimated2/NativeReanimated/index.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/commonTypes.ts +44 -40
- package/src/reanimated2/animation/decay.ts +1 -1
- package/src/reanimated2/animation/delay.ts +2 -16
- package/src/reanimated2/animation/index.ts +7 -8
- package/src/reanimated2/animation/repeat.ts +2 -12
- package/src/reanimated2/animation/sequence.ts +3 -10
- package/src/reanimated2/animation/spring.ts +1 -1
- package/src/reanimated2/animation/styleAnimation.ts +10 -18
- package/src/reanimated2/animation/timing.ts +1 -1
- package/src/reanimated2/animation/util.ts +12 -9
- package/src/reanimated2/commonTypes.ts +48 -1
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +39 -6
- package/src/reanimated2/globals.d.ts +5 -0
- package/src/reanimated2/hook/commonTypes.ts +5 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
- package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
- package/src/reanimated2/hook/utils.ts +18 -17
- package/src/reanimated2/index.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +178 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +9 -4
- package/src/reanimated2/js-reanimated/Mapper.ts +4 -2
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
- package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
- package/src/reanimated2/js-reanimated/index.ts +5 -0
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +18 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +15 -11
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/utils.ts +1 -1
- package/lib/Animated.js +0 -25
- package/lib/index.js +0 -25
- package/lib/reanimated2/NativeMethods.js +0 -25
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -36
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <thread>
|
|
5
5
|
#include "EventHandlerRegistry.h"
|
|
6
|
+
#include "FeaturesConfig.h"
|
|
6
7
|
#include "FrozenObject.h"
|
|
7
8
|
#include "JSIStoreValueUser.h"
|
|
8
9
|
#include "Mapper.h"
|
|
@@ -84,6 +85,7 @@ NativeReanimatedModule::NativeReanimatedModule(
|
|
|
84
85
|
platformDepMethodsHolder.scrollToFunction,
|
|
85
86
|
platformDepMethodsHolder.measuringFunction,
|
|
86
87
|
platformDepMethodsHolder.getCurrentTime,
|
|
88
|
+
platformDepMethodsHolder.setGestureStateFunction,
|
|
87
89
|
layoutAnimationsProxy);
|
|
88
90
|
onRenderCallback = [this](double timestampMs) {
|
|
89
91
|
this->renderRequested = false;
|
|
@@ -234,6 +236,13 @@ jsi::Value NativeReanimatedModule::getViewProp(
|
|
|
234
236
|
return jsi::Value::undefined();
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
jsi::Value NativeReanimatedModule::enableLayoutAnimations(
|
|
240
|
+
jsi::Runtime &rt,
|
|
241
|
+
const jsi::Value &config) {
|
|
242
|
+
FeaturesConfig::setLayoutAnimationEnabled(config.getBool());
|
|
243
|
+
return jsi::Value::undefined();
|
|
244
|
+
}
|
|
245
|
+
|
|
237
246
|
void NativeReanimatedModule::onEvent(
|
|
238
247
|
std::string eventName,
|
|
239
248
|
std::string eventAsString) {
|
|
@@ -99,6 +99,17 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_getViewProp(
|
|
|
99
99
|
return jsi::Value::undefined();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
static jsi::Value
|
|
103
|
+
__hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations(
|
|
104
|
+
jsi::Runtime &rt,
|
|
105
|
+
TurboModule &turboModule,
|
|
106
|
+
const jsi::Value *args,
|
|
107
|
+
size_t count) {
|
|
108
|
+
static_cast<NativeReanimatedModuleSpec *>(&turboModule)
|
|
109
|
+
->enableLayoutAnimations(rt, std::move(args[0]));
|
|
110
|
+
return jsi::Value::undefined();
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
103
114
|
std::shared_ptr<CallInvoker> jsInvoker)
|
|
104
115
|
: TurboModule("NativeReanimated", jsInvoker) {
|
|
@@ -124,6 +135,8 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
|
124
135
|
|
|
125
136
|
methodMap_["getViewProp"] =
|
|
126
137
|
MethodMetadata{3, __hostFunction_NativeReanimatedModuleSpec_getViewProp};
|
|
138
|
+
methodMap_["enableLayoutAnimations"] = MethodMetadata{
|
|
139
|
+
2, __hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations};
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
} // namespace reanimated
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "RuntimeDecorator.h"
|
|
2
|
+
#include <chrono>
|
|
2
3
|
#include <memory>
|
|
3
4
|
#include <unordered_map>
|
|
4
5
|
#include "LayoutAnimationsProxy.h"
|
|
@@ -8,11 +9,15 @@
|
|
|
8
9
|
namespace reanimated {
|
|
9
10
|
|
|
10
11
|
std::unordered_map<RuntimePointer, RuntimeType>
|
|
11
|
-
RuntimeDecorator::runtimeRegistry
|
|
12
|
+
&RuntimeDecorator::runtimeRegistry() {
|
|
13
|
+
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
14
|
+
return runtimeRegistry;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
void RuntimeDecorator::registerRuntime(
|
|
13
18
|
jsi::Runtime *runtime,
|
|
14
19
|
RuntimeType runtimeType) {
|
|
15
|
-
runtimeRegistry.insert({runtime, runtimeType});
|
|
20
|
+
runtimeRegistry().insert({runtime, runtimeType});
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
void RuntimeDecorator::decorateRuntime(
|
|
@@ -79,6 +84,22 @@ void RuntimeDecorator::decorateRuntime(
|
|
|
79
84
|
jsi::PropNameID::forAscii(rt, "_setGlobalConsole"),
|
|
80
85
|
1,
|
|
81
86
|
setGlobalConsole));
|
|
87
|
+
|
|
88
|
+
rt.global().setProperty(
|
|
89
|
+
rt,
|
|
90
|
+
"_chronoNow",
|
|
91
|
+
jsi::Function::createFromHostFunction(
|
|
92
|
+
rt,
|
|
93
|
+
jsi::PropNameID::forAscii(rt, "_chronoNow"),
|
|
94
|
+
0,
|
|
95
|
+
[](jsi::Runtime &rt,
|
|
96
|
+
const jsi::Value &thisValue,
|
|
97
|
+
const jsi::Value *args,
|
|
98
|
+
size_t count) -> jsi::Value {
|
|
99
|
+
double now = std::chrono::system_clock::now().time_since_epoch() /
|
|
100
|
+
std::chrono::milliseconds(1);
|
|
101
|
+
return jsi::Value(now);
|
|
102
|
+
}));
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
void RuntimeDecorator::decorateUIRuntime(
|
|
@@ -88,6 +109,7 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
88
109
|
const ScrollToFunction scrollTo,
|
|
89
110
|
const MeasuringFunction measure,
|
|
90
111
|
const TimeProviderFunction getCurrentTime,
|
|
112
|
+
const SetGestureStateFunction setGestureState,
|
|
91
113
|
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy) {
|
|
92
114
|
RuntimeDecorator::decorateRuntime(rt, "UI");
|
|
93
115
|
rt.global().setProperty(rt, "_UI", jsi::Value(true));
|
|
@@ -207,6 +229,20 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
207
229
|
jsi::Value _stopObservingProgress = jsi::Function::createFromHostFunction(
|
|
208
230
|
rt, jsi::PropNameID::forAscii(rt, "_stopObservingProgress"), 0, clb8);
|
|
209
231
|
rt.global().setProperty(rt, "_stopObservingProgress", _stopObservingProgress);
|
|
232
|
+
|
|
233
|
+
auto clb9 = [setGestureState](
|
|
234
|
+
jsi::Runtime &rt,
|
|
235
|
+
const jsi::Value &thisValue,
|
|
236
|
+
const jsi::Value *args,
|
|
237
|
+
size_t count) -> jsi::Value {
|
|
238
|
+
int handlerTag = static_cast<int>(args[0].asNumber());
|
|
239
|
+
int newState = static_cast<int>(args[1].asNumber());
|
|
240
|
+
setGestureState(handlerTag, newState);
|
|
241
|
+
return jsi::Value::undefined();
|
|
242
|
+
};
|
|
243
|
+
jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
|
|
244
|
+
rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
|
|
245
|
+
rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
|
|
210
246
|
}
|
|
211
247
|
|
|
212
248
|
} // namespace reanimated
|
|
@@ -68,6 +68,9 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
|
|
|
68
68
|
const jsi::Value &propName,
|
|
69
69
|
const jsi::Value &callback) override;
|
|
70
70
|
|
|
71
|
+
jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config)
|
|
72
|
+
override;
|
|
73
|
+
|
|
71
74
|
void onRender(double timestampMs);
|
|
72
75
|
void onEvent(std::string eventName, std::string eventAsString);
|
|
73
76
|
bool isAnyHandlerWaitingForEvent(std::string eventName);
|
|
@@ -58,6 +58,11 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
|
|
|
58
58
|
const jsi::Value &viewTag,
|
|
59
59
|
const jsi::Value &propName,
|
|
60
60
|
const jsi::Value &callback) = 0;
|
|
61
|
+
|
|
62
|
+
// other
|
|
63
|
+
virtual jsi::Value enableLayoutAnimations(
|
|
64
|
+
jsi::Runtime &rt,
|
|
65
|
+
const jsi::Value &config) = 0;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
} // namespace reanimated
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
namespace reanimated {
|
|
5
|
+
|
|
6
|
+
class FeaturesConfig {
|
|
7
|
+
public:
|
|
8
|
+
static inline bool isLayoutAnimationEnabled() {
|
|
9
|
+
return _isLayoutAnimationEnabled;
|
|
10
|
+
}
|
|
11
|
+
static inline void setLayoutAnimationEnabled(bool isLayoutAnimationEnabled) {
|
|
12
|
+
_isLayoutAnimationEnabled = isLayoutAnimationEnabled;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private:
|
|
16
|
+
static bool _isLayoutAnimationEnabled;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace reanimated
|
|
@@ -21,6 +21,7 @@ using ScrollToFunction = std::function<void(int, double, double, bool)>;
|
|
|
21
21
|
using MeasuringFunction =
|
|
22
22
|
std::function<std::vector<std::pair<std::string, double>>(int)>;
|
|
23
23
|
using TimeProviderFunction = std::function<double(void)>;
|
|
24
|
+
using SetGestureStateFunction = std::function<void(int, int)>;
|
|
24
25
|
|
|
25
26
|
struct PlatformDepMethodsHolder {
|
|
26
27
|
RequestRender requestRender;
|
|
@@ -28,6 +29,7 @@ struct PlatformDepMethodsHolder {
|
|
|
28
29
|
ScrollToFunction scrollToFunction;
|
|
29
30
|
MeasuringFunction measuringFunction;
|
|
30
31
|
TimeProviderFunction getCurrentTime;
|
|
32
|
+
SetGestureStateFunction setGestureStateFunction;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
} // namespace reanimated
|
|
@@ -36,6 +36,7 @@ class RuntimeDecorator {
|
|
|
36
36
|
const ScrollToFunction scrollTo,
|
|
37
37
|
const MeasuringFunction measure,
|
|
38
38
|
const TimeProviderFunction getCurrentTime,
|
|
39
|
+
const SetGestureStateFunction setGestureState,
|
|
39
40
|
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy);
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -58,27 +59,27 @@ class RuntimeDecorator {
|
|
|
58
59
|
static void registerRuntime(jsi::Runtime *runtime, RuntimeType runtimeType);
|
|
59
60
|
|
|
60
61
|
private:
|
|
61
|
-
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
62
|
+
static std::unordered_map<RuntimePointer, RuntimeType> &runtimeRegistry();
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
inline bool RuntimeDecorator::isUIRuntime(jsi::Runtime &rt) {
|
|
65
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
66
|
-
if (iterator == runtimeRegistry.end())
|
|
66
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
67
|
+
if (iterator == runtimeRegistry().end())
|
|
67
68
|
return false;
|
|
68
69
|
return iterator->second == RuntimeType::UI;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
inline bool RuntimeDecorator::isWorkletRuntime(jsi::Runtime &rt) {
|
|
72
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
73
|
-
if (iterator == runtimeRegistry.end())
|
|
73
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
74
|
+
if (iterator == runtimeRegistry().end())
|
|
74
75
|
return false;
|
|
75
76
|
auto type = iterator->second;
|
|
76
77
|
return type == RuntimeType::UI || type == RuntimeType::Worklet;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
inline bool RuntimeDecorator::isReactRuntime(jsi::Runtime &rt) {
|
|
80
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
81
|
-
if (iterator == runtimeRegistry.end())
|
|
81
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
82
|
+
if (iterator == runtimeRegistry().end())
|
|
82
83
|
return true;
|
|
83
84
|
return false;
|
|
84
85
|
}
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Check out our dedicated documentation page for info about this library, API refe
|
|
|
19
19
|
|
|
20
20
|
## Examples
|
|
21
21
|
|
|
22
|
-
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/
|
|
22
|
+
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/main/Example/) directory.
|
|
23
23
|
If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check Example/ directory README for installation instructions.
|
|
24
24
|
|
|
25
25
|
## License
|
package/RNReanimated.podspec
CHANGED
|
@@ -5,10 +5,28 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
|
5
5
|
reactVersion = '0.0.0'
|
|
6
6
|
|
|
7
7
|
begin
|
|
8
|
+
# standard app
|
|
9
|
+
# /appName/node_modules/react-native-reanimated/RNReanimated.podspec
|
|
10
|
+
# /appName/node_modules/react-native/package.json
|
|
8
11
|
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json")))["version"]
|
|
9
12
|
rescue
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
begin
|
|
14
|
+
# monorepo
|
|
15
|
+
# /monorepo/packages/appName/node_modules/react-native-reanimated/RNReanimated.podspec
|
|
16
|
+
# /monorepo/node_modules/react-native/package.json
|
|
17
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "node_modules", "react-native", "package.json")))["version"]
|
|
18
|
+
rescue
|
|
19
|
+
begin
|
|
20
|
+
# Example app in reanimated repo
|
|
21
|
+
# /react-native-reanimated/RNReanimated.podspec
|
|
22
|
+
# /react-native-reanimated/node_modules/react-native/package.json
|
|
23
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "node_modules", "react-native", "package.json")))["version"]
|
|
24
|
+
rescue
|
|
25
|
+
# should never happen
|
|
26
|
+
reactVersion = '0.66.0'
|
|
27
|
+
puts "[RNReanimated] Unable to recognized your `react-native` version! Default `react-native` version: " + reactVersion
|
|
28
|
+
end
|
|
29
|
+
end
|
|
12
30
|
end
|
|
13
31
|
|
|
14
32
|
rnVersion = reactVersion.split('.')[1]
|
|
@@ -75,7 +93,6 @@ Pod::Spec.new do |s|
|
|
|
75
93
|
s.dependency 'React-RCTBlob'
|
|
76
94
|
s.dependency 'React-RCTSettings'
|
|
77
95
|
s.dependency 'React-RCTText'
|
|
78
|
-
s.dependency 'React-RCTVibration'
|
|
79
96
|
s.dependency 'React-RCTImage'
|
|
80
97
|
s.dependency 'React-Core/RCTWebSocket'
|
|
81
98
|
s.dependency 'React-cxxreact'
|
package/android/build.gradle
CHANGED
|
@@ -31,14 +31,14 @@ abstract class replaceSoTask extends DefaultTask {
|
|
|
31
31
|
def getCurrentFlavor() {
|
|
32
32
|
Gradle gradle = getGradle()
|
|
33
33
|
String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
|
|
34
|
-
Pattern pattern = Pattern.compile("(assemble|install|generate)(\\w
|
|
34
|
+
Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
|
|
35
35
|
Matcher matcher = pattern.matcher(taskRequestName)
|
|
36
36
|
|
|
37
37
|
if(matcher.find()) {
|
|
38
38
|
return matcher.group(2)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return ""
|
|
41
|
+
return "NOT-FOUND"
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
def replaceSoTaskDebug
|
|
@@ -58,8 +58,9 @@ rootProject.getSubprojects().forEach({project ->
|
|
|
58
58
|
|
|
59
59
|
if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
|
|
60
60
|
def projectProperties = project.getProperties()
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
final NOTFOUND = "NOT-FOUND"
|
|
62
|
+
if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
|
|
63
|
+
|| (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
|
|
63
64
|
) {
|
|
64
65
|
def flavorString = getCurrentFlavor()
|
|
65
66
|
replaceSoTask.appName = project.getProperties().path
|
|
@@ -82,4 +83,29 @@ rootProject.getSubprojects().forEach({project ->
|
|
|
82
83
|
}
|
|
83
84
|
})
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
def minorCopy = Integer.parseInt(minor)
|
|
87
|
+
def aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
|
|
88
|
+
|
|
89
|
+
while (!aar.exists()) {
|
|
90
|
+
minorCopy -= 1
|
|
91
|
+
aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
|
|
92
|
+
if (minorCopy < 63) {
|
|
93
|
+
throw new GradleException('No aar for react-native-reanimated found.')
|
|
94
|
+
}
|
|
95
|
+
if (aar.exists()) {
|
|
96
|
+
println "\n\n\n"
|
|
97
|
+
println "****************************************************************************************"
|
|
98
|
+
println "\n\n\n"
|
|
99
|
+
println "WARNING reanimated - no version-specific reanimated AAR for react-native version " + minor + " found."
|
|
100
|
+
println "Falling back to AAR for react-native version " + minorCopy
|
|
101
|
+
println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
|
|
102
|
+
println "Please post a pull request to implement support for react-native version " + minor + " to the reanimated repo."
|
|
103
|
+
println "Thanks!"
|
|
104
|
+
println "\n\n\n"
|
|
105
|
+
println "****************************************************************************************"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
artifacts.add("default", aar)
|
|
110
|
+
|
|
111
|
+
apply from: './expo/linking.gradle'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
def isExpoLinked = false
|
|
2
|
+
rootProject.getSubprojects().forEach({ project ->
|
|
3
|
+
if (project.plugins.hasPlugin("com.android.application")) {
|
|
4
|
+
if (project.configurations.implementation.getDependencies().find { dep -> dep.name == "expo" }) {
|
|
5
|
+
isExpoLinked = true
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
def safeExtGet(prop, fallback) {
|
|
11
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isExpoLinked) {
|
|
15
|
+
apply plugin: 'com.android.library'
|
|
16
|
+
|
|
17
|
+
android {
|
|
18
|
+
// Disable aar bundling to fix the error when running `gradle assembleRelease` over `gradle :app:assembleRelease`
|
|
19
|
+
// which will throw `Direct local .aar file dependencies are not supported when building an AAR.`
|
|
20
|
+
tasks.whenTaskAdded { task ->
|
|
21
|
+
if (['bundleDebugAar', 'bundleReleaseAar'].contains(task.name)) {
|
|
22
|
+
task.enabled = false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
27
|
+
|
|
28
|
+
sourceSets {
|
|
29
|
+
main.manifest.srcFile 'src/AndroidManifest.xml'
|
|
30
|
+
main.java.srcDirs = [ 'expo/src/main/java' ]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
libraryVariants.all {
|
|
34
|
+
generateBuildConfigProvider?.get()?.enabled = false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dependencies {
|
|
39
|
+
implementation 'com.facebook.react:react-native:+'
|
|
40
|
+
implementation project(':expo-modules-core')
|
|
41
|
+
|
|
42
|
+
project.configurations.default.artifacts.each { artifact ->
|
|
43
|
+
api files(artifact.file)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
|
|
6
|
+
public class EXReanimatedAdapter {
|
|
7
|
+
public static void registerJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) {
|
|
8
|
+
NodesManager nodesManager =
|
|
9
|
+
reactApplicationContext.getNativeModule(ReanimatedModule.class).getNodesManager();
|
|
10
|
+
nodesManager.initWithContext(reactApplicationContext);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package expo.modules.adapters.reanimated;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.swmansion.reanimated.EXReanimatedAdapter;
|
|
8
|
+
|
|
9
|
+
import java.util.Collections;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
import expo.modules.core.interfaces.Package;
|
|
13
|
+
import expo.modules.core.interfaces.ReactNativeHostHandler;
|
|
14
|
+
|
|
15
|
+
public class EXReanimatedPackage implements Package {
|
|
16
|
+
@Override
|
|
17
|
+
public List<? extends ReactNativeHostHandler> createReactNativeHostHandlers(Context context) {
|
|
18
|
+
final ReactNativeHostHandler handler = new ReactNativeHostHandler() {
|
|
19
|
+
@Override
|
|
20
|
+
public void onRegisterJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext, boolean useDeveloperSupport) {
|
|
21
|
+
EXReanimatedAdapter.registerJSIModules(reactApplicationContext, jsContext);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return Collections.singletonList(handler);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
@interface REAAnimationsManager ()
|
|
9
9
|
|
|
10
|
+
typedef NS_ENUM(NSInteger, FrameConfigType) { EnteringFrame, ExitingFrame };
|
|
11
|
+
|
|
10
12
|
@property (atomic, nullable) void (^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber *);
|
|
11
13
|
@property (atomic, nullable) void (^removeConfigForTag)(NSNumber *);
|
|
12
14
|
|
|
@@ -21,6 +23,8 @@
|
|
|
21
23
|
NSMutableDictionary<NSNumber *, NSNumber *> *_states;
|
|
22
24
|
NSMutableDictionary<NSNumber *, UIView *> *_viewForTag;
|
|
23
25
|
NSMutableSet<NSNumber *> *_toRemove;
|
|
26
|
+
NSMutableArray<NSString *> *_targetKeys;
|
|
27
|
+
NSMutableArray<NSString *> *_currentKeys;
|
|
24
28
|
BOOL _cleaningScheduled;
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -43,6 +47,13 @@
|
|
|
43
47
|
_viewForTag = [NSMutableDictionary new];
|
|
44
48
|
_toRemove = [NSMutableSet new];
|
|
45
49
|
_cleaningScheduled = false;
|
|
50
|
+
|
|
51
|
+
_targetKeys = [NSMutableArray new];
|
|
52
|
+
_currentKeys = [NSMutableArray new];
|
|
53
|
+
for (NSString *key in [[self class] layoutKeys]) {
|
|
54
|
+
[_targetKeys addObject:[NSString stringWithFormat:@"target%@", [key capitalizedString]]];
|
|
55
|
+
[_currentKeys addObject:[NSString stringWithFormat:@"current%@", [key capitalizedString]]];
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
return self;
|
|
48
59
|
}
|
|
@@ -56,6 +67,8 @@
|
|
|
56
67
|
_viewForTag = nil;
|
|
57
68
|
_toRemove = nil;
|
|
58
69
|
_cleaningScheduled = false;
|
|
70
|
+
_targetKeys = nil;
|
|
71
|
+
_currentKeys = nil;
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
- (void)setAnimationStartingBlock:
|
|
@@ -137,6 +150,10 @@
|
|
|
137
150
|
NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
|
|
138
151
|
for (NSNumber *viewTag in _toRemove) {
|
|
139
152
|
UIView *view = _viewForTag[viewTag];
|
|
153
|
+
if (view == nil) {
|
|
154
|
+
view = [_reaUiManager viewForReactTag:viewTag];
|
|
155
|
+
_viewForTag[viewTag] = view;
|
|
156
|
+
}
|
|
140
157
|
[self findRoot:view roots:roots];
|
|
141
158
|
}
|
|
142
159
|
for (NSNumber *viewTag in roots) {
|
|
@@ -208,16 +225,53 @@
|
|
|
208
225
|
[componentData setProps:newProps forView:view];
|
|
209
226
|
}
|
|
210
227
|
|
|
211
|
-
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
|
|
228
|
+
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values frameConfig:(FrameConfigType)frameConfig
|
|
229
|
+
{
|
|
230
|
+
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
231
|
+
if (frameConfig == EnteringFrame) {
|
|
232
|
+
NSDictionary *preparedData = @{
|
|
233
|
+
@"targetWidth" : values[@"width"],
|
|
234
|
+
@"targetHeight" : values[@"height"],
|
|
235
|
+
@"targetOriginX" : values[@"originX"],
|
|
236
|
+
@"targetOriginY" : values[@"originY"],
|
|
237
|
+
@"targetGlobalOriginX" : values[@"globalOriginX"],
|
|
238
|
+
@"targetGlobalOriginY" : values[@"globalOriginY"],
|
|
239
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
240
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
241
|
+
};
|
|
242
|
+
return preparedData;
|
|
243
|
+
} else {
|
|
244
|
+
NSDictionary *preparedData = @{
|
|
245
|
+
@"currentWidth" : values[@"width"],
|
|
246
|
+
@"currentHeight" : values[@"height"],
|
|
247
|
+
@"currentOriginX" : values[@"originX"],
|
|
248
|
+
@"currentOriginY" : values[@"originY"],
|
|
249
|
+
@"currentGlobalOriginX" : values[@"globalOriginX"],
|
|
250
|
+
@"currentGlobalOriginY" : values[@"globalOriginY"],
|
|
251
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
252
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
253
|
+
};
|
|
254
|
+
return preparedData;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
- (NSDictionary *)prepareDataForLayoutAnimatingWorklet:(NSMutableDictionary *)currentValues
|
|
259
|
+
targetValues:(NSMutableDictionary *)targetValues
|
|
212
260
|
{
|
|
213
261
|
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
214
262
|
NSDictionary *preparedData = @{
|
|
215
|
-
@"
|
|
216
|
-
@"
|
|
217
|
-
@"
|
|
218
|
-
@"
|
|
219
|
-
@"
|
|
220
|
-
@"
|
|
263
|
+
@"currentWidth" : currentValues[@"width"],
|
|
264
|
+
@"currentHeight" : currentValues[@"height"],
|
|
265
|
+
@"currentOriginX" : currentValues[@"originX"],
|
|
266
|
+
@"currentOriginY" : currentValues[@"originY"],
|
|
267
|
+
@"currentGlobalOriginX" : currentValues[@"globalOriginX"],
|
|
268
|
+
@"currentGlobalOriginY" : currentValues[@"globalOriginY"],
|
|
269
|
+
@"targetWidth" : targetValues[@"width"],
|
|
270
|
+
@"targetHeight" : targetValues[@"height"],
|
|
271
|
+
@"targetOriginX" : targetValues[@"originX"],
|
|
272
|
+
@"targetOriginY" : targetValues[@"originY"],
|
|
273
|
+
@"targetGlobalOriginX" : targetValues[@"globalOriginX"],
|
|
274
|
+
@"targetGlobalOriginY" : targetValues[@"globalOriginY"],
|
|
221
275
|
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
222
276
|
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
223
277
|
};
|
|
@@ -241,7 +295,7 @@
|
|
|
241
295
|
return;
|
|
242
296
|
}
|
|
243
297
|
_states[tag] = [NSNumber numberWithInt:Disappearing];
|
|
244
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
298
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues frameConfig:ExitingFrame];
|
|
245
299
|
_startAnimationForTag(tag, @"exiting", preparedValues, @(0));
|
|
246
300
|
}
|
|
247
301
|
|
|
@@ -257,7 +311,7 @@
|
|
|
257
311
|
ViewState state = [_states[tag] intValue];
|
|
258
312
|
if (state == Inactive) {
|
|
259
313
|
if (targetValues != nil) {
|
|
260
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
314
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
|
|
261
315
|
_startAnimationForTag(tag, @"entering", preparedValues, @(0));
|
|
262
316
|
}
|
|
263
317
|
return;
|
|
@@ -268,7 +322,7 @@
|
|
|
268
322
|
{
|
|
269
323
|
NSNumber *tag = view.reactTag;
|
|
270
324
|
NSMutableDictionary *targetValues = after.values;
|
|
271
|
-
NSMutableDictionary *
|
|
325
|
+
NSMutableDictionary *currentValues = before.values;
|
|
272
326
|
if (_states[tag] == nil) {
|
|
273
327
|
return;
|
|
274
328
|
}
|
|
@@ -278,8 +332,9 @@
|
|
|
278
332
|
}
|
|
279
333
|
if (state == Appearing) {
|
|
280
334
|
BOOL doNotStartLayout = true;
|
|
281
|
-
for (
|
|
282
|
-
if ([((NSNumber *)
|
|
335
|
+
for (int i = 0; i < [[self class] layoutKeys].count; ++i) {
|
|
336
|
+
if ([((NSNumber *)currentValues[_currentKeys[i]]) doubleValue] !=
|
|
337
|
+
[((NSNumber *)targetValues[_targetKeys[i]]) doubleValue]) {
|
|
283
338
|
doNotStartLayout = false;
|
|
284
339
|
}
|
|
285
340
|
}
|
|
@@ -288,13 +343,7 @@
|
|
|
288
343
|
}
|
|
289
344
|
}
|
|
290
345
|
_states[view.reactTag] = [NSNumber numberWithInt:Layout];
|
|
291
|
-
NSDictionary *
|
|
292
|
-
NSDictionary *preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
293
|
-
NSMutableDictionary *preparedValues = [NSMutableDictionary new];
|
|
294
|
-
[preparedValues addEntriesFromDictionary:preparedTargetValues];
|
|
295
|
-
for (NSString *key in preparedStartValues.allKeys) {
|
|
296
|
-
preparedValues[[NSString stringWithFormat:@"%@%@", @"b", key]] = preparedStartValues[key];
|
|
297
|
-
}
|
|
346
|
+
NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
|
|
298
347
|
_startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
|
|
299
348
|
}
|
|
300
349
|
|