react-native-reanimated 2.3.0-beta.2 → 2.3.1
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 +12 -3
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
- package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
- package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
- package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
- package/Common/cpp/Tools/Mapper.cpp +1 -1
- package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
- package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
- package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
- package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
- package/Common/cpp/headers/Tools/Mapper.h +2 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
- package/Common/cpp/headers/Tools/Scheduler.h +2 -0
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
- package/Common/cpp/hidden_headers/Logger.h +2 -2
- package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
- package/README.md +1 -1
- package/RNReanimated.podspec +21 -3
- package/android/build.gradle +33 -13
- package/android/expo/linking.gradle +46 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
- package/ios/LayoutReanimation/REAUIManager.mm +101 -61
- package/ios/Nodes/REAPropsNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +0 -3
- package/ios/REANodesManager.m +1 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/native/NativeMethods.h +5 -0
- package/ios/native/NativeMethods.mm +14 -6
- package/ios/native/NativeProxy.h +1 -0
- package/ios/native/NativeProxy.mm +84 -63
- package/ios/native/REAIOSErrorHandler.mm +19 -15
- package/ios/native/REAIOSLogger.mm +10 -6
- package/ios/native/REAIOSScheduler.mm +17 -10
- package/ios/native/REAInitializer.mm +39 -37
- package/ios/native/UIResponder+Reanimated.mm +2 -2
- package/lib/Animated.js +11 -5
- package/lib/ConfigHelper.js +121 -138
- package/lib/ReanimatedEventEmitter.js +0 -1
- package/lib/ReanimatedModule.js +0 -1
- package/lib/ReanimatedModule.macos.js +0 -1
- package/lib/ReanimatedModule.native.js +5 -6
- package/lib/ReanimatedModule.windows.js +0 -1
- package/lib/ReanimatedModuleCompat.js +64 -35
- package/lib/createAnimatedComponent.js +469 -499
- package/lib/index.js +11 -5
- package/lib/reanimated1/core/Core.test.js +1 -1
- package/lib/reanimated2/NativeMethods.js +7 -0
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/reanimated2/PropAdapters.js +0 -1
- package/lib/reanimated2/UpdateProps.js +1 -1
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
- package/lib/reanimated2/animation/spring.js +2 -0
- package/lib/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/reanimated2/animation/util.js +23 -0
- package/lib/reanimated2/component/FlatList.js +30 -0
- package/lib/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/reanimated2/component/index.js +4 -0
- package/lib/reanimated2/core.js +34 -6
- package/lib/reanimated2/globals.d.ts +8 -0
- package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
- package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
- package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
- package/lib/reanimated2/js-reanimated/index.js +10 -8
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/lib/reanimated2/mock.js +3 -1
- package/lib/setAndForwardRef.js +14 -48
- package/mock.js +1 -1
- package/package.json +27 -23
- package/plugin.js +111 -110
- package/react-native-reanimated.d.ts +56 -27
- package/src/Animated.js +11 -5
- package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
- package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
- package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
- package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
- package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
- package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
- package/src/ReanimatedModuleCompat.ts +51 -0
- package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/NativeMethods.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
- package/src/reanimated2/PropAdapters.ts +0 -1
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/commonTypes.ts +4 -4
- package/src/reanimated2/animation/decay.ts +2 -2
- package/src/reanimated2/animation/delay.ts +3 -3
- package/src/reanimated2/animation/index.ts +7 -7
- package/src/reanimated2/animation/repeat.ts +4 -4
- package/src/reanimated2/animation/sequence.ts +2 -2
- package/src/reanimated2/animation/spring.ts +6 -5
- package/src/reanimated2/animation/styleAnimation.ts +24 -12
- package/src/reanimated2/animation/timing.ts +5 -5
- package/src/reanimated2/animation/util.ts +45 -6
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +62 -17
- package/src/reanimated2/globals.d.ts +8 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
- package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
- package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
- package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
- package/src/reanimated2/js-reanimated/index.ts +31 -14
- package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/mock.ts +3 -1
- package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
- package/src/ReanimatedModuleCompat.js +0 -37
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
@interface REAAnimationsManager ()
|
|
9
9
|
|
|
10
|
+
typedef NS_ENUM(NSInteger, FrameConfigType) { EnteringFrame, ExitingFrame };
|
|
11
|
+
|
|
10
12
|
@property (atomic, nullable) void (^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber *);
|
|
11
13
|
@property (atomic, nullable) void (^removeConfigForTag)(NSNumber *);
|
|
12
14
|
|
|
@@ -21,6 +23,8 @@
|
|
|
21
23
|
NSMutableDictionary<NSNumber *, NSNumber *> *_states;
|
|
22
24
|
NSMutableDictionary<NSNumber *, UIView *> *_viewForTag;
|
|
23
25
|
NSMutableSet<NSNumber *> *_toRemove;
|
|
26
|
+
NSMutableArray<NSString *> *_targetKeys;
|
|
27
|
+
NSMutableArray<NSString *> *_currentKeys;
|
|
24
28
|
BOOL _cleaningScheduled;
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -43,6 +47,13 @@
|
|
|
43
47
|
_viewForTag = [NSMutableDictionary new];
|
|
44
48
|
_toRemove = [NSMutableSet new];
|
|
45
49
|
_cleaningScheduled = false;
|
|
50
|
+
|
|
51
|
+
_targetKeys = [NSMutableArray new];
|
|
52
|
+
_currentKeys = [NSMutableArray new];
|
|
53
|
+
for (NSString *key in [[self class] layoutKeys]) {
|
|
54
|
+
[_targetKeys addObject:[NSString stringWithFormat:@"target%@", [key capitalizedString]]];
|
|
55
|
+
[_currentKeys addObject:[NSString stringWithFormat:@"current%@", [key capitalizedString]]];
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
return self;
|
|
48
59
|
}
|
|
@@ -56,6 +67,8 @@
|
|
|
56
67
|
_viewForTag = nil;
|
|
57
68
|
_toRemove = nil;
|
|
58
69
|
_cleaningScheduled = false;
|
|
70
|
+
_targetKeys = nil;
|
|
71
|
+
_currentKeys = nil;
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
- (void)setAnimationStartingBlock:
|
|
@@ -208,16 +221,53 @@
|
|
|
208
221
|
[componentData setProps:newProps forView:view];
|
|
209
222
|
}
|
|
210
223
|
|
|
211
|
-
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
|
|
224
|
+
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values frameConfig:(FrameConfigType)frameConfig
|
|
225
|
+
{
|
|
226
|
+
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
227
|
+
if (frameConfig == EnteringFrame) {
|
|
228
|
+
NSDictionary *preparedData = @{
|
|
229
|
+
@"targetWidth" : values[@"width"],
|
|
230
|
+
@"targetHeight" : values[@"height"],
|
|
231
|
+
@"targetOriginX" : values[@"originX"],
|
|
232
|
+
@"targetOriginY" : values[@"originY"],
|
|
233
|
+
@"targetGlobalOriginX" : values[@"globalOriginX"],
|
|
234
|
+
@"targetGlobalOriginY" : values[@"globalOriginY"],
|
|
235
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
236
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
237
|
+
};
|
|
238
|
+
return preparedData;
|
|
239
|
+
} else {
|
|
240
|
+
NSDictionary *preparedData = @{
|
|
241
|
+
@"currentWidth" : values[@"width"],
|
|
242
|
+
@"currentHeight" : values[@"height"],
|
|
243
|
+
@"currentOriginX" : values[@"originX"],
|
|
244
|
+
@"currentOriginY" : values[@"originY"],
|
|
245
|
+
@"currentGlobalOriginX" : values[@"globalOriginX"],
|
|
246
|
+
@"currentGlobalOriginY" : values[@"globalOriginY"],
|
|
247
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
248
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
249
|
+
};
|
|
250
|
+
return preparedData;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
- (NSDictionary *)prepareDataForLayoutAnimatingWorklet:(NSMutableDictionary *)currentValues
|
|
255
|
+
targetValues:(NSMutableDictionary *)targetValues
|
|
212
256
|
{
|
|
213
257
|
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
214
258
|
NSDictionary *preparedData = @{
|
|
215
|
-
@"
|
|
216
|
-
@"
|
|
217
|
-
@"
|
|
218
|
-
@"
|
|
219
|
-
@"
|
|
220
|
-
@"
|
|
259
|
+
@"currentWidth" : currentValues[@"width"],
|
|
260
|
+
@"currentHeight" : currentValues[@"height"],
|
|
261
|
+
@"currentOriginX" : currentValues[@"originX"],
|
|
262
|
+
@"currentOriginY" : currentValues[@"originY"],
|
|
263
|
+
@"currentGlobalOriginX" : currentValues[@"globalOriginX"],
|
|
264
|
+
@"currentGlobalOriginY" : currentValues[@"globalOriginY"],
|
|
265
|
+
@"targetWidth" : targetValues[@"width"],
|
|
266
|
+
@"targetHeight" : targetValues[@"height"],
|
|
267
|
+
@"targetOriginX" : targetValues[@"originX"],
|
|
268
|
+
@"targetOriginY" : targetValues[@"originY"],
|
|
269
|
+
@"targetGlobalOriginX" : targetValues[@"globalOriginX"],
|
|
270
|
+
@"targetGlobalOriginY" : targetValues[@"globalOriginY"],
|
|
221
271
|
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
222
272
|
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
223
273
|
};
|
|
@@ -241,12 +291,13 @@
|
|
|
241
291
|
return;
|
|
242
292
|
}
|
|
243
293
|
_states[tag] = [NSNumber numberWithInt:Disappearing];
|
|
244
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
294
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues frameConfig:ExitingFrame];
|
|
245
295
|
_startAnimationForTag(tag, @"exiting", preparedValues, @(0));
|
|
246
296
|
}
|
|
247
297
|
|
|
248
298
|
- (void)onViewCreate:(UIView *)view after:(REASnapshot *)after
|
|
249
299
|
{
|
|
300
|
+
_reaUiManager.flushUiOperations();
|
|
250
301
|
NSNumber *tag = view.reactTag;
|
|
251
302
|
if (_states[tag] == nil) {
|
|
252
303
|
_states[tag] = [NSNumber numberWithInt:Inactive];
|
|
@@ -256,7 +307,7 @@
|
|
|
256
307
|
ViewState state = [_states[tag] intValue];
|
|
257
308
|
if (state == Inactive) {
|
|
258
309
|
if (targetValues != nil) {
|
|
259
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
310
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
|
|
260
311
|
_startAnimationForTag(tag, @"entering", preparedValues, @(0));
|
|
261
312
|
}
|
|
262
313
|
return;
|
|
@@ -267,7 +318,7 @@
|
|
|
267
318
|
{
|
|
268
319
|
NSNumber *tag = view.reactTag;
|
|
269
320
|
NSMutableDictionary *targetValues = after.values;
|
|
270
|
-
NSMutableDictionary *
|
|
321
|
+
NSMutableDictionary *currentValues = before.values;
|
|
271
322
|
if (_states[tag] == nil) {
|
|
272
323
|
return;
|
|
273
324
|
}
|
|
@@ -277,8 +328,9 @@
|
|
|
277
328
|
}
|
|
278
329
|
if (state == Appearing) {
|
|
279
330
|
BOOL doNotStartLayout = true;
|
|
280
|
-
for (
|
|
281
|
-
if ([((NSNumber *)
|
|
331
|
+
for (int i = 0; i < [[self class] layoutKeys].count; ++i) {
|
|
332
|
+
if ([((NSNumber *)currentValues[_currentKeys[i]]) doubleValue] !=
|
|
333
|
+
[((NSNumber *)targetValues[_targetKeys[i]]) doubleValue]) {
|
|
282
334
|
doNotStartLayout = false;
|
|
283
335
|
}
|
|
284
336
|
}
|
|
@@ -287,13 +339,7 @@
|
|
|
287
339
|
}
|
|
288
340
|
}
|
|
289
341
|
_states[view.reactTag] = [NSNumber numberWithInt:Layout];
|
|
290
|
-
NSDictionary *
|
|
291
|
-
NSDictionary *preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
292
|
-
NSMutableDictionary *preparedValues = [NSMutableDictionary new];
|
|
293
|
-
[preparedValues addEntriesFromDictionary:preparedTargetValues];
|
|
294
|
-
for (NSString *key in preparedStartValues.allKeys) {
|
|
295
|
-
preparedValues[[NSString stringWithFormat:@"%@%@", @"b", key]] = preparedStartValues[key];
|
|
296
|
-
}
|
|
342
|
+
NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
|
|
297
343
|
_startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
|
|
298
344
|
}
|
|
299
345
|
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
#import "REAUIManager.h"
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
|
-
#
|
|
4
|
-
#import "RCTUIManagerObserverCoordinator.h"
|
|
5
|
-
#import "RCTRootShadowView.h"
|
|
6
|
-
#import "RCTRootViewInternal.h"
|
|
7
|
-
#import "RCTLayoutAnimation.h"
|
|
8
|
-
#import "RCTLayoutAnimationGroup.h"
|
|
3
|
+
#include "FeaturesConfig.h"
|
|
9
4
|
#import "REAIOSScheduler.h"
|
|
10
5
|
#include "Scheduler.h"
|
|
11
6
|
|
|
7
|
+
#import <React/RCTComponentData.h>
|
|
8
|
+
#import <React/RCTLayoutAnimation.h>
|
|
9
|
+
#import <React/RCTLayoutAnimationGroup.h>
|
|
10
|
+
#import <React/RCTModalHostView.h>
|
|
11
|
+
#import <React/RCTRootShadowView.h>
|
|
12
|
+
#import <React/RCTRootViewInternal.h>
|
|
13
|
+
#import <React/RCTUIManagerObserverCoordinator.h>
|
|
14
|
+
|
|
12
15
|
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
13
16
|
#import <RNScreens/RNSScreen.h>
|
|
14
17
|
#endif
|
|
15
18
|
|
|
16
|
-
@interface RCTUIManager(REA)
|
|
19
|
+
@interface RCTUIManager (REA)
|
|
17
20
|
- (void)_manageChildren:(NSNumber *)containerTag
|
|
18
21
|
moveFromIndices:(NSArray<NSNumber *> *)moveFromIndices
|
|
19
22
|
moveToIndices:(NSArray<NSNumber *> *)moveToIndices
|
|
@@ -29,19 +32,19 @@
|
|
|
29
32
|
@implementation REAUIManager
|
|
30
33
|
|
|
31
34
|
BOOL blockSetter = false;
|
|
32
|
-
NSMutableDictionary<NSNumber*, NSMutableSet<id<RCTComponent
|
|
33
|
-
NSMutableDictionary<NSNumber*, NSNumber
|
|
34
|
-
REAAnimationsManager*
|
|
35
|
+
NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> *_toBeRemovedRegister;
|
|
36
|
+
NSMutableDictionary<NSNumber *, NSNumber *> *_parentMapper;
|
|
37
|
+
REAAnimationsManager *_animationsManager;
|
|
35
38
|
std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
36
39
|
|
|
37
|
-
+ (NSString*)moduleName
|
|
40
|
+
+ (NSString *)moduleName
|
|
38
41
|
{
|
|
39
42
|
return NSStringFromClass([RCTUIManager class]);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
- (void)setBridge:(RCTBridge *)bridge
|
|
43
46
|
{
|
|
44
|
-
if(!_blockSetter) {
|
|
47
|
+
if (!_blockSetter) {
|
|
45
48
|
_blockSetter = true;
|
|
46
49
|
|
|
47
50
|
self.bridge = bridge;
|
|
@@ -49,8 +52,10 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
49
52
|
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewRegistry"] forKey:@"_shadowViewRegistry"];
|
|
50
53
|
[self setValue:[bridge.uiManager valueForKey:@"_viewRegistry"] forKey:@"_viewRegistry"];
|
|
51
54
|
[self setValue:[bridge.uiManager valueForKey:@"_nativeIDRegistry"] forKey:@"_nativeIDRegistry"];
|
|
52
|
-
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewsWithUpdatedProps"]
|
|
53
|
-
|
|
55
|
+
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewsWithUpdatedProps"]
|
|
56
|
+
forKey:@"_shadowViewsWithUpdatedProps"];
|
|
57
|
+
[self setValue:[bridge.uiManager valueForKey:@"_shadowViewsWithUpdatedChildren"]
|
|
58
|
+
forKey:@"_shadowViewsWithUpdatedChildren"];
|
|
54
59
|
[self setValue:[bridge.uiManager valueForKey:@"_pendingUIBlocks"] forKey:@"_pendingUIBlocks"];
|
|
55
60
|
[self setValue:[bridge.uiManager valueForKey:@"_rootViewTags"] forKey:@"_rootViewTags"];
|
|
56
61
|
[self setValue:[bridge.uiManager valueForKey:@"_observerCoordinator"] forKey:@"_observerCoordinator"];
|
|
@@ -68,25 +73,39 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
68
73
|
removeAtIndices:(NSArray<NSNumber *> *)removeAtIndices
|
|
69
74
|
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry
|
|
70
75
|
{
|
|
76
|
+
if (!reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
77
|
+
[super _manageChildren:containerTag
|
|
78
|
+
moveFromIndices:moveFromIndices
|
|
79
|
+
moveToIndices:moveToIndices
|
|
80
|
+
addChildReactTags:addChildReactTags
|
|
81
|
+
addAtIndices:addAtIndices
|
|
82
|
+
removeAtIndices:removeAtIndices
|
|
83
|
+
registry:registry];
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Reanimated changes /start
|
|
71
88
|
BOOL isUIViewRegistry = ((id)registry == (id)[self valueForKey:@"_viewRegistry"]);
|
|
72
89
|
id<RCTComponent> container;
|
|
73
|
-
|
|
74
|
-
if(isUIViewRegistry) {
|
|
90
|
+
NSMutableArray<id<RCTComponent>> *permanentlyRemovedChildren;
|
|
91
|
+
if (isUIViewRegistry) {
|
|
75
92
|
container = registry[containerTag];
|
|
76
|
-
for(id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
93
|
+
for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
77
94
|
[container removeReactSubview:toRemoveChild];
|
|
78
95
|
}
|
|
79
96
|
|
|
80
|
-
permanentlyRemovedChildren = [super _childrenToRemoveFromContainer:container
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
permanentlyRemovedChildren = (NSMutableArray *)[super _childrenToRemoveFromContainer:container
|
|
98
|
+
atIndices:removeAtIndices];
|
|
99
|
+
if (permanentlyRemovedChildren != nil) {
|
|
100
|
+
for (id<RCTComponent> permanentlyRemovedChild in permanentlyRemovedChildren) {
|
|
101
|
+
if (_toBeRemovedRegister[containerTag] == nil) {
|
|
84
102
|
_toBeRemovedRegister[containerTag] = [[NSMutableSet<id<RCTComponent>> alloc] init];
|
|
85
103
|
}
|
|
86
104
|
[_toBeRemovedRegister[containerTag] addObject:permanentlyRemovedChild];
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
}
|
|
108
|
+
// Reanimated changes /end
|
|
90
109
|
|
|
91
110
|
[super _manageChildren:containerTag
|
|
92
111
|
moveFromIndices:moveFromIndices
|
|
@@ -96,30 +115,44 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
96
115
|
removeAtIndices:removeAtIndices
|
|
97
116
|
registry:registry];
|
|
98
117
|
|
|
99
|
-
|
|
118
|
+
// Reanimated changes /start
|
|
119
|
+
if (isUIViewRegistry) {
|
|
100
120
|
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
101
|
-
for(id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
121
|
+
for (id<RCTComponent> toRemoveChild in _toBeRemovedRegister[containerTag]) {
|
|
102
122
|
NSInteger lastIndex = [container reactSubviews].count - 1;
|
|
103
|
-
if(lastIndex < 0) {
|
|
123
|
+
if (lastIndex < 0) {
|
|
104
124
|
lastIndex = 0;
|
|
105
125
|
}
|
|
106
|
-
[
|
|
107
|
-
|
|
126
|
+
if ([toRemoveChild isKindOfClass:[RCTModalHostView class]]
|
|
127
|
+
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
128
|
+
|| ([toRemoveChild isKindOfClass:[RNSScreenView class]])
|
|
129
|
+
#endif
|
|
130
|
+
) {
|
|
131
|
+
// we don't want layout animations when removing modals or Screens of native-stack since it brings buggy
|
|
132
|
+
// behavior
|
|
133
|
+
[_toBeRemovedRegister[container.reactTag] removeObject:toRemoveChild];
|
|
134
|
+
[permanentlyRemovedChildren removeObject:toRemoveChild];
|
|
135
|
+
|
|
136
|
+
} else {
|
|
137
|
+
[container insertReactSubview:toRemoveChild atIndex:lastIndex];
|
|
138
|
+
viewRegistry[toRemoveChild.reactTag] = toRemoveChild;
|
|
139
|
+
}
|
|
108
140
|
}
|
|
109
141
|
|
|
110
142
|
for (UIView *removedChild in permanentlyRemovedChildren) {
|
|
111
|
-
[self callAnimationForTree:
|
|
143
|
+
[self callAnimationForTree:removedChild parentTag:containerTag];
|
|
112
144
|
}
|
|
113
145
|
}
|
|
146
|
+
// Reanimated changes /end
|
|
114
147
|
}
|
|
115
148
|
|
|
116
|
-
- (void)
|
|
149
|
+
- (void)callAnimationForTree:(UIView *)view parentTag:(NSNumber *)parentTag
|
|
117
150
|
{
|
|
118
|
-
REASnapshot*
|
|
151
|
+
REASnapshot *snapshot = [[REASnapshot alloc] init:view];
|
|
119
152
|
_parentMapper[view.reactTag] = parentTag;
|
|
120
153
|
[_animationsManager onViewRemoval:view before:snapshot];
|
|
121
154
|
|
|
122
|
-
for(UIView*
|
|
155
|
+
for (UIView *subView in view.reactSubviews) {
|
|
123
156
|
[self callAnimationForTree:subView parentTag:view.reactTag];
|
|
124
157
|
}
|
|
125
158
|
}
|
|
@@ -153,11 +186,12 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
153
186
|
for (RCTShadowView *shadowView in affectedShadowViews) {
|
|
154
187
|
reactTags[index] = shadowView.reactTag;
|
|
155
188
|
RCTLayoutMetrics layoutMetrics = shadowView.layoutMetrics;
|
|
156
|
-
frameDataArray[index++] = (RCTFrameData){
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
189
|
+
frameDataArray[index++] = (RCTFrameData){
|
|
190
|
+
layoutMetrics.frame,
|
|
191
|
+
layoutMetrics.layoutDirection,
|
|
192
|
+
shadowView.isNewView,
|
|
193
|
+
shadowView.superview.isNewView,
|
|
194
|
+
layoutMetrics.displayType};
|
|
161
195
|
}
|
|
162
196
|
}
|
|
163
197
|
|
|
@@ -183,7 +217,7 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
183
217
|
CGSize contentSize = shadowView.layoutMetrics.frame.size;
|
|
184
218
|
|
|
185
219
|
RCTExecuteOnMainQueue(^{
|
|
186
|
-
NSMutableDictionary<NSNumber *, UIView
|
|
220
|
+
NSMutableDictionary<NSNumber *, UIView *> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
187
221
|
UIView *view = viewRegistry[reactTag];
|
|
188
222
|
RCTAssert(view != nil, @"view (for ID %@) not found", reactTag);
|
|
189
223
|
|
|
@@ -236,7 +270,13 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
236
270
|
view.hidden = isHidden;
|
|
237
271
|
}
|
|
238
272
|
|
|
239
|
-
|
|
273
|
+
// Reanimated changes /start
|
|
274
|
+
REASnapshot *snapshotBefore;
|
|
275
|
+
if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
276
|
+
snapshotBefore = [[REASnapshot alloc] init:view];
|
|
277
|
+
}
|
|
278
|
+
// Reanimated changes /end
|
|
279
|
+
|
|
240
280
|
if (creatingLayoutAnimation) {
|
|
241
281
|
// Animate view creation
|
|
242
282
|
[view reactSetFrame:frame];
|
|
@@ -282,55 +322,61 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
282
322
|
completion(YES);
|
|
283
323
|
}
|
|
284
324
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
325
|
+
// Reanimated changes /start
|
|
326
|
+
if (reanimated::FeaturesConfig::isLayoutAnimationEnabled()) {
|
|
327
|
+
if (isNew) {
|
|
328
|
+
REASnapshot *snapshot = [[REASnapshot alloc] init:view];
|
|
329
|
+
[_animationsManager onViewCreate:view after:snapshot];
|
|
330
|
+
} else {
|
|
331
|
+
REASnapshot *snapshotAfter = [[REASnapshot alloc] init:view];
|
|
332
|
+
[_animationsManager onViewUpdate:view before:snapshotBefore after:snapshotAfter];
|
|
333
|
+
}
|
|
292
334
|
}
|
|
293
|
-
|
|
294
335
|
}
|
|
295
336
|
|
|
296
337
|
[_animationsManager removeLeftovers];
|
|
297
338
|
// Clean up
|
|
339
|
+
// uiManager->_layoutAnimationGroup = nil;
|
|
298
340
|
[uiManager setValue:nil forKey:@"_layoutAnimationGroup"];
|
|
341
|
+
// Reanimated changes /end
|
|
299
342
|
};
|
|
300
343
|
}
|
|
301
344
|
|
|
302
345
|
- (Class)class
|
|
303
346
|
{
|
|
304
|
-
|
|
347
|
+
return [RCTUIManager class];
|
|
305
348
|
}
|
|
306
349
|
|
|
307
350
|
+ (Class)class
|
|
308
351
|
{
|
|
309
|
-
|
|
352
|
+
return [RCTUIManager class];
|
|
310
353
|
}
|
|
311
354
|
|
|
312
|
-
- (void)setUp:(REAAnimationsManager*)
|
|
355
|
+
- (void)setUp:(REAAnimationsManager *)animationsManager
|
|
313
356
|
{
|
|
314
357
|
_animationsManager = animationsManager;
|
|
315
|
-
_toBeRemovedRegister = [[NSMutableDictionary<NSNumber*, NSMutableSet<id<RCTComponent
|
|
316
|
-
_parentMapper = [[NSMutableDictionary<NSNumber*, NSNumber*> alloc] init];
|
|
358
|
+
_toBeRemovedRegister = [[NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> alloc] init];
|
|
359
|
+
_parentMapper = [[NSMutableDictionary<NSNumber *, NSNumber *> alloc] init];
|
|
317
360
|
}
|
|
318
361
|
|
|
319
|
-
- (void)unregisterView:(id<RCTComponent>)
|
|
362
|
+
- (void)unregisterView:(id<RCTComponent>)view
|
|
320
363
|
{
|
|
321
|
-
NSNumber*
|
|
322
|
-
if(tag == nil) {
|
|
364
|
+
NSNumber *tag = _parentMapper[view.reactTag];
|
|
365
|
+
if (tag == nil) {
|
|
323
366
|
return;
|
|
324
367
|
}
|
|
325
368
|
|
|
326
369
|
[_toBeRemovedRegister[tag] removeObject:view];
|
|
327
|
-
if(_toBeRemovedRegister[tag].count == 0) {
|
|
370
|
+
if (_toBeRemovedRegister[tag].count == 0) {
|
|
328
371
|
[_toBeRemovedRegister removeObjectForKey:tag];
|
|
329
372
|
}
|
|
330
373
|
NSMutableDictionary<NSNumber *, id<RCTComponent>> *viewRegistry = [self valueForKey:@"_viewRegistry"];
|
|
331
374
|
[view.reactSuperview removeReactSubview:view];
|
|
332
375
|
id<RCTComponent> parentView = viewRegistry[tag];
|
|
333
|
-
|
|
376
|
+
@try {
|
|
377
|
+
[parentView removeReactSubview:view];
|
|
378
|
+
} @catch (id anException) {
|
|
379
|
+
}
|
|
334
380
|
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
335
381
|
if ([view isKindOfClass:[RNSScreenView class]]) {
|
|
336
382
|
[parentView didUpdateReactSubviews];
|
|
@@ -339,10 +385,4 @@ std::weak_ptr<reanimated::Scheduler> _scheduler;
|
|
|
339
385
|
[viewRegistry removeObjectForKey:view.reactTag];
|
|
340
386
|
}
|
|
341
387
|
|
|
342
|
-
- (void)batchDidComplete
|
|
343
|
-
{
|
|
344
|
-
self.flushUiOperations();
|
|
345
|
-
[super batchDidComplete];
|
|
346
|
-
}
|
|
347
|
-
|
|
348
388
|
@end
|
package/ios/Nodes/REAPropsNode.m
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
#import "REANodesManager.h"
|
|
5
5
|
#import "REAStyleNode.h"
|
|
6
6
|
|
|
7
|
+
#import <React/RCTComponentData.h>
|
|
7
8
|
#import <React/RCTLog.h>
|
|
8
9
|
#import <React/RCTUIManager.h>
|
|
9
|
-
#import "React/RCTComponentData.h"
|
|
10
10
|
|
|
11
11
|
@implementation REAPropsNode {
|
|
12
12
|
NSNumber *_connectedViewTag;
|
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
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#import "NativeMethods.h"
|
|
2
|
-
#import <React/RCTScrollView.h>
|
|
3
2
|
#import <React/RCTEventDispatcher.h>
|
|
3
|
+
#import <React/RCTScrollView.h>
|
|
4
4
|
|
|
5
5
|
namespace reanimated {
|
|
6
6
|
|
|
7
|
-
std::vector<std::pair<std::string,double>> measure(int viewTag, RCTUIManager *uiManager)
|
|
7
|
+
std::vector<std::pair<std::string, double>> measure(int viewTag, RCTUIManager *uiManager)
|
|
8
|
+
{
|
|
8
9
|
UIView *view = [uiManager viewForReactTag:@(viewTag)];
|
|
9
10
|
|
|
10
11
|
UIView *rootView = view;
|
|
@@ -17,7 +18,7 @@ std::vector<std::pair<std::string,double>> measure(int viewTag, RCTUIManager *ui
|
|
|
17
18
|
rootView = rootView.superview;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
if (rootView == nil
|
|
21
|
+
if (rootView == nil) {
|
|
21
22
|
return std::vector<std::pair<std::string, double>>(1, std::make_pair("x", -1234567.0));
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -36,11 +37,18 @@ std::vector<std::pair<std::string,double>> measure(int viewTag, RCTUIManager *ui
|
|
|
36
37
|
return result;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
void scrollTo(int scrollViewTag, RCTUIManager *uiManager, double x, double y, bool animated)
|
|
41
|
+
{
|
|
41
42
|
UIView *view = [uiManager viewForReactTag:@(scrollViewTag)];
|
|
42
|
-
RCTScrollView *scrollView = (RCTScrollView *)
|
|
43
|
+
RCTScrollView *scrollView = (RCTScrollView *)view;
|
|
43
44
|
[scrollView scrollToOffset:(CGPoint){(CGFloat)x, (CGFloat)y} animated:animated];
|
|
44
45
|
}
|
|
45
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
|
+
|
|
46
54
|
}
|