react-native-reanimated 3.0.0-rc.5 → 3.0.0-rc.6
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/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 +54 -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/native/NativeProxy.mm +49 -47
- package/lib/commonjs/createAnimatedComponent.js +26 -26
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +4 -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 +4 -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 +1 -1
- package/src/createAnimatedComponent.tsx +48 -39
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +15 -0
- package/src/reanimated2/core.ts +19 -10
- package/src/reanimated2/globals.d.ts +10 -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
|
@@ -29,13 +29,13 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
29
29
|
private AnimationsManager mAnimationsManager = null;
|
|
30
30
|
private volatile boolean mInitialized = false;
|
|
31
31
|
private ReactApplicationContext mContext;
|
|
32
|
-
private WeakReference<NativeViewHierarchyManager>
|
|
32
|
+
private WeakReference<NativeViewHierarchyManager> mWeakNativeViewHierarchyManager =
|
|
33
33
|
new WeakReference<>(null);
|
|
34
34
|
|
|
35
35
|
ReaLayoutAnimator(
|
|
36
36
|
ReactApplicationContext context, NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
37
37
|
mContext = context;
|
|
38
|
-
|
|
38
|
+
mWeakNativeViewHierarchyManager = new WeakReference<>(nativeViewHierarchyManager);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public void maybeInit() {
|
|
@@ -44,7 +44,7 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
44
44
|
ReanimatedModule reanimatedModule = mContext.getNativeModule(ReanimatedModule.class);
|
|
45
45
|
mAnimationsManager = reanimatedModule.getNodesManager().getAnimationsManager();
|
|
46
46
|
mAnimationsManager.setReanimatedNativeHierarchyManager(
|
|
47
|
-
(ReanimatedNativeHierarchyManager)
|
|
47
|
+
(ReanimatedNativeHierarchyManager) mWeakNativeViewHierarchyManager.get());
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -89,12 +89,12 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
89
89
|
mAnimationsManager.onViewCreate(
|
|
90
90
|
view,
|
|
91
91
|
(ViewGroup) view.getParent(),
|
|
92
|
-
new Snapshot(view,
|
|
92
|
+
new Snapshot(view, mWeakNativeViewHierarchyManager.get()));
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
|
-
Snapshot before = new Snapshot(view,
|
|
95
|
+
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManager.get());
|
|
96
96
|
view.layout(x, y, x + width, y + height);
|
|
97
|
-
Snapshot after = new Snapshot(view,
|
|
97
|
+
Snapshot after = new Snapshot(view, mWeakNativeViewHierarchyManager.get());
|
|
98
98
|
mAnimationsManager.onViewUpdate(view, before, after);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -113,7 +113,7 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
UiThreadUtil.assertOnUiThread();
|
|
116
|
-
NativeViewHierarchyManager nativeViewHierarchyManager =
|
|
116
|
+
NativeViewHierarchyManager nativeViewHierarchyManager = mWeakNativeViewHierarchyManager.get();
|
|
117
117
|
ViewManager viewManager;
|
|
118
118
|
try {
|
|
119
119
|
viewManager = nativeViewHierarchyManager.resolveViewManager(view.getId());
|
|
@@ -147,45 +147,9 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
maybeInit();
|
|
150
|
-
Snapshot before = new Snapshot(view,
|
|
150
|
+
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManager.get());
|
|
151
151
|
mAnimationsManager.onViewRemoval(
|
|
152
152
|
view, (ViewGroup) view.getParent(), before, () -> listener.onAnimationEnd());
|
|
153
|
-
if (viewManager instanceof ViewGroupManager) {
|
|
154
|
-
ViewGroupManager vgm = (ViewGroupManager) viewManager;
|
|
155
|
-
for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
|
|
156
|
-
dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
private void dfs(View view, NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
162
|
-
int tag = view.getId();
|
|
163
|
-
if (tag == -1) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
ViewManager vm = null;
|
|
167
|
-
try {
|
|
168
|
-
vm = nativeViewHierarchyManager.resolveViewManager(tag);
|
|
169
|
-
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
|
|
170
|
-
mAnimationsManager.onViewRemoval(
|
|
171
|
-
view,
|
|
172
|
-
(ViewGroup) view.getParent(),
|
|
173
|
-
before,
|
|
174
|
-
() -> {
|
|
175
|
-
ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager =
|
|
176
|
-
(ReanimatedNativeHierarchyManager) nativeViewHierarchyManager;
|
|
177
|
-
reanimatedNativeHierarchyManager.publicDropView(view);
|
|
178
|
-
});
|
|
179
|
-
} catch (IllegalViewOperationException e) {
|
|
180
|
-
// (IllegalViewOperationException) == (vm == null)
|
|
181
|
-
e.printStackTrace();
|
|
182
|
-
}
|
|
183
|
-
if (vm instanceof ViewGroupManager) {
|
|
184
|
-
ViewGroupManager vgm = (ViewGroupManager) vm;
|
|
185
|
-
for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
|
|
186
|
-
dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
153
|
}
|
|
190
154
|
|
|
191
155
|
public boolean isLayoutAnimationEnabled() {
|
|
@@ -9,7 +9,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
9
9
|
import com.facebook.react.bridge.UiThreadUtil;
|
|
10
10
|
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
11
11
|
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
12
|
-
import com.facebook.react.uimanager.RootViewManager;
|
|
13
12
|
import com.facebook.react.uimanager.ViewAtIndex;
|
|
14
13
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
15
14
|
import com.facebook.react.uimanager.ViewManager;
|
|
@@ -28,14 +27,13 @@ import java.util.Set;
|
|
|
28
27
|
class ReaLayoutAnimator extends LayoutAnimationController {
|
|
29
28
|
private AnimationsManager mAnimationsManager = null;
|
|
30
29
|
private volatile boolean mInitialized = false;
|
|
31
|
-
private ReactApplicationContext mContext;
|
|
32
|
-
private WeakReference<NativeViewHierarchyManager>
|
|
33
|
-
new WeakReference<>(null);
|
|
30
|
+
private final ReactApplicationContext mContext;
|
|
31
|
+
private final WeakReference<NativeViewHierarchyManager> mWeakNativeViewHierarchyManager;
|
|
34
32
|
|
|
35
33
|
ReaLayoutAnimator(
|
|
36
34
|
ReactApplicationContext context, NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
37
35
|
mContext = context;
|
|
38
|
-
|
|
36
|
+
mWeakNativeViewHierarchyManager = new WeakReference<>(nativeViewHierarchyManager);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
public void maybeInit() {
|
|
@@ -44,7 +42,7 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
44
42
|
ReanimatedModule reanimatedModule = mContext.getNativeModule(ReanimatedModule.class);
|
|
45
43
|
mAnimationsManager = reanimatedModule.getNodesManager().getAnimationsManager();
|
|
46
44
|
mAnimationsManager.setReanimatedNativeHierarchyManager(
|
|
47
|
-
(ReanimatedNativeHierarchyManager)
|
|
45
|
+
(ReanimatedNativeHierarchyManager) mWeakNativeViewHierarchyManager.get());
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -89,12 +87,12 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
89
87
|
mAnimationsManager.onViewCreate(
|
|
90
88
|
view,
|
|
91
89
|
(ViewGroup) view.getParent(),
|
|
92
|
-
new Snapshot(view,
|
|
90
|
+
new Snapshot(view, mWeakNativeViewHierarchyManager.get()));
|
|
93
91
|
}
|
|
94
92
|
} else {
|
|
95
|
-
Snapshot before = new Snapshot(view,
|
|
93
|
+
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManager.get());
|
|
96
94
|
view.layout(x, y, x + width, y + height);
|
|
97
|
-
Snapshot after = new Snapshot(view,
|
|
95
|
+
Snapshot after = new Snapshot(view, mWeakNativeViewHierarchyManager.get());
|
|
98
96
|
mAnimationsManager.onViewUpdate(view, before, after);
|
|
99
97
|
}
|
|
100
98
|
}
|
|
@@ -113,7 +111,7 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
113
111
|
return;
|
|
114
112
|
}
|
|
115
113
|
UiThreadUtil.assertOnUiThread();
|
|
116
|
-
NativeViewHierarchyManager nativeViewHierarchyManager =
|
|
114
|
+
NativeViewHierarchyManager nativeViewHierarchyManager = mWeakNativeViewHierarchyManager.get();
|
|
117
115
|
ViewManager viewManager;
|
|
118
116
|
try {
|
|
119
117
|
viewManager = nativeViewHierarchyManager.resolveViewManager(view.getId());
|
|
@@ -147,45 +145,8 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
147
|
maybeInit();
|
|
150
|
-
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
|
|
151
148
|
mAnimationsManager.onViewRemoval(
|
|
152
|
-
view, (ViewGroup) view.getParent(),
|
|
153
|
-
if (viewManager instanceof ViewGroupManager) {
|
|
154
|
-
ViewGroupManager vgm = (ViewGroupManager) viewManager;
|
|
155
|
-
for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
|
|
156
|
-
dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
private void dfs(View view, NativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
162
|
-
int tag = view.getId();
|
|
163
|
-
if (tag == -1) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
ViewManager vm = null;
|
|
167
|
-
try {
|
|
168
|
-
vm = nativeViewHierarchyManager.resolveViewManager(tag);
|
|
169
|
-
Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
|
|
170
|
-
mAnimationsManager.onViewRemoval(
|
|
171
|
-
view,
|
|
172
|
-
(ViewGroup) view.getParent(),
|
|
173
|
-
before,
|
|
174
|
-
() -> {
|
|
175
|
-
ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager =
|
|
176
|
-
(ReanimatedNativeHierarchyManager) nativeViewHierarchyManager;
|
|
177
|
-
reanimatedNativeHierarchyManager.publicDropView(view);
|
|
178
|
-
});
|
|
179
|
-
} catch (IllegalViewOperationException e) {
|
|
180
|
-
// (IllegalViewOperationException) == (vm == null)
|
|
181
|
-
e.printStackTrace();
|
|
182
|
-
}
|
|
183
|
-
if (vm instanceof ViewGroupManager) {
|
|
184
|
-
ViewGroupManager vgm = (ViewGroupManager) vm;
|
|
185
|
-
for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
|
|
186
|
-
dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
149
|
+
view, (ViewGroup) view.getParent(), listener::onAnimationEnd);
|
|
189
150
|
}
|
|
190
151
|
|
|
191
152
|
public boolean isLayoutAnimationEnabled() {
|
|
@@ -197,8 +158,8 @@ class ReaLayoutAnimator extends LayoutAnimationController {
|
|
|
197
158
|
public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager {
|
|
198
159
|
private final HashMap<Integer, ArrayList<View>> toBeRemoved = new HashMap<>();
|
|
199
160
|
private final HashMap<Integer, Runnable> cleanerCallback = new HashMap<>();
|
|
200
|
-
private LayoutAnimationController mReaLayoutAnimator
|
|
201
|
-
private HashMap<Integer, Set<Integer>> mPendingDeletionsForTag = new HashMap<>();
|
|
161
|
+
private final LayoutAnimationController mReaLayoutAnimator;
|
|
162
|
+
private final HashMap<Integer, Set<Integer>> mPendingDeletionsForTag = new HashMap<>();
|
|
202
163
|
private boolean initOk = true;
|
|
203
164
|
|
|
204
165
|
public ReanimatedNativeHierarchyManager(
|
|
@@ -260,11 +221,6 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
|
|
|
260
221
|
}
|
|
261
222
|
}
|
|
262
223
|
|
|
263
|
-
public ReanimatedNativeHierarchyManager(
|
|
264
|
-
ViewManagerRegistry viewManagers, RootViewManager manager) {
|
|
265
|
-
super(viewManagers, manager);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
224
|
private boolean isLayoutAnimationDisabled() {
|
|
269
225
|
return !initOk || !((ReaLayoutAnimator) mReaLayoutAnimator).isLayoutAnimationEnabled();
|
|
270
226
|
}
|
|
@@ -355,14 +311,12 @@ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager
|
|
|
355
311
|
continue;
|
|
356
312
|
}
|
|
357
313
|
toBeRemovedChildren.add(view);
|
|
314
|
+
// It's far from optimal but let's leave it as it is for now
|
|
358
315
|
cleanerCallback.put(
|
|
359
316
|
view.getId(),
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
toBeRemovedChildren.remove(view);
|
|
364
|
-
viewGroupManager.removeView(viewGroup, view);
|
|
365
|
-
} // It's far from optimal but let's leave it as it is for now
|
|
317
|
+
() -> {
|
|
318
|
+
toBeRemovedChildren.remove(view);
|
|
319
|
+
viewGroupManager.removeView(viewGroup, view);
|
|
366
320
|
});
|
|
367
321
|
}
|
|
368
322
|
}
|
|
@@ -12,20 +12,30 @@ typedef NS_ENUM(NSInteger, ViewState) {
|
|
|
12
12
|
ToRemove,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
typedef BOOL (^REAHasAnimationBlock)(NSNumber *_Nonnull tag, NSString *_Nonnull type);
|
|
16
|
+
typedef void (^REAAnimationStartingBlock)(
|
|
17
|
+
NSNumber *_Nonnull tag,
|
|
18
|
+
NSString *_Nonnull type,
|
|
19
|
+
NSDictionary *_Nonnull yogaValues,
|
|
20
|
+
NSNumber *_Nonnull depth);
|
|
21
|
+
typedef void (^REAAnimationRemovingBlock)(NSNumber *_Nonnull tag);
|
|
22
|
+
|
|
15
23
|
@interface REAAnimationsManager : NSObject
|
|
16
24
|
|
|
17
25
|
- (instancetype)initWithUIManager:(RCTUIManager *)uiManager;
|
|
18
|
-
- (void)
|
|
19
|
-
- (void)
|
|
20
|
-
|
|
21
|
-
- (void)
|
|
22
|
-
- (void)
|
|
26
|
+
- (void)setAnimationStartingBlock:(REAAnimationStartingBlock)startAnimation;
|
|
27
|
+
- (void)setHasAnimationBlock:(REAHasAnimationBlock)hasAnimation;
|
|
28
|
+
- (void)setAnimationRemovingBlock:(REAAnimationRemovingBlock)clearAnimation;
|
|
29
|
+
- (void)progressLayoutAnimationWithStyle:(NSDictionary *_Nonnull)newStyle forTag:(NSNumber *_Nonnull)tag;
|
|
30
|
+
- (void)endLayoutAnimationForTag:(NSNumber *_Nonnull)tag cancelled:(BOOL)cancelled removeView:(BOOL)removeView;
|
|
23
31
|
- (void)invalidate;
|
|
24
|
-
- (void)
|
|
32
|
+
- (void)viewDidMount:(UIView *)view withBeforeSnapshot:(REASnapshot *)snapshot;
|
|
33
|
+
- (REASnapshot *)prepareSnapshotBeforeMountForView:(UIView *)view;
|
|
34
|
+
- (BOOL)wantsHandleRemovalOfView:(UIView *)view;
|
|
35
|
+
- (void)removeAnimationsFromSubtree:(UIView *)view;
|
|
36
|
+
- (void)removeChildren:(NSArray<UIView *> *)children fromContainer:(UIView *)container;
|
|
25
37
|
- (void)onViewCreate:(UIView *)view after:(REASnapshot *)after;
|
|
26
38
|
- (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after;
|
|
27
|
-
- (void)setToBeRemovedRegistry:(NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> *)toBeRemovedRegister;
|
|
28
|
-
- (void)removeLeftovers;
|
|
29
39
|
|
|
30
40
|
@end
|
|
31
41
|
|