react-native-reanimated 2.3.0-beta.3 → 2.3.0-beta.4
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 +21 -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/RNReanimated.podspec +20 -3
- package/android/build.gradle +29 -5
- 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/ios/LayoutReanimation/REAUIManager.mm +56 -12
- 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 +10 -2
- package/ios/native/REAInitializer.mm +8 -3
- package/lib/Animated.js +9 -1
- package/lib/createAnimatedComponent.js +53 -37
- package/lib/index.js +9 -1
- package/lib/reanimated2/NativeMethods.js +7 -0
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/reanimated2/UpdateProps.js +1 -1
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
- package/lib/reanimated2/animation/styleAnimation.js +5 -0
- package/lib/reanimated2/core.js +18 -0
- package/lib/reanimated2/globals.d.ts +2 -0
- package/lib/reanimated2/js-reanimated/JSReanimated.js +3 -0
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -1
- package/lib/reanimated2/js-reanimated/index.js +3 -0
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +1 -1
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +2 -2
- package/mock.js +1 -1
- package/package.json +2 -2
- package/plugin.js +9 -3
- package/react-native-reanimated.d.ts +1 -0
- package/src/Animated.js +9 -1
- package/src/createAnimatedComponent.tsx +76 -41
- package/src/reanimated2/NativeMethods.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +4 -0
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/styleAnimation.ts +9 -0
- package/src/reanimated2/core.ts +29 -0
- package/src/reanimated2/globals.d.ts +2 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +6 -0
- package/src/reanimated2/js-reanimated/Mapper.ts +3 -1
- package/src/reanimated2/js-reanimated/index.ts +5 -0
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +18 -5
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +1 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +5 -5
|
@@ -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
|
|
@@ -8,11 +8,15 @@
|
|
|
8
8
|
namespace reanimated {
|
|
9
9
|
|
|
10
10
|
std::unordered_map<RuntimePointer, RuntimeType>
|
|
11
|
-
RuntimeDecorator::runtimeRegistry
|
|
11
|
+
&RuntimeDecorator::runtimeRegistry() {
|
|
12
|
+
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
13
|
+
return runtimeRegistry;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
void RuntimeDecorator::registerRuntime(
|
|
13
17
|
jsi::Runtime *runtime,
|
|
14
18
|
RuntimeType runtimeType) {
|
|
15
|
-
runtimeRegistry.insert({runtime, runtimeType});
|
|
19
|
+
runtimeRegistry().insert({runtime, runtimeType});
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
void RuntimeDecorator::decorateRuntime(
|
|
@@ -88,6 +92,7 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
88
92
|
const ScrollToFunction scrollTo,
|
|
89
93
|
const MeasuringFunction measure,
|
|
90
94
|
const TimeProviderFunction getCurrentTime,
|
|
95
|
+
const SetGestureStateFunction setGestureState,
|
|
91
96
|
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy) {
|
|
92
97
|
RuntimeDecorator::decorateRuntime(rt, "UI");
|
|
93
98
|
rt.global().setProperty(rt, "_UI", jsi::Value(true));
|
|
@@ -207,6 +212,20 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
207
212
|
jsi::Value _stopObservingProgress = jsi::Function::createFromHostFunction(
|
|
208
213
|
rt, jsi::PropNameID::forAscii(rt, "_stopObservingProgress"), 0, clb8);
|
|
209
214
|
rt.global().setProperty(rt, "_stopObservingProgress", _stopObservingProgress);
|
|
215
|
+
|
|
216
|
+
auto clb9 = [setGestureState](
|
|
217
|
+
jsi::Runtime &rt,
|
|
218
|
+
const jsi::Value &thisValue,
|
|
219
|
+
const jsi::Value *args,
|
|
220
|
+
size_t count) -> jsi::Value {
|
|
221
|
+
int handlerTag = static_cast<int>(args[0].asNumber());
|
|
222
|
+
int newState = static_cast<int>(args[1].asNumber());
|
|
223
|
+
setGestureState(handlerTag, newState);
|
|
224
|
+
return jsi::Value::undefined();
|
|
225
|
+
};
|
|
226
|
+
jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
|
|
227
|
+
rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
|
|
228
|
+
rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
|
|
210
229
|
}
|
|
211
230
|
|
|
212
231
|
} // 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/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,27 @@ 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)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#import "REAUIManager.h"
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
|
+
#include "FeaturesConfig.h"
|
|
3
4
|
#import "RCTComponentData.h"
|
|
4
5
|
#import "RCTLayoutAnimation.h"
|
|
5
6
|
#import "RCTLayoutAnimationGroup.h"
|
|
7
|
+
#import "RCTModalHostView.h"
|
|
6
8
|
#import "RCTRootShadowView.h"
|
|
7
9
|
#import "RCTRootViewInternal.h"
|
|
8
10
|
#import "RCTUIManagerObserverCoordinator.h"
|
|
@@ -70,16 +72,29 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
70
72
|
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
71
73
|
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
|
72
74
|
{
|
|
75
|
+
if (!reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
76
|
+
[super _manageChildren:containerTag
|
|
77
|
+
moveFromIndices:moveFromIndices
|
|
78
|
+
moveToIndices:moveToIndices
|
|
79
|
+
addChildReactTags:addChildReactTags
|
|
80
|
+
addAtIndices:addAtIndices
|
|
81
|
+
removeAtIndices:removeAtIndices
|
|
82
|
+
registry:registry];
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Reanimated changes /start
|
|
73
87
|
BOOL isUIViewRegistry = ((id)registry == (id)[self valueForKey:@"_viewRegistry"]);
|
|
74
88
|
id<RCTComponent> container;
|
|
75
|
-
|
|
89
|
+
NSMutableArray<id<RCTComponent>> *permanentlyRemovedChildren;
|
|
76
90
|
if (isUIViewRegistry) {
|
|
77
91
|
container = registry[containerTag];
|
|
78
92
|
for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
79
93
|
[container removeReactSubview:toRemoveChild];
|
|
80
94
|
}
|
|
81
95
|
|
|
82
|
-
permanentlyRemovedChildren = [super _childrenToRemoveFromContainer:container
|
|
96
|
+
permanentlyRemovedChildren = (NSMutableArray *)[super _childrenToRemoveFromContainer:container
|
|
97
|
+
atIndices:removeAtIndices];
|
|
83
98
|
if (permanentlyRemovedChildren != nil) {
|
|
84
99
|
for (id<RCTComponent> permanentlyRemovedChild in permanentlyRemovedChildren) {
|
|
85
100
|
if (_toBeRemovedRegister[containerTag] == nil) {
|
|
@@ -89,6 +104,7 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
}
|
|
107
|
+
// Reanimated changes /end
|
|
92
108
|
|
|
93
109
|
[super _manageChildren:containerTag
|
|
94
110
|
moveFromIndices:moveFromIndices
|
|
@@ -98,6 +114,7 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
98
114
|
removeAtIndices:removeAtIndices
|
|
99
115
|
registry:registry];
|
|
100
116
|
|
|
117
|
+
// Reanimated changes /start
|
|
101
118
|
if (isUIViewRegistry) {
|
|
102
119
|
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
103
120
|
for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
@@ -105,14 +122,27 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
105
122
|
if (lastIndex < 0) {
|
|
106
123
|
lastIndex = 0;
|
|
107
124
|
}
|
|
108
|
-
[
|
|
109
|
-
|
|
125
|
+
if ([toRemoveChild isKindOfClass:[RCTModalHostView class]]
|
|
126
|
+
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
127
|
+
|| ([toRemoveChild isKindOfClass:[RNSScreenView class]])
|
|
128
|
+
#endif
|
|
129
|
+
) {
|
|
130
|
+
// we don't want layout animations when removing modals or Screens of native-stack since it brings buggy
|
|
131
|
+
// behavior
|
|
132
|
+
[_toBeRemovedRegister[container.reactTag] removeObject:toRemoveChild];
|
|
133
|
+
[permanentlyRemovedChildren removeObject:toRemoveChild];
|
|
134
|
+
|
|
135
|
+
} else {
|
|
136
|
+
[container insertReactSubview:toRemoveChild atIndex:lastIndex];
|
|
137
|
+
viewRegistry[toRemoveChild.reactTag] = toRemoveChild;
|
|
138
|
+
}
|
|
110
139
|
}
|
|
111
140
|
|
|
112
141
|
for (UIView *removedChild in permanentlyRemovedChildren) {
|
|
113
142
|
[self callAnimationForTree:removedChild parentTag:containerTag];
|
|
114
143
|
}
|
|
115
144
|
}
|
|
145
|
+
// Reanimated changes /end
|
|
116
146
|
}
|
|
117
147
|
|
|
118
148
|
- (void)callAnimationForTree:(UIView *)view parentTag:(NSNumber *)parentTag
|
|
@@ -239,7 +269,13 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
239
269
|
view.hidden = isHidden;
|
|
240
270
|
}
|
|
241
271
|
|
|
242
|
-
|
|
272
|
+
// Reanimated changes /start
|
|
273
|
+
REASnapshot *snapshotBefore;
|
|
274
|
+
if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
275
|
+
snapshotBefore = [[REASnapshot alloc] init:view];
|
|
276
|
+
}
|
|
277
|
+
// Reanimated changes /end
|
|
278
|
+
|
|
243
279
|
if (creatingLayoutAnimation) {
|
|
244
280
|
// Animate view creation
|
|
245
281
|
[view reactSetFrame:frame];
|
|
@@ -285,18 +321,23 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
285
321
|
completion(YES);
|
|
286
322
|
}
|
|
287
323
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
324
|
+
// Reanimated changes /start
|
|
325
|
+
if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
326
|
+
if (isNew) {
|
|
327
|
+
REASnapshot *snapshot = [[REASnapshot alloc] init:view];
|
|
328
|
+
[_animationsManager onViewCreate:view after:snapshot];
|
|
329
|
+
} else {
|
|
330
|
+
REASnapshot *snapshotAfter = [[REASnapshot alloc] init:view];
|
|
331
|
+
[_animationsManager onViewUpdate:view before:snapshotBefore after:snapshotAfter];
|
|
332
|
+
}
|
|
294
333
|
}
|
|
295
334
|
}
|
|
296
335
|
|
|
297
336
|
[_animationsManager removeLeftovers];
|
|
298
337
|
// Clean up
|
|
338
|
+
// uiManager->_layoutAnimationGroup = nil;
|
|
299
339
|
[uiManager setValue:nil forKey:@"_layoutAnimationGroup"];
|
|
340
|
+
// Reanimated changes /end
|
|
300
341
|
};
|
|
301
342
|
}
|
|
302
343
|
|
|
@@ -331,7 +372,10 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
331
372
|
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
332
373
|
[view.reactSuperview removeReactSubview:view];
|
|
333
374
|
id<RCTComponent> parentView = viewRegistry[tag];
|
|
334
|
-
|
|
375
|
+
@try {
|
|
376
|
+
[parentView removeReactSubview:view];
|
|
377
|
+
} @catch (id anException) {
|
|
378
|
+
}
|
|
335
379
|
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
336
380
|
if ([view isKindOfClass:[RNSScreenView class]]) {
|
|
337
381
|
[parentView didUpdateReactSubviews];
|
package/ios/REAEventDispatcher.m
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
- (void)sendEvent:(id<RCTEvent>)event
|
|
9
9
|
{
|
|
10
|
-
[[
|
|
10
|
+
[[[self bridge] moduleForName:@"ReanimatedModule"] eventDispatcherWillDispatchEvent:event];
|
|
11
11
|
[super sendEvent:event];
|
|
12
12
|
}
|
|
13
13
|
|
package/ios/REAModule.h
CHANGED
package/ios/REAModule.m
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
typedef void (^AnimatedOperation)(REANodesManager *nodesManager);
|
|
8
8
|
|
|
9
|
-
RCTBridge *_bridge_reanimated = nil;
|
|
10
|
-
|
|
11
9
|
@implementation REAModule {
|
|
12
10
|
NSMutableArray<AnimatedOperation> *_operations;
|
|
13
11
|
REATransitionManager *_transitionManager;
|
|
@@ -17,7 +15,6 @@ RCT_EXPORT_MODULE(ReanimatedModule);
|
|
|
17
15
|
|
|
18
16
|
- (void)invalidate
|
|
19
17
|
{
|
|
20
|
-
_bridge_reanimated = nil;
|
|
21
18
|
_transitionManager = nil;
|
|
22
19
|
[_nodesManager invalidate];
|
|
23
20
|
[self.bridge.uiManager.observerCoordinator removeObserver:self];
|
package/ios/REANodesManager.m
CHANGED
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onAnimationFrame:)];
|
|
119
|
+
_displayLink.preferredFramesPerSecond = 120; // will fallback to 60 fps for devices without Pro Motion display
|
|
119
120
|
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
120
121
|
[_displayLink setPaused:true];
|
|
121
122
|
return self;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
#include <vector>
|
|
7
7
|
#import <vector>
|
|
8
|
+
#import "RNGestureHandlerStateManager.h"
|
|
8
9
|
|
|
9
10
|
namespace reanimated {
|
|
10
11
|
|
|
@@ -17,5 +18,9 @@ void scrollTo(
|
|
|
17
18
|
double x,
|
|
18
19
|
double y,
|
|
19
20
|
bool animated);
|
|
21
|
+
void setGestureState(
|
|
22
|
+
id<RNGestureHandlerStateManager> gestureHandlerStateManager,
|
|
23
|
+
int handlerTag,
|
|
24
|
+
int newState);
|
|
20
25
|
|
|
21
26
|
} // namespace reanimated
|
|
@@ -18,7 +18,7 @@ std::vector<std::pair<std::string, double>> measure(int viewTag, RCTUIManager *u
|
|
|
18
18
|
rootView = rootView.superview;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
if (rootView == nil
|
|
21
|
+
if (rootView == nil) {
|
|
22
22
|
return std::vector<std::pair<std::string, double>>(1, std::make_pair("x", -1234567.0));
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -44,4 +44,11 @@ void scrollTo(int scrollViewTag, RCTUIManager *uiManager, double x, double y, bo
|
|
|
44
44
|
[scrollView scrollToOffset:(CGPoint){(CGFloat)x, (CGFloat)y} animated:animated];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
void setGestureState(id<RNGestureHandlerStateManager> gestureHandlerStateManager, int handlerTag, int newState)
|
|
48
|
+
{
|
|
49
|
+
if (gestureHandlerStateManager != nil) {
|
|
50
|
+
[gestureHandlerStateManager setGestureState:newState forHandler:handlerTag];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
}
|
package/ios/native/NativeProxy.h
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#import "REAModule.h"
|
|
13
13
|
#import "REANodesManager.h"
|
|
14
14
|
#import "REAUIManager.h"
|
|
15
|
+
#import "RNGestureHandlerStateManager.h"
|
|
15
16
|
|
|
16
17
|
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
17
18
|
#import <reacthermes/HermesExecutorFactory.h>
|
|
@@ -86,9 +87,10 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v
|
|
|
86
87
|
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
90
|
+
std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
91
|
+
RCTBridge *bridge,
|
|
92
|
+
std::shared_ptr<CallInvoker> jsInvoker)
|
|
90
93
|
{
|
|
91
|
-
RCTBridge *bridge = _bridge_reanimated;
|
|
92
94
|
REAModule *reanimatedModule = [bridge moduleForClass:[REAModule class]];
|
|
93
95
|
|
|
94
96
|
auto propUpdater = [reanimatedModule](
|
|
@@ -111,6 +113,11 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
111
113
|
scrollTo(viewTag, uiManager, x, y, animated);
|
|
112
114
|
};
|
|
113
115
|
|
|
116
|
+
id<RNGestureHandlerStateManager> gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
|
|
117
|
+
auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
|
|
118
|
+
setGestureState(gestureHandlerStateManager, handlerTag, newState);
|
|
119
|
+
};
|
|
120
|
+
|
|
114
121
|
auto propObtainer = [reanimatedModule](
|
|
115
122
|
jsi::Runtime &rt, const int viewTag, const jsi::String &propName) -> jsi::Value {
|
|
116
123
|
NSString *propNameConverted = [NSString stringWithFormat:@"%s", propName.utf8(rt).c_str()];
|
|
@@ -223,6 +230,7 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
223
230
|
scrollToFunction,
|
|
224
231
|
measuringFunction,
|
|
225
232
|
getCurrentTime,
|
|
233
|
+
setGestureStateFunction,
|
|
226
234
|
};
|
|
227
235
|
|
|
228
236
|
module = std::make_shared<NativeReanimatedModule>(
|
|
@@ -35,17 +35,22 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
|
35
35
|
[eventDispatcher setBridge:bridge];
|
|
36
36
|
#endif
|
|
37
37
|
[bridge updateModuleWithInstance:eventDispatcher];
|
|
38
|
-
_bridge_reanimated = bridge;
|
|
39
38
|
const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
|
|
40
39
|
if (!bridge) {
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
#if RNVERSION >= 63
|
|
44
|
-
auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
|
|
43
|
+
auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker);
|
|
45
44
|
#else
|
|
46
45
|
auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
|
|
47
|
-
auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
|
|
46
|
+
auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
|
|
48
47
|
#endif
|
|
48
|
+
runtime.global().setProperty(
|
|
49
|
+
runtime,
|
|
50
|
+
"_WORKLET_RUNTIME",
|
|
51
|
+
static_cast<double>(
|
|
52
|
+
reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
|
|
53
|
+
|
|
49
54
|
runtime.global().setProperty(
|
|
50
55
|
runtime,
|
|
51
56
|
jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
|