react-native-reanimated 3.0.0-rc.5 → 3.0.0-rc.7
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/LayoutAnimations/LayoutAnimationsProxy.cpp +97 -15
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +32 -8
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +16 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +8 -1
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +17 -0
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -1
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +1 -1
- package/android/build.gradle +9 -4
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +16 -25
- package/android/src/main/cpp/LayoutAnimations.cpp +42 -50
- package/android/src/main/cpp/LayoutAnimations.h +17 -3
- package/android/src/main/cpp/NativeProxy.cpp +64 -5
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +1 -1
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +208 -223
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +7 -5
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +5 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +1 -1
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +20 -7
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +8 -44
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +15 -61
- package/ios/LayoutReanimation/REAAnimationsManager.h +18 -8
- package/ios/LayoutReanimation/REAAnimationsManager.m +197 -162
- package/ios/LayoutReanimation/REAUIManager.mm +63 -70
- package/ios/REAModule.mm +11 -5
- package/ios/native/NativeProxy.mm +49 -47
- package/ios/native/REAInitializer.mm +9 -0
- package/lib/commonjs/createAnimatedComponent.js +26 -26
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +31 -0
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +9 -9
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +23 -62
- package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +27 -26
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +29 -0
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/core.js +7 -9
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +22 -61
- package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +1 -1
- package/package.json +2 -2
- package/scripts/reanimated_utils.rb +3 -2
- package/src/createAnimatedComponent.tsx +48 -39
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +43 -0
- package/src/reanimated2/core.ts +19 -10
- package/src/reanimated2/globals.d.ts +12 -6
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +24 -50
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -55
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -40
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +0 -49
|
@@ -11,35 +11,117 @@ namespace reanimated {
|
|
|
11
11
|
const long long idOffset = 1e9;
|
|
12
12
|
|
|
13
13
|
LayoutAnimationsProxy::LayoutAnimationsProxy(
|
|
14
|
-
std::function<void(int, jsi::Object newProps)>
|
|
15
|
-
std::function<void(int, bool)>
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
std::function<void(int, jsi::Object newProps)> progressHandler,
|
|
15
|
+
std::function<void(int, bool, bool)> endHandler,
|
|
16
|
+
std::weak_ptr<ErrorHandler> weakErrorHandler)
|
|
17
|
+
: progressHandler_(std::move(progressHandler)),
|
|
18
|
+
endHandler_(std::move(endHandler)),
|
|
19
|
+
weakErrorHandler_(weakErrorHandler) {}
|
|
18
20
|
|
|
19
21
|
void LayoutAnimationsProxy::startObserving(
|
|
20
22
|
int tag,
|
|
21
23
|
std::shared_ptr<MutableValue> sv,
|
|
22
24
|
jsi::Runtime &rt) {
|
|
23
|
-
|
|
25
|
+
observedValues_[tag] = sv;
|
|
26
|
+
this->progressHandler_(tag, sv->value->toJSValue(rt).asObject(rt));
|
|
24
27
|
sv->addListener(tag + idOffset, [sv, tag, this, &rt]() {
|
|
25
|
-
|
|
26
|
-
ValueWrapper::asFrozenObject(sv->value->valueContainer);
|
|
27
|
-
this->notifyAboutProgress(tag, newValue->shallowClone(rt));
|
|
28
|
+
this->progressHandler_(tag, sv->value->toJSValue(rt).asObject(rt));
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
void LayoutAnimationsProxy::stopObserving(
|
|
32
|
-
|
|
32
|
+
void LayoutAnimationsProxy::stopObserving(
|
|
33
|
+
int tag,
|
|
34
|
+
bool finished,
|
|
35
|
+
bool removeView) {
|
|
36
|
+
if (observedValues_.count(tag) == 0) {
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
|
-
std::shared_ptr<MutableValue> sv =
|
|
39
|
+
std::shared_ptr<MutableValue> sv = observedValues_[tag];
|
|
36
40
|
sv->removeListener(tag + idOffset);
|
|
37
|
-
|
|
38
|
-
this->
|
|
41
|
+
observedValues_.erase(tag);
|
|
42
|
+
this->endHandler_(tag, !finished, removeView);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void LayoutAnimationsProxy::configureAnimation(
|
|
46
|
+
int tag,
|
|
47
|
+
const std::string &type,
|
|
48
|
+
std::shared_ptr<ShareableValue> config,
|
|
49
|
+
std::shared_ptr<ShareableValue> viewSharedValue) {
|
|
50
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
51
|
+
if (type == "entering") {
|
|
52
|
+
enteringAnimations_[tag] = config;
|
|
53
|
+
} else if (type == "exiting") {
|
|
54
|
+
exitingAnimations_[tag] = config;
|
|
55
|
+
} else if (type == "layout") {
|
|
56
|
+
layoutAnimations_[tag] = config;
|
|
57
|
+
}
|
|
58
|
+
viewSharedValues_[tag] = viewSharedValue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bool LayoutAnimationsProxy::hasLayoutAnimation(
|
|
62
|
+
int tag,
|
|
63
|
+
const std::string &type) {
|
|
64
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
65
|
+
if (type == "entering") {
|
|
66
|
+
return enteringAnimations_.find(tag) != enteringAnimations_.end();
|
|
67
|
+
} else if (type == "exiting") {
|
|
68
|
+
return exitingAnimations_.find(tag) != exitingAnimations_.end();
|
|
69
|
+
} else if (type == "layout") {
|
|
70
|
+
return layoutAnimations_.find(tag) != layoutAnimations_.end();
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void LayoutAnimationsProxy::clearLayoutAnimationConfig(int tag) {
|
|
76
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
77
|
+
enteringAnimations_.erase(tag);
|
|
78
|
+
exitingAnimations_.erase(tag);
|
|
79
|
+
layoutAnimations_.erase(tag);
|
|
80
|
+
viewSharedValues_.erase(tag);
|
|
39
81
|
}
|
|
40
82
|
|
|
41
|
-
void LayoutAnimationsProxy::
|
|
42
|
-
|
|
83
|
+
void LayoutAnimationsProxy::startLayoutAnimation(
|
|
84
|
+
jsi::Runtime &rt,
|
|
85
|
+
int tag,
|
|
86
|
+
const std::string &type,
|
|
87
|
+
const jsi::Object &values) {
|
|
88
|
+
std::shared_ptr<ShareableValue> config;
|
|
89
|
+
std::shared_ptr<ShareableValue> viewSharedValue;
|
|
90
|
+
{
|
|
91
|
+
auto lock = std::unique_lock<std::mutex>(animationsMutex_);
|
|
92
|
+
if (type == "entering") {
|
|
93
|
+
config = enteringAnimations_[tag];
|
|
94
|
+
} else if (type == "exiting") {
|
|
95
|
+
config = exitingAnimations_[tag];
|
|
96
|
+
} else if (type == "layout") {
|
|
97
|
+
config = layoutAnimations_[tag];
|
|
98
|
+
}
|
|
99
|
+
viewSharedValue = viewSharedValues_[tag];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
103
|
+
rt.global()
|
|
104
|
+
.getPropertyAsObject(rt, "global")
|
|
105
|
+
.getProperty(rt, "LayoutAnimationRepository");
|
|
106
|
+
if (layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
107
|
+
auto errorHandler = weakErrorHandler_.lock();
|
|
108
|
+
if (errorHandler != nullptr) {
|
|
109
|
+
errorHandler->setError(
|
|
110
|
+
"startLayoutAnimation called before initializing LayoutAnimationRepository");
|
|
111
|
+
errorHandler->raise();
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
jsi::Function startAnimationForTag =
|
|
116
|
+
layoutAnimationRepositoryAsValue.getObject(rt).getPropertyAsFunction(
|
|
117
|
+
rt, "startAnimationForTag");
|
|
118
|
+
startAnimationForTag.call(
|
|
119
|
+
rt,
|
|
120
|
+
jsi::Value(tag),
|
|
121
|
+
jsi::String::createFromAscii(rt, type),
|
|
122
|
+
values,
|
|
123
|
+
config->toJSValue(rt),
|
|
124
|
+
viewSharedValue->toJSValue(rt));
|
|
43
125
|
}
|
|
44
126
|
|
|
45
127
|
} // namespace reanimated
|
|
@@ -1,32 +1,56 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <ErrorHandler.h>
|
|
3
4
|
#include <jsi/jsi.h>
|
|
4
5
|
#include <stdio.h>
|
|
5
6
|
#include <functional>
|
|
6
|
-
#include <map>
|
|
7
7
|
#include <memory>
|
|
8
|
+
#include <mutex>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <unordered_map>
|
|
8
11
|
|
|
9
12
|
namespace reanimated {
|
|
10
13
|
|
|
11
14
|
using namespace facebook;
|
|
12
15
|
|
|
13
16
|
class MutableValue;
|
|
17
|
+
class ShareableValue;
|
|
14
18
|
|
|
15
19
|
class LayoutAnimationsProxy {
|
|
16
20
|
public:
|
|
17
21
|
LayoutAnimationsProxy(
|
|
18
|
-
std::function<void(int, jsi::Object newProps)>
|
|
19
|
-
std::function<void(int, bool)>
|
|
22
|
+
std::function<void(int, jsi::Object newProps)> progressHandler,
|
|
23
|
+
std::function<void(int, bool, bool)> endHandler,
|
|
24
|
+
std::weak_ptr<ErrorHandler> weakErrorHandler);
|
|
20
25
|
|
|
21
26
|
void
|
|
22
27
|
startObserving(int tag, std::shared_ptr<MutableValue> sv, jsi::Runtime &rt);
|
|
23
|
-
void stopObserving(int tag, bool finished);
|
|
24
|
-
void
|
|
28
|
+
void stopObserving(int tag, bool finished, bool removeView);
|
|
29
|
+
void configureAnimation(
|
|
30
|
+
int tag,
|
|
31
|
+
const std::string &type,
|
|
32
|
+
std::shared_ptr<ShareableValue> config,
|
|
33
|
+
std::shared_ptr<ShareableValue> viewSharedValue);
|
|
34
|
+
bool hasLayoutAnimation(int tag, const std::string &type);
|
|
35
|
+
void startLayoutAnimation(
|
|
36
|
+
jsi::Runtime &rt,
|
|
37
|
+
int tag,
|
|
38
|
+
const std::string &type,
|
|
39
|
+
const jsi::Object &values);
|
|
40
|
+
void clearLayoutAnimationConfig(int tag);
|
|
25
41
|
|
|
26
42
|
private:
|
|
27
|
-
std::function<void(int, jsi::Object newProps)>
|
|
28
|
-
std::function<void(int, bool)>
|
|
29
|
-
std::
|
|
43
|
+
std::function<void(int, jsi::Object newProps)> progressHandler_;
|
|
44
|
+
std::function<void(int, bool, bool)> endHandler_;
|
|
45
|
+
std::weak_ptr<ErrorHandler> weakErrorHandler_;
|
|
46
|
+
std::unordered_map<int, std::shared_ptr<MutableValue>> observedValues_;
|
|
47
|
+
std::unordered_map<int, std::shared_ptr<ShareableValue>> viewSharedValues_;
|
|
48
|
+
std::unordered_map<int, std::shared_ptr<ShareableValue>> enteringAnimations_;
|
|
49
|
+
std::unordered_map<int, std::shared_ptr<ShareableValue>> exitingAnimations_;
|
|
50
|
+
std::unordered_map<int, std::shared_ptr<ShareableValue>> layoutAnimations_;
|
|
51
|
+
mutable std::mutex
|
|
52
|
+
animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`,
|
|
53
|
+
// `layoutAnimations_` and `viewSharedValues_`.
|
|
30
54
|
};
|
|
31
55
|
|
|
32
56
|
} // namespace reanimated
|
|
@@ -87,6 +87,7 @@ NativeReanimatedModule::NativeReanimatedModule(
|
|
|
87
87
|
PlatformDepMethodsHolder platformDepMethodsHolder)
|
|
88
88
|
: NativeReanimatedModuleSpec(jsInvoker),
|
|
89
89
|
RuntimeManager(rt, errorHandler, scheduler, RuntimeType::UI),
|
|
90
|
+
layoutAnimationsProxy_(layoutAnimationsProxy),
|
|
90
91
|
mapperRegistry(std::make_shared<MapperRegistry>()),
|
|
91
92
|
eventHandlerRegistry(std::make_shared<EventHandlerRegistry>()),
|
|
92
93
|
requestRender(platformDepMethodsHolder.requestRender),
|
|
@@ -109,7 +110,7 @@ NativeReanimatedModule::NativeReanimatedModule(
|
|
|
109
110
|
maybeRequestRender();
|
|
110
111
|
};
|
|
111
112
|
|
|
112
|
-
this->
|
|
113
|
+
this->layoutAnimationsProxy_ = layoutAnimationsProxy;
|
|
113
114
|
|
|
114
115
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
115
116
|
auto updateProps = [this](
|
|
@@ -337,6 +338,20 @@ jsi::Value NativeReanimatedModule::configureProps(
|
|
|
337
338
|
return jsi::Value::undefined();
|
|
338
339
|
}
|
|
339
340
|
|
|
341
|
+
jsi::Value NativeReanimatedModule::configureLayoutAnimation(
|
|
342
|
+
jsi::Runtime &rt,
|
|
343
|
+
const jsi::Value &viewTag,
|
|
344
|
+
const jsi::Value &type,
|
|
345
|
+
const jsi::Value &config,
|
|
346
|
+
const jsi::Value &viewSharedValue) {
|
|
347
|
+
layoutAnimationsProxy_->configureAnimation(
|
|
348
|
+
viewTag.asNumber(),
|
|
349
|
+
type.asString(rt).utf8(rt),
|
|
350
|
+
ShareableValue::adapt(rt, config, this),
|
|
351
|
+
ShareableValue::adapt(rt, viewSharedValue, this));
|
|
352
|
+
return jsi::Value::undefined();
|
|
353
|
+
}
|
|
354
|
+
|
|
340
355
|
void NativeReanimatedModule::onEvent(
|
|
341
356
|
std::string eventName,
|
|
342
357
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -144,11 +144,19 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
|
|
|
144
144
|
jsi::Runtime &rt,
|
|
145
145
|
const jsi::Value &listenerId) override;
|
|
146
146
|
|
|
147
|
+
jsi::Value configureLayoutAnimation(
|
|
148
|
+
jsi::Runtime &rt,
|
|
149
|
+
const jsi::Value &viewTag,
|
|
150
|
+
const jsi::Value &type,
|
|
151
|
+
const jsi::Value &config,
|
|
152
|
+
const jsi::Value &viewSharedValue) override;
|
|
153
|
+
|
|
147
154
|
private:
|
|
148
155
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
149
156
|
bool isThereAnyLayoutProp(jsi::Runtime &rt, const jsi::Value &props);
|
|
150
157
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
151
158
|
|
|
159
|
+
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy_;
|
|
152
160
|
std::shared_ptr<MapperRegistry> mapperRegistry;
|
|
153
161
|
std::shared_ptr<EventHandlerRegistry> eventHandlerRegistry;
|
|
154
162
|
std::function<void(FrameCallback &, jsi::Runtime &)> requestRender;
|
|
@@ -158,7 +166,6 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
|
|
|
158
166
|
std::function<jsi::Value(jsi::Runtime &, const int, const jsi::String &)>
|
|
159
167
|
propObtainer;
|
|
160
168
|
std::function<void(double)> onRenderCallback;
|
|
161
|
-
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy;
|
|
162
169
|
AnimatedSensorModule animatedSensorModule;
|
|
163
170
|
ConfigurePropsFunction configurePropsPlatformFunction;
|
|
164
171
|
|
|
@@ -159,6 +159,20 @@ static jsi::Value SPEC_PREFIX(unsubscribeFromKeyboardEvents)(
|
|
|
159
159
|
return jsi::Value::undefined();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
static jsi::Value SPEC_PREFIX(configureLayoutAnimation)(
|
|
163
|
+
jsi::Runtime &rt,
|
|
164
|
+
TurboModule &turboModule,
|
|
165
|
+
const jsi::Value *args,
|
|
166
|
+
size_t count) {
|
|
167
|
+
return static_cast<NativeReanimatedModuleSpec *>(&turboModule)
|
|
168
|
+
->configureLayoutAnimation(
|
|
169
|
+
rt,
|
|
170
|
+
std::move(args[0]),
|
|
171
|
+
std::move(args[1]),
|
|
172
|
+
std::move(args[2]),
|
|
173
|
+
std::move(args[3]));
|
|
174
|
+
}
|
|
175
|
+
|
|
162
176
|
NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
163
177
|
std::shared_ptr<CallInvoker> jsInvoker)
|
|
164
178
|
: TurboModule("NativeReanimated", jsInvoker) {
|
|
@@ -188,5 +202,8 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
|
188
202
|
MethodMetadata{1, SPEC_PREFIX(subscribeForKeyboardEvents)};
|
|
189
203
|
methodMap_["unsubscribeFromKeyboardEvents"] =
|
|
190
204
|
MethodMetadata{1, SPEC_PREFIX(unsubscribeFromKeyboardEvents)};
|
|
205
|
+
|
|
206
|
+
methodMap_["configureLayoutAnimation"] =
|
|
207
|
+
MethodMetadata{4, SPEC_PREFIX(configureLayoutAnimation)};
|
|
191
208
|
}
|
|
192
209
|
} // namespace reanimated
|
|
@@ -85,6 +85,14 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
|
|
|
85
85
|
jsi::Runtime &rt,
|
|
86
86
|
const jsi::Value &uiProps,
|
|
87
87
|
const jsi::Value &nativeProps) = 0;
|
|
88
|
+
|
|
89
|
+
// layout animations
|
|
90
|
+
virtual jsi::Value configureLayoutAnimation(
|
|
91
|
+
jsi::Runtime &rt,
|
|
92
|
+
const jsi::Value &viewTag,
|
|
93
|
+
const jsi::Value &type,
|
|
94
|
+
const jsi::Value &config,
|
|
95
|
+
const jsi::Value &viewSharedValue) = 0;
|
|
88
96
|
};
|
|
89
97
|
|
|
90
98
|
} // namespace reanimated
|
|
@@ -277,7 +277,8 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
277
277
|
if (layoutProxy.expired()) {
|
|
278
278
|
return jsi::Value::undefined();
|
|
279
279
|
}
|
|
280
|
-
proxy->stopObserving(
|
|
280
|
+
proxy->stopObserving(
|
|
281
|
+
args[0].asNumber(), args[1].getBool(), args[2].getBool());
|
|
281
282
|
return jsi::Value::undefined();
|
|
282
283
|
};
|
|
283
284
|
jsi::Value _stopObservingProgress = jsi::Function::createFromHostFunction(
|
package/RNReanimated.podspec
CHANGED
|
@@ -12,6 +12,7 @@ folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comm
|
|
|
12
12
|
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
|
|
13
13
|
boost_compiler_flags = '-Wno-documentation'
|
|
14
14
|
fabric_flags = fabric_enabled ? '-DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED' : ''
|
|
15
|
+
version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"]
|
|
15
16
|
|
|
16
17
|
Pod::Spec.new do |s|
|
|
17
18
|
|
|
@@ -46,7 +47,7 @@ Pod::Spec.new do |s|
|
|
|
46
47
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' -DHERMES_ENABLE_DEBUGGER'
|
|
47
48
|
s.xcconfig = {
|
|
48
49
|
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/Headers/Public/React-hermes\" \"$(PODS_ROOT)/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/#{config[:react_native_common_dir]}\"",
|
|
49
|
-
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags
|
|
50
|
+
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags + " " + version_flag
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
s.requires_arc = true
|
package/android/CMakeLists.txt
CHANGED
|
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.8)
|
|
|
3
3
|
|
|
4
4
|
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
5
5
|
set (CMAKE_CXX_STANDARD 17)
|
|
6
|
-
set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DANDROID -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall -Werror")
|
|
6
|
+
set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DANDROID -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall -Werror")
|
|
7
7
|
if(${IS_NEW_ARCHITECTURE_ENABLED})
|
|
8
8
|
set (ALL_FLAGS "${DEFAULT_FLAGS} -DRCT_NEW_ARCH_ENABLED")
|
|
9
9
|
else()
|
package/android/build.gradle
CHANGED
|
@@ -179,8 +179,11 @@ def checkNoMultipleInstances() {
|
|
|
179
179
|
def getReanimatedVersion() {
|
|
180
180
|
def inputFile = file(projectDir.path + '/../package.json')
|
|
181
181
|
def json = new JsonSlurper().parseText(inputFile.text)
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
return json.version
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
def getReanimatedMajorVersion() {
|
|
186
|
+
def (major, minor, patch) = getReanimatedVersion().tokenize('.')
|
|
184
187
|
return major.toInteger()
|
|
185
188
|
}
|
|
186
189
|
|
|
@@ -209,7 +212,8 @@ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
|
|
209
212
|
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
210
213
|
def FBJNI_VERSION = "0.3.0"
|
|
211
214
|
def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
|
|
212
|
-
def
|
|
215
|
+
def REANIMATED_VERSION = getReanimatedVersion()
|
|
216
|
+
def REANIMATED_MAJOR_VERSION = getReanimatedMajorVersion()
|
|
213
217
|
|
|
214
218
|
// We download various C++ open-source dependencies into downloads.
|
|
215
219
|
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
|
|
@@ -461,7 +465,8 @@ android {
|
|
|
461
465
|
"-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
|
|
462
466
|
"-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}",
|
|
463
467
|
"-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}",
|
|
464
|
-
"-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}"
|
|
468
|
+
"-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}",
|
|
469
|
+
"-DREANIMATED_VERSION=${REANIMATED_VERSION}"
|
|
465
470
|
abiFilters (*reactNativeArchitectures())
|
|
466
471
|
_stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
|
|
467
472
|
}
|
|
@@ -307,31 +307,22 @@ public class NativeProxy {
|
|
|
307
307
|
|
|
308
308
|
WeakReference<LayoutAnimations> weakLayoutAnimations = new WeakReference<>(LayoutAnimations);
|
|
309
309
|
animationsManager.setNativeMethods(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
310
|
+
new NativeMethodsHolder() {
|
|
311
|
+
@Override
|
|
312
|
+
public void startAnimation(int tag, String type, HashMap<String, Float> values) {}
|
|
313
|
+
|
|
314
|
+
@Override
|
|
315
|
+
public boolean isLayoutAnimationEnabled() {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@Override
|
|
320
|
+
public boolean hasAnimation(int tag, String type) {
|
|
321
|
+
return false;
|
|
318
322
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
@Override
|
|
324
|
-
public void removeConfigForTag(int tag) {
|
|
325
|
-
LayoutAnimations LayoutAnimations = weakLayoutAnimations.get();
|
|
326
|
-
if (LayoutAnimations != null) {
|
|
327
|
-
LayoutAnimations.removeConfigForTag(tag);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
@Override
|
|
332
|
-
public boolean isLayoutAnimationEnabled() {
|
|
333
|
-
return LayoutAnimations.isLayoutAnimationEnabled();
|
|
334
|
-
}
|
|
335
|
-
});
|
|
323
|
+
|
|
324
|
+
@Override
|
|
325
|
+
public void clearAnimationConfig(int tag) {}
|
|
326
|
+
});
|
|
336
327
|
}
|
|
337
328
|
}
|
|
@@ -17,70 +17,59 @@ void LayoutAnimations::setWeakUIRuntime(std::weak_ptr<jsi::Runtime> wrt) {
|
|
|
17
17
|
this->weakUIRuntime = wrt;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
void LayoutAnimations::setAnimationStartingBlock(
|
|
21
|
+
AnimationStartingBlock animationStartingBlock) {
|
|
22
|
+
this->animationStartingBlock_ = animationStartingBlock;
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
void LayoutAnimations::startAnimationForTag(
|
|
21
26
|
int tag,
|
|
22
27
|
alias_ref<JString> type,
|
|
23
28
|
alias_ref<JMap<jstring, jstring>> values) {
|
|
24
|
-
|
|
25
|
-
jsi::Value layoutAnimationRepositoryAsValue =
|
|
26
|
-
rt->global()
|
|
27
|
-
.getPropertyAsObject(*rt, "global")
|
|
28
|
-
.getProperty(*rt, "LayoutAnimationRepository");
|
|
29
|
-
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
30
|
-
jsi::Function startAnimationForTag =
|
|
31
|
-
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(
|
|
32
|
-
*rt, "startAnimationForTag");
|
|
33
|
-
jsi::Object target(*rt);
|
|
34
|
-
|
|
35
|
-
for (const auto &entry : *values) {
|
|
36
|
-
target.setProperty(
|
|
37
|
-
*rt,
|
|
38
|
-
entry.first->toStdString().c_str(),
|
|
39
|
-
std::stof(entry.second->toStdString()));
|
|
40
|
-
}
|
|
41
|
-
startAnimationForTag.call(
|
|
42
|
-
*rt,
|
|
43
|
-
jsi::Value(tag),
|
|
44
|
-
jsi::String::createFromUtf8(*rt, type->toStdString()),
|
|
45
|
-
target);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
29
|
+
this->animationStartingBlock_(tag, type, values);
|
|
48
30
|
}
|
|
49
31
|
|
|
50
|
-
void LayoutAnimations::
|
|
51
|
-
|
|
52
|
-
jsi::Value
|
|
53
|
-
rt->global()
|
|
54
|
-
.getPropertyAsObject(*rt, "global")
|
|
55
|
-
.getProperty(*rt, "LayoutAnimationRepository");
|
|
56
|
-
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
57
|
-
jsi::Function removeConfig =
|
|
58
|
-
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(
|
|
59
|
-
*rt, "removeConfig");
|
|
60
|
-
removeConfig.call(*rt, jsi::Value(tag));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
void LayoutAnimations::notifyAboutProgress(
|
|
66
|
-
const jsi::Value &progress,
|
|
67
|
-
int tag) {
|
|
32
|
+
void LayoutAnimations::progressLayoutAnimation(
|
|
33
|
+
int tag,
|
|
34
|
+
const jsi::Value &progress) {
|
|
68
35
|
if (auto rt = this->weakUIRuntime.lock()) {
|
|
69
36
|
static const auto method =
|
|
70
37
|
javaPart_->getClass()
|
|
71
|
-
->getMethod<void(JMap<JString, JObject>::javaobject
|
|
72
|
-
"
|
|
38
|
+
->getMethod<void(int, JMap<JString, JObject>::javaobject)>(
|
|
39
|
+
"progressLayoutAnimation");
|
|
73
40
|
method(
|
|
74
41
|
javaPart_.get(),
|
|
75
|
-
|
|
76
|
-
|
|
42
|
+
tag,
|
|
43
|
+
JNIHelper::ConvertToPropsMap(*rt, progress.asObject(*rt)).get());
|
|
77
44
|
}
|
|
78
45
|
}
|
|
79
46
|
|
|
80
|
-
void LayoutAnimations::
|
|
47
|
+
void LayoutAnimations::endLayoutAnimation(
|
|
48
|
+
int tag,
|
|
49
|
+
bool cancelled,
|
|
50
|
+
bool removeView) {
|
|
81
51
|
static const auto method =
|
|
82
|
-
javaPart_->getClass()->getMethod<void(int,
|
|
83
|
-
|
|
52
|
+
javaPart_->getClass()->getMethod<void(int, bool, bool)>(
|
|
53
|
+
"endLayoutAnimation");
|
|
54
|
+
method(javaPart_.get(), tag, cancelled, removeView);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void LayoutAnimations::setHasAnimationBlock(
|
|
58
|
+
HasAnimationBlock hasAnimationBlock) {
|
|
59
|
+
this->hasAnimationBlock_ = hasAnimationBlock;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
bool LayoutAnimations::hasAnimationForTag(int tag, std::string type) {
|
|
63
|
+
return hasAnimationBlock_(tag, type);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void LayoutAnimations::setClearAnimationConfigBlock(
|
|
67
|
+
ClearAnimationConfigBlock clearAnimationConfigBlock) {
|
|
68
|
+
this->clearAnimationConfigBlock_ = clearAnimationConfigBlock;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void LayoutAnimations::clearAnimationConfigForTag(int tag) {
|
|
72
|
+
clearAnimationConfigBlock_(tag);
|
|
84
73
|
}
|
|
85
74
|
|
|
86
75
|
bool LayoutAnimations::isLayoutAnimationEnabled() {
|
|
@@ -93,7 +82,10 @@ void LayoutAnimations::registerNatives() {
|
|
|
93
82
|
makeNativeMethod(
|
|
94
83
|
"startAnimationForTag", LayoutAnimations::startAnimationForTag),
|
|
95
84
|
makeNativeMethod(
|
|
96
|
-
"
|
|
85
|
+
"hasAnimationForTag", LayoutAnimations::hasAnimationForTag),
|
|
86
|
+
makeNativeMethod(
|
|
87
|
+
"clearAnimationConfigForTag",
|
|
88
|
+
LayoutAnimations::clearAnimationConfigForTag),
|
|
97
89
|
makeNativeMethod(
|
|
98
90
|
"isLayoutAnimationEnabled",
|
|
99
91
|
LayoutAnimations::isLayoutAnimationEnabled),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <fbjni/fbjni.h>
|
|
4
4
|
#include <jsi/jsi.h>
|
|
5
5
|
#include <memory>
|
|
6
|
+
#include <string>
|
|
6
7
|
#include "JNIHelper.h"
|
|
7
8
|
|
|
8
9
|
namespace reanimated {
|
|
@@ -11,6 +12,11 @@ using namespace facebook::jni;
|
|
|
11
12
|
using namespace facebook;
|
|
12
13
|
|
|
13
14
|
class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
|
|
15
|
+
using AnimationStartingBlock = std::function<
|
|
16
|
+
void(int, alias_ref<JString>, alias_ref<JMap<jstring, jstring>>)>;
|
|
17
|
+
using HasAnimationBlock = std::function<bool(int, std::string)>;
|
|
18
|
+
using ClearAnimationConfigBlock = std::function<void(int)>;
|
|
19
|
+
|
|
14
20
|
public:
|
|
15
21
|
static auto constexpr kJavaDescriptor =
|
|
16
22
|
"Lcom/swmansion/reanimated/layoutReanimation/LayoutAnimations;";
|
|
@@ -22,18 +28,26 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
|
|
|
22
28
|
int tag,
|
|
23
29
|
alias_ref<JString> type,
|
|
24
30
|
alias_ref<JMap<jstring, jstring>> values);
|
|
25
|
-
|
|
31
|
+
bool hasAnimationForTag(int tag, std::string type);
|
|
26
32
|
bool isLayoutAnimationEnabled();
|
|
27
33
|
|
|
28
34
|
void setWeakUIRuntime(std::weak_ptr<jsi::Runtime> wrt);
|
|
35
|
+
void setAnimationStartingBlock(AnimationStartingBlock animationStartingBlock);
|
|
36
|
+
void setHasAnimationBlock(HasAnimationBlock hasAnimationBlock);
|
|
37
|
+
void setClearAnimationConfigBlock(
|
|
38
|
+
ClearAnimationConfigBlock clearAnimationConfigBlock);
|
|
29
39
|
|
|
30
|
-
void
|
|
31
|
-
void
|
|
40
|
+
void progressLayoutAnimation(int tag, const jsi::Value &progress);
|
|
41
|
+
void endLayoutAnimation(int tag, bool cancelled, bool removeView);
|
|
42
|
+
void clearAnimationConfigForTag(int tag);
|
|
32
43
|
|
|
33
44
|
private:
|
|
34
45
|
friend HybridBase;
|
|
35
46
|
jni::global_ref<LayoutAnimations::javaobject> javaPart_;
|
|
36
47
|
std::weak_ptr<jsi::Runtime> weakUIRuntime;
|
|
48
|
+
AnimationStartingBlock animationStartingBlock_;
|
|
49
|
+
HasAnimationBlock hasAnimationBlock_;
|
|
50
|
+
ClearAnimationConfigBlock clearAnimationConfigBlock_;
|
|
37
51
|
|
|
38
52
|
explicit LayoutAnimations(
|
|
39
53
|
jni::alias_ref<LayoutAnimations::jhybridobject> jThis);
|