react-native-reanimated 3.0.0-rc.7 → 3.0.0-rc.9
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 +32 -37
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +4 -3
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +76 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +41 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +168 -167
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +36 -34
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +22 -34
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +13 -14
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +30 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +1 -1
- package/Common/cpp/SharedItems/RuntimeManager.h +1 -34
- package/Common/cpp/SharedItems/Shareables.cpp +144 -0
- package/Common/cpp/SharedItems/Shareables.h +470 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +79 -50
- package/Common/cpp/Tools/RuntimeDecorator.h +13 -3
- package/Common/cpp/Tools/Scheduler.cpp +10 -0
- package/Common/cpp/Tools/SingleInstanceChecker.h +1 -1
- package/android/src/main/cpp/LayoutAnimations.cpp +6 -16
- package/android/src/main/cpp/LayoutAnimations.h +4 -4
- package/android/src/main/cpp/NativeProxy.cpp +50 -63
- package/ios/LayoutReanimation/REAAnimationsManager.h +3 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +49 -16
- package/ios/LayoutReanimation/REAUIManager.mm +22 -62
- package/ios/native/NativeProxy.mm +26 -42
- package/lib/commonjs/createAnimatedComponent.js +7 -11
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +27 -55
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -3
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +7 -0
- 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 +74 -240
- 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/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +15 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +18 -8
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +27 -36
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +23 -59
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +3 -2
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +157 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +8 -33
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +14 -103
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -7
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +5 -0
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +87 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +186 -0
- package/lib/commonjs/reanimated2/mappers.js.map +1 -0
- package/lib/commonjs/reanimated2/mock.js +26 -0
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +173 -0
- package/lib/commonjs/reanimated2/mutables.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +159 -0
- package/lib/commonjs/reanimated2/shareables.js.map +1 -0
- package/lib/commonjs/reanimated2/threads.js +58 -0
- package/lib/commonjs/reanimated2/threads.js.map +1 -0
- package/lib/commonjs/reanimated2/time.js +55 -0
- package/lib/commonjs/reanimated2/time.js.map +1 -0
- package/lib/commonjs/reanimated2/valueSetter.js +81 -0
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -0
- package/lib/module/createAnimatedComponent.js +7 -12
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +24 -25
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +27 -53
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +4 -3
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +7 -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 +33 -226
- 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/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +16 -6
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +17 -8
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +29 -34
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +26 -62
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +3 -2
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +143 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +8 -31
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +14 -98
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +4 -7
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +5 -0
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +173 -0
- package/lib/module/reanimated2/mappers.js.map +1 -0
- package/lib/module/reanimated2/mock.js +26 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +149 -0
- package/lib/module/reanimated2/mutables.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +138 -0
- package/lib/module/reanimated2/shareables.js.map +1 -0
- package/lib/module/reanimated2/threads.js +45 -0
- package/lib/module/reanimated2/threads.js.map +1 -0
- package/lib/module/reanimated2/time.js +37 -0
- package/lib/module/reanimated2/time.js.map +1 -0
- package/lib/module/reanimated2/valueSetter.js +66 -0
- package/lib/module/reanimated2/valueSetter.js.map +1 -0
- package/package.json +3 -2
- package/plugin.js +112 -30
- package/src/createAnimatedComponent.tsx +8 -24
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +43 -53
- package/src/reanimated2/ViewDescriptorsSet.ts +30 -69
- package/src/reanimated2/WorkletEventHandler.ts +4 -11
- package/src/reanimated2/animation/util.ts +1 -0
- package/src/reanimated2/commonTypes.ts +29 -4
- package/src/reanimated2/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +68 -258
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/globals.d.ts +48 -29
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +18 -9
- package/src/reanimated2/hook/useAnimatedRef.ts +27 -9
- package/src/reanimated2/hook/useAnimatedSensor.ts +33 -31
- package/src/reanimated2/hook/useAnimatedStyle.ts +26 -74
- package/src/reanimated2/hook/useSharedValue.ts +6 -3
- package/src/reanimated2/hook/utils.ts +1 -1
- package/src/reanimated2/initializers.ts +143 -0
- package/src/reanimated2/interpolateColor.ts +2 -2
- package/src/reanimated2/jestUtils.ts +14 -29
- package/src/reanimated2/js-reanimated/JSReanimated.ts +24 -94
- package/src/reanimated2/js-reanimated/global.ts +4 -7
- package/src/reanimated2/js-reanimated/index.ts +4 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +7 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +91 -0
- package/src/reanimated2/layoutReanimation/index.ts +1 -1
- package/src/reanimated2/mappers.ts +179 -0
- package/src/reanimated2/mock.ts +105 -0
- package/src/reanimated2/mutables.ts +151 -0
- package/src/reanimated2/shareables.ts +128 -0
- package/src/reanimated2/threads.ts +46 -0
- package/src/reanimated2/time.ts +30 -0
- package/src/reanimated2/valueSetter.ts +64 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +0 -127
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +0 -56
- package/Common/cpp/Registries/MapperRegistry.cpp +0 -147
- package/Common/cpp/Registries/MapperRegistry.h +0 -29
- package/Common/cpp/Registries/WorkletsCache.cpp +0 -45
- package/Common/cpp/Registries/WorkletsCache.h +0 -24
- package/Common/cpp/SharedItems/FrozenObject.cpp +0 -35
- package/Common/cpp/SharedItems/FrozenObject.h +0 -36
- package/Common/cpp/SharedItems/HostFunctionHandler.h +0 -28
- package/Common/cpp/SharedItems/MutableValue.cpp +0 -134
- package/Common/cpp/SharedItems/MutableValue.h +0 -54
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +0 -47
- package/Common/cpp/SharedItems/MutableValueSetterProxy.h +0 -25
- package/Common/cpp/SharedItems/RemoteObject.cpp +0 -45
- package/Common/cpp/SharedItems/RemoteObject.h +0 -35
- package/Common/cpp/SharedItems/ShareableValue.cpp +0 -529
- package/Common/cpp/SharedItems/ShareableValue.h +0 -63
- package/Common/cpp/SharedItems/ValueWrapper.h +0 -183
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +0 -55
- package/Common/cpp/Tools/JSIStoreValueUser.h +0 -37
- package/Common/cpp/Tools/Mapper.cpp +0 -86
- package/Common/cpp/Tools/Mapper.h +0 -51
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -58
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -52
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +0 -49
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
#include "AnimatedSensorModule.h"
|
|
2
|
-
#include "MutableValue.h"
|
|
3
|
-
#include "ValueWrapper.h"
|
|
4
2
|
|
|
5
3
|
#include <memory>
|
|
6
4
|
#include <utility>
|
|
7
5
|
|
|
6
|
+
#include "Shareables.h"
|
|
7
|
+
|
|
8
8
|
namespace reanimated {
|
|
9
9
|
|
|
10
10
|
AnimatedSensorModule::AnimatedSensorModule(
|
|
11
|
-
const PlatformDepMethodsHolder &platformDepMethodsHolder
|
|
12
|
-
RuntimeManager *runtimeManager)
|
|
11
|
+
const PlatformDepMethodsHolder &platformDepMethodsHolder)
|
|
13
12
|
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
|
|
14
13
|
platformUnregisterSensorFunction_(
|
|
15
|
-
platformDepMethodsHolder.unregisterSensor)
|
|
16
|
-
runtimeManager_(runtimeManager) {}
|
|
14
|
+
platformDepMethodsHolder.unregisterSensor) {}
|
|
17
15
|
|
|
18
16
|
AnimatedSensorModule::~AnimatedSensorModule() {
|
|
19
17
|
// It is called during app reload because app reload doesn't call hooks
|
|
@@ -25,41 +23,38 @@ AnimatedSensorModule::~AnimatedSensorModule() {
|
|
|
25
23
|
|
|
26
24
|
jsi::Value AnimatedSensorModule::registerSensor(
|
|
27
25
|
jsi::Runtime &rt,
|
|
28
|
-
const
|
|
26
|
+
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
27
|
+
const jsi::Value &sensorTypeValue,
|
|
29
28
|
const jsi::Value &interval,
|
|
30
|
-
const jsi::Value &
|
|
31
|
-
|
|
32
|
-
rt, sensorDataContainer.getObject(rt), runtimeManager_);
|
|
33
|
-
auto &mutableObject =
|
|
34
|
-
ValueWrapper::asMutableValue(sensorsData->valueContainer);
|
|
29
|
+
const jsi::Value &sensorDataHandler) {
|
|
30
|
+
SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setter = [&, mutableObject](double newValues[]) {
|
|
39
|
-
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
|
|
40
|
-
jsi::Object value(runtime);
|
|
41
|
-
value.setProperty(runtime, "qx", newValues[0]);
|
|
42
|
-
value.setProperty(runtime, "qy", newValues[1]);
|
|
43
|
-
value.setProperty(runtime, "qz", newValues[2]);
|
|
44
|
-
value.setProperty(runtime, "qw", newValues[3]);
|
|
45
|
-
value.setProperty(runtime, "yaw", newValues[4]);
|
|
46
|
-
value.setProperty(runtime, "pitch", newValues[5]);
|
|
47
|
-
value.setProperty(runtime, "roll", newValues[6]);
|
|
48
|
-
mutableObject->setValue(runtime, std::move(value));
|
|
49
|
-
};
|
|
50
|
-
} else {
|
|
51
|
-
setter = [&, mutableObject](double newValues[]) {
|
|
52
|
-
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
|
|
53
|
-
jsi::Object value(runtime);
|
|
54
|
-
value.setProperty(runtime, "x", newValues[0]);
|
|
55
|
-
value.setProperty(runtime, "y", newValues[1]);
|
|
56
|
-
value.setProperty(runtime, "z", newValues[2]);
|
|
57
|
-
mutableObject->setValue(runtime, std::move(value));
|
|
58
|
-
};
|
|
59
|
-
}
|
|
32
|
+
auto shareableHandler = extractShareableOrThrow(rt, sensorDataHandler);
|
|
33
|
+
auto uiRuntime = runtimeHelper->uiRuntime();
|
|
60
34
|
|
|
61
35
|
int sensorId = platformRegisterSensorFunction_(
|
|
62
|
-
sensorType
|
|
36
|
+
sensorType, interval.asNumber(), [=](double newValues[]) {
|
|
37
|
+
jsi::Runtime &rt = *uiRuntime;
|
|
38
|
+
auto handler =
|
|
39
|
+
shareableHandler->getJSValue(rt).asObject(rt).asFunction(rt);
|
|
40
|
+
if (sensorType == SensorType::ROTATION_VECTOR) {
|
|
41
|
+
jsi::Object value(rt);
|
|
42
|
+
value.setProperty(rt, "qx", newValues[0]);
|
|
43
|
+
value.setProperty(rt, "qy", newValues[1]);
|
|
44
|
+
value.setProperty(rt, "qz", newValues[2]);
|
|
45
|
+
value.setProperty(rt, "qw", newValues[3]);
|
|
46
|
+
value.setProperty(rt, "yaw", newValues[4]);
|
|
47
|
+
value.setProperty(rt, "pitch", newValues[5]);
|
|
48
|
+
value.setProperty(rt, "roll", newValues[6]);
|
|
49
|
+
handler.call(rt, value);
|
|
50
|
+
} else {
|
|
51
|
+
jsi::Object value(rt);
|
|
52
|
+
value.setProperty(rt, "x", newValues[0]);
|
|
53
|
+
value.setProperty(rt, "y", newValues[1]);
|
|
54
|
+
value.setProperty(rt, "z", newValues[2]);
|
|
55
|
+
handler.call(rt, value);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
63
58
|
if (sensorId != -1) {
|
|
64
59
|
sensorsIds_.insert(sensorId);
|
|
65
60
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
4
5
|
#include <unordered_set>
|
|
5
6
|
|
|
6
7
|
#include "PlatformDepMethodsHolder.h"
|
|
7
8
|
#include "RuntimeManager.h"
|
|
9
|
+
#include "Shareables.h"
|
|
8
10
|
|
|
9
11
|
namespace reanimated {
|
|
10
12
|
|
|
@@ -22,16 +24,15 @@ class AnimatedSensorModule {
|
|
|
22
24
|
std::unordered_set<int> sensorsIds_;
|
|
23
25
|
RegisterSensorFunction platformRegisterSensorFunction_;
|
|
24
26
|
UnregisterSensorFunction platformUnregisterSensorFunction_;
|
|
25
|
-
RuntimeManager *runtimeManager_;
|
|
26
27
|
|
|
27
28
|
public:
|
|
28
29
|
AnimatedSensorModule(
|
|
29
|
-
const PlatformDepMethodsHolder &platformDepMethodsHolder
|
|
30
|
-
RuntimeManager *runtimeManager);
|
|
30
|
+
const PlatformDepMethodsHolder &platformDepMethodsHolder);
|
|
31
31
|
~AnimatedSensorModule();
|
|
32
32
|
|
|
33
33
|
jsi::Value registerSensor(
|
|
34
34
|
jsi::Runtime &rt,
|
|
35
|
+
const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
|
|
35
36
|
const jsi::Value &sensorType,
|
|
36
37
|
const jsi::Value &interval,
|
|
37
38
|
const jsi::Value &sensorDataContainer);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#include "LayoutAnimationsManager.h"
|
|
2
|
+
#include "Shareables.h"
|
|
3
|
+
|
|
4
|
+
#include <utility>
|
|
5
|
+
|
|
6
|
+
namespace reanimated {
|
|
7
|
+
|
|
8
|
+
void LayoutAnimationsManager::configureAnimation(
|
|
9
|
+
int tag,
|
|
10
|
+
const std::string &type,
|
|
11
|
+
std::shared_ptr<Shareable> config) {
|
|
12
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
13
|
+
if (type == "entering") {
|
|
14
|
+
enteringAnimations_[tag] = config;
|
|
15
|
+
} else if (type == "exiting") {
|
|
16
|
+
exitingAnimations_[tag] = config;
|
|
17
|
+
} else if (type == "layout") {
|
|
18
|
+
layoutAnimations_[tag] = config;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
bool LayoutAnimationsManager::hasLayoutAnimation(
|
|
23
|
+
int tag,
|
|
24
|
+
const std::string &type) {
|
|
25
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
26
|
+
if (type == "entering") {
|
|
27
|
+
return enteringAnimations_.find(tag) != enteringAnimations_.end();
|
|
28
|
+
} else if (type == "exiting") {
|
|
29
|
+
return exitingAnimations_.find(tag) != exitingAnimations_.end();
|
|
30
|
+
} else if (type == "layout") {
|
|
31
|
+
return layoutAnimations_.find(tag) != layoutAnimations_.end();
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) {
|
|
37
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
38
|
+
enteringAnimations_.erase(tag);
|
|
39
|
+
exitingAnimations_.erase(tag);
|
|
40
|
+
layoutAnimations_.erase(tag);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void LayoutAnimationsManager::startLayoutAnimation(
|
|
44
|
+
jsi::Runtime &rt,
|
|
45
|
+
int tag,
|
|
46
|
+
const std::string &type,
|
|
47
|
+
const jsi::Object &values) {
|
|
48
|
+
std::shared_ptr<Shareable> config, viewShareable;
|
|
49
|
+
{
|
|
50
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
51
|
+
if (type == "entering") {
|
|
52
|
+
config = enteringAnimations_[tag];
|
|
53
|
+
} else if (type == "exiting") {
|
|
54
|
+
config = exitingAnimations_[tag];
|
|
55
|
+
} else if (type == "layout") {
|
|
56
|
+
config = layoutAnimations_[tag];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// TODO: cache the following!!
|
|
61
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
62
|
+
rt.global()
|
|
63
|
+
.getPropertyAsObject(rt, "global")
|
|
64
|
+
.getProperty(rt, "LayoutAnimationsManager");
|
|
65
|
+
jsi::Function startAnimationForTag =
|
|
66
|
+
layoutAnimationRepositoryAsValue.getObject(rt).getPropertyAsFunction(
|
|
67
|
+
rt, "start");
|
|
68
|
+
startAnimationForTag.call(
|
|
69
|
+
rt,
|
|
70
|
+
jsi::Value(tag),
|
|
71
|
+
jsi::String::createFromAscii(rt, type),
|
|
72
|
+
values,
|
|
73
|
+
config->getJSValue(rt));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} // namespace reanimated
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "ErrorHandler.h"
|
|
4
|
+
#include "Shareables.h"
|
|
5
|
+
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <functional>
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <mutex>
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <unordered_map>
|
|
13
|
+
|
|
14
|
+
namespace reanimated {
|
|
15
|
+
|
|
16
|
+
using namespace facebook;
|
|
17
|
+
|
|
18
|
+
class LayoutAnimationsManager {
|
|
19
|
+
public:
|
|
20
|
+
void configureAnimation(
|
|
21
|
+
int tag,
|
|
22
|
+
const std::string &type,
|
|
23
|
+
std::shared_ptr<Shareable> config);
|
|
24
|
+
bool hasLayoutAnimation(int tag, const std::string &type);
|
|
25
|
+
void startLayoutAnimation(
|
|
26
|
+
jsi::Runtime &rt,
|
|
27
|
+
int tag,
|
|
28
|
+
const std::string &type,
|
|
29
|
+
const jsi::Object &values);
|
|
30
|
+
void clearLayoutAnimationConfig(int tag);
|
|
31
|
+
|
|
32
|
+
private:
|
|
33
|
+
std::unordered_map<int, std::shared_ptr<Shareable>> enteringAnimations_;
|
|
34
|
+
std::unordered_map<int, std::shared_ptr<Shareable>> exitingAnimations_;
|
|
35
|
+
std::unordered_map<int, std::shared_ptr<Shareable>> layoutAnimations_;
|
|
36
|
+
mutable std::mutex
|
|
37
|
+
animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`,
|
|
38
|
+
// `layoutAnimations_` and `viewSharedValues_`.
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace reanimated
|