react-native-reanimated 2.3.0-alpha.1 → 2.3.0-beta.2
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 +15 -8
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +170 -166
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +36 -34
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +13 -6
- package/Common/cpp/Registries/MapperRegistry.cpp +19 -15
- package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
- package/Common/cpp/SharedItems/FrozenObject.cpp +19 -8
- package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
- package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
- package/Common/cpp/SharedItems/ShareableValue.cpp +216 -143
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +36 -24
- package/Common/cpp/Tools/Mapper.cpp +41 -29
- package/Common/cpp/Tools/RuntimeDecorator.cpp +103 -84
- package/Common/cpp/Tools/Scheduler.cpp +14 -6
- package/Common/cpp/Tools/WorkletEventHandler.cpp +1 -1
- package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +45 -34
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +28 -16
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +14 -8
- package/Common/cpp/headers/Registries/MapperRegistry.h +4 -4
- package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
- package/Common/cpp/headers/SharedItems/FrozenObject.h +15 -11
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +6 -4
- package/Common/cpp/headers/SharedItems/MutableValue.h +21 -12
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +10 -7
- package/Common/cpp/headers/SharedItems/RemoteObject.h +16 -8
- package/Common/cpp/headers/SharedItems/RuntimeManager.h +39 -21
- package/Common/cpp/headers/SharedItems/ShareableValue.h +31 -27
- package/Common/cpp/headers/SharedItems/SharedParent.h +7 -4
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +80 -61
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +17 -19
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +18 -13
- package/Common/cpp/headers/Tools/Mapper.h +24 -18
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +12 -7
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -7
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +29 -23
- package/Common/cpp/headers/Tools/Scheduler.h +28 -33
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +9 -7
- package/Common/cpp/hidden_headers/Logger.h +14 -14
- package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
- package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
- package/README.md +1 -1
- package/RNReanimated.podspec +4 -4
- package/android/build.gradle +80 -3
- 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/ios/LayoutReanimation/REAAnimationsManager.h +19 -10
- package/ios/LayoutReanimation/REAAnimationsManager.m +195 -200
- package/ios/LayoutReanimation/REASnapshot.h +13 -0
- package/ios/LayoutReanimation/REASnapshot.m +29 -0
- package/ios/LayoutReanimation/REAUIManager.h +16 -0
- package/ios/LayoutReanimation/REAUIManager.mm +348 -0
- package/ios/Nodes/REAAlwaysNode.m +14 -15
- package/ios/Nodes/REABezierNode.m +8 -7
- package/ios/Nodes/REABlockNode.m +1 -1
- package/ios/Nodes/REACallFuncNode.h +0 -1
- package/ios/Nodes/REACallFuncNode.m +10 -8
- package/ios/Nodes/REAClockNodes.m +22 -20
- package/ios/Nodes/REAConcatNode.h +0 -1
- package/ios/Nodes/REAConcatNode.m +2 -2
- package/ios/Nodes/REACondNode.m +7 -5
- package/ios/Nodes/READebugNode.m +5 -4
- package/ios/Nodes/REAEventNode.m +1 -1
- package/ios/Nodes/REAFunctionNode.h +0 -1
- package/ios/Nodes/REAFunctionNode.m +2 -2
- package/ios/Nodes/REAJSCallNode.m +4 -5
- package/ios/Nodes/REANode.h +3 -4
- package/ios/Nodes/REANode.m +9 -11
- package/ios/Nodes/REAOperatorNode.m +68 -67
- package/ios/Nodes/REAParamNode.h +1 -3
- package/ios/Nodes/REAParamNode.m +15 -17
- package/ios/Nodes/REAPropsNode.h +1 -3
- package/ios/Nodes/REAPropsNode.m +19 -22
- package/ios/Nodes/REASetNode.h +0 -1
- package/ios/Nodes/REASetNode.m +7 -5
- package/ios/Nodes/REAStyleNode.h +0 -1
- package/ios/Nodes/REAStyleNode.m +2 -4
- package/ios/Nodes/REATransformNode.h +0 -1
- package/ios/Nodes/REATransformNode.m +3 -5
- package/ios/Nodes/REAValueNode.m +5 -7
- package/ios/REAEventDispatcher.m +3 -3
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +29 -40
- package/ios/REANodesManager.h +11 -19
- package/ios/REANodesManager.m +105 -130
- package/ios/REAUtils.h +5 -3
- package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
- package/ios/Transitioning/REAAllTransitions.h +2 -2
- package/ios/Transitioning/REAAllTransitions.m +14 -25
- package/ios/Transitioning/REATransition.h +8 -7
- package/ios/Transitioning/REATransition.m +19 -16
- package/ios/Transitioning/REATransitionAnimation.h +1 -1
- package/ios/Transitioning/REATransitionAnimation.m +2 -3
- package/ios/Transitioning/REATransitionManager.m +3 -3
- package/ios/native/NativeMethods.h +15 -5
- package/ios/native/NativeProxy.h +4 -3
- package/ios/native/NativeProxy.mm +19 -5
- package/ios/native/REAIOSErrorHandler.h +13 -10
- package/ios/native/REAIOSLogger.h +8 -8
- package/ios/native/REAIOSScheduler.h +5 -5
- package/ios/native/REAIOSScheduler.mm +7 -5
- package/ios/native/REAInitializer.h +37 -0
- package/ios/native/REAInitializer.mm +63 -0
- package/ios/native/UIResponder+Reanimated.mm +9 -48
- package/lib/ConfigHelper.js +1 -0
- package/lib/ReanimatedModule.native.js +10 -2
- package/lib/createAnimatedComponent.js +64 -30
- package/lib/reanimated1/core/AnimatedAlways.js +1 -1
- package/lib/reanimated1/core/AnimatedBezier.js +1 -1
- package/lib/reanimated1/core/AnimatedBlock.js +1 -1
- package/lib/reanimated1/core/AnimatedCall.js +1 -1
- package/lib/reanimated1/core/AnimatedCallFunc.js +1 -1
- package/lib/reanimated1/core/AnimatedConcat.js +1 -1
- package/lib/reanimated1/core/AnimatedCond.js +1 -1
- package/lib/reanimated1/core/AnimatedDebug.js +1 -1
- package/lib/reanimated1/core/AnimatedEvent.js +1 -1
- package/lib/reanimated1/core/AnimatedFunction.js +1 -1
- package/lib/reanimated1/core/AnimatedOperator.js +1 -1
- package/lib/reanimated1/core/AnimatedParam.js +1 -1
- package/lib/reanimated1/core/AnimatedProps.js +2 -2
- package/lib/reanimated1/core/AnimatedSet.js +1 -1
- package/lib/reanimated1/core/AnimatedStartClock.js +1 -1
- package/lib/reanimated1/core/AnimatedStopClock.js +1 -1
- package/lib/reanimated1/core/AnimatedStyle.js +1 -1
- package/lib/reanimated1/core/AnimatedTransform.js +1 -1
- package/lib/reanimated1/core/Core.test.js +30 -0
- package/lib/reanimated1/core/InternalAnimatedValue.js +1 -1
- package/lib/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
- package/lib/reanimated1/derived/interpolate.js +1 -1
- package/lib/reanimated2/Colors.js +16 -12
- package/lib/reanimated2/NativeMethods.js +3 -14
- package/lib/reanimated2/{NativeReanimated.native.js → NativeReanimated/NativeReanimated.js} +19 -24
- package/lib/reanimated2/NativeReanimated/index.js +15 -0
- package/lib/reanimated2/PlatformChecker.js +16 -0
- package/lib/reanimated2/PropAdapters.js +14 -4
- package/lib/reanimated2/UpdateProps.js +14 -11
- package/lib/reanimated2/ViewDescriptorsSet.js +73 -0
- package/lib/reanimated2/WorkletEventHandler.js +15 -13
- package/lib/reanimated2/animation/commonTypes.js +1 -0
- package/lib/reanimated2/animation/decay.js +71 -0
- package/lib/reanimated2/animation/delay.js +64 -0
- package/lib/reanimated2/animation/index.js +8 -0
- package/lib/reanimated2/animation/repeat.js +69 -0
- package/lib/reanimated2/animation/sequence.js +72 -0
- package/lib/reanimated2/animation/spring.js +101 -0
- package/lib/reanimated2/animation/styleAnimation.js +166 -0
- package/lib/reanimated2/animation/timing.js +64 -0
- package/lib/reanimated2/animation/util.js +157 -0
- package/lib/reanimated2/commonTypes.js +1 -0
- package/lib/reanimated2/core.js +35 -39
- package/lib/reanimated2/globals.d.ts +47 -1
- package/lib/reanimated2/hook/Hooks.js +9 -0
- package/lib/reanimated2/hook/commonTypes.js +1 -0
- package/lib/reanimated2/hook/index.js +8 -0
- package/lib/reanimated2/hook/useAnimatedGestureHandler.js +50 -0
- package/lib/reanimated2/hook/useAnimatedReaction.js +37 -0
- package/lib/reanimated2/hook/useAnimatedRef.js +25 -0
- package/lib/reanimated2/hook/useAnimatedScrollHandler.js +41 -0
- package/lib/reanimated2/hook/useAnimatedStyle.js +376 -0
- package/lib/reanimated2/hook/useDerivedValue.js +36 -0
- package/lib/reanimated2/hook/useSharedValue.js +17 -0
- package/lib/reanimated2/hook/utils.js +175 -0
- package/lib/reanimated2/index.js +3 -2
- package/lib/reanimated2/interpolation.js +95 -86
- package/lib/reanimated2/jestUtils.js +0 -12
- package/lib/reanimated2/js-reanimated/JSReanimated.js +9 -10
- package/lib/reanimated2/js-reanimated/index.js +57 -1
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +58 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +69 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +193 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +3 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +325 -207
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +235 -187
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +327 -269
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +146 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +85 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +119 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +289 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +159 -121
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +83 -65
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +371 -277
- package/lib/reanimated2/layoutReanimation/defaultAnimations/index.js +4 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
- package/lib/reanimated2/layoutReanimation/index.js +3 -2
- package/lib/reanimated2/platform-specific/RNRenderer.web.js +2 -0
- package/lib/reanimated2/utils.js +9 -0
- package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
- package/package.json +21 -10
- package/plugin.js +244 -85
- package/react-native-reanimated.d.ts +531 -453
- package/src/ConfigHelper.js +1 -0
- package/src/ReanimatedModule.native.js +10 -2
- package/src/createAnimatedComponent.js +64 -30
- package/src/reanimated1/core/AnimatedAlways.js +1 -1
- package/src/reanimated1/core/AnimatedBezier.js +1 -1
- package/src/reanimated1/core/AnimatedBlock.js +1 -1
- package/src/reanimated1/core/AnimatedCall.js +1 -1
- package/src/reanimated1/core/AnimatedCallFunc.js +1 -1
- package/src/reanimated1/core/AnimatedConcat.js +1 -1
- package/src/reanimated1/core/AnimatedCond.js +1 -1
- package/src/reanimated1/core/AnimatedDebug.js +1 -1
- package/src/reanimated1/core/AnimatedEvent.js +1 -1
- package/src/reanimated1/core/AnimatedFunction.js +1 -1
- package/src/reanimated1/core/AnimatedOperator.js +1 -1
- package/src/reanimated1/core/AnimatedParam.js +1 -1
- package/src/reanimated1/core/AnimatedProps.js +2 -2
- package/src/reanimated1/core/AnimatedSet.js +1 -1
- package/src/reanimated1/core/AnimatedStartClock.js +1 -1
- package/src/reanimated1/core/AnimatedStopClock.js +1 -1
- package/src/reanimated1/core/AnimatedStyle.js +1 -1
- package/src/reanimated1/core/AnimatedTransform.js +1 -1
- package/src/reanimated1/core/Core.test.js +30 -0
- package/src/reanimated1/core/InternalAnimatedValue.js +1 -1
- package/src/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
- package/src/reanimated1/derived/interpolate.js +1 -1
- package/src/reanimated2/Colors.ts +30 -27
- package/src/reanimated2/Easing.ts +3 -1
- package/src/reanimated2/NativeMethods.ts +26 -16
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +78 -0
- package/src/reanimated2/NativeReanimated/index.ts +18 -0
- package/src/reanimated2/PlatformChecker.ts +21 -0
- package/src/reanimated2/PropAdapters.ts +52 -34
- package/src/reanimated2/UpdateProps.ts +40 -20
- package/src/reanimated2/ViewDescriptorsSet.ts +108 -0
- package/src/reanimated2/WorkletEventHandler.ts +41 -23
- package/src/reanimated2/animation/commonTypes.ts +48 -0
- package/src/reanimated2/animation/decay.ts +141 -0
- package/src/reanimated2/animation/delay.ts +103 -0
- package/src/reanimated2/animation/index.ts +16 -0
- package/src/reanimated2/animation/repeat.ts +128 -0
- package/src/reanimated2/animation/sequence.ts +110 -0
- package/src/reanimated2/animation/spring.ts +165 -0
- package/src/reanimated2/animation/styleAnimation.ts +253 -0
- package/src/reanimated2/animation/timing.ts +109 -0
- package/src/reanimated2/animation/util.ts +242 -0
- package/src/reanimated2/commonTypes.ts +81 -0
- package/src/reanimated2/core.ts +128 -82
- package/src/reanimated2/globals.d.ts +47 -1
- package/src/reanimated2/hook/Hooks.ts +16 -0
- package/src/reanimated2/hook/commonTypes.ts +12 -0
- package/src/reanimated2/hook/index.ts +25 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +110 -0
- package/src/reanimated2/hook/useAnimatedReaction.ts +49 -0
- package/src/reanimated2/hook/useAnimatedRef.ts +34 -0
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +83 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +538 -0
- package/src/reanimated2/hook/useDerivedValue.ts +48 -0
- package/src/reanimated2/hook/useSharedValue.ts +22 -0
- package/src/reanimated2/hook/utils.ts +259 -0
- package/src/reanimated2/index.ts +3 -2
- package/src/reanimated2/interpolation.ts +170 -101
- package/src/reanimated2/jestUtils.ts +0 -12
- package/src/reanimated2/js-reanimated/JSReanimated.ts +47 -22
- package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
- package/src/reanimated2/js-reanimated/index.ts +71 -0
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +62 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +91 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +263 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +78 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +16 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +243 -121
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +43 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +95 -53
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +114 -64
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +179 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +93 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +132 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +333 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +84 -50
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +41 -23
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +234 -154
- package/src/reanimated2/layoutReanimation/defaultAnimations/index.ts +4 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
- package/src/reanimated2/layoutReanimation/index.ts +3 -2
- package/src/reanimated2/platform-specific/RNRenderer.web.ts +2 -0
- package/src/reanimated2/utils.ts +21 -0
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
- package/ios/LayoutReanimation/REAAnimationRootView.h +0 -12
- package/ios/LayoutReanimation/REAAnimationRootView.m +0 -16
- package/ios/LayoutReanimation/REAAnimationRootViewManager.h +0 -9
- package/ios/LayoutReanimation/REAAnimationRootViewManager.m +0 -49
- package/ios/LayoutReanimation/REAReactBatchObserver.h +0 -20
- package/ios/LayoutReanimation/REAReactBatchObserver.m +0 -125
- package/ios/LayoutReanimation/REASnapshooter.h +0 -19
- package/ios/LayoutReanimation/REASnapshooter.m +0 -64
- package/ios/LayoutReanimation/REAViewTraverser.h +0 -13
- package/ios/LayoutReanimation/REAViewTraverser.m +0 -40
- package/lib/reanimated2/Hooks.js +0 -732
- package/lib/reanimated2/NativeReanimated.js +0 -4
- package/lib/reanimated2/animations.js +0 -713
- package/lib/reanimated2/js-reanimated/index.web.js +0 -20
- package/lib/reanimated2/layoutReanimation/AnimatedRoot.js +0 -55
- package/lib/reanimated2/layoutReanimation/defaultAnimationsBuilder.js +0 -374
- package/src/reanimated2/Hooks.ts +0 -918
- package/src/reanimated2/NativeReanimated.native.ts +0 -61
- package/src/reanimated2/NativeReanimated.ts +0 -5
- package/src/reanimated2/animations.ts +0 -868
- package/src/reanimated2/js-reanimated/index.js +0 -0
- package/src/reanimated2/js-reanimated/index.web.ts +0 -29
- package/src/reanimated2/layoutReanimation/AnimatedRoot.tsx +0 -68
- package/src/reanimated2/layoutReanimation/defaultAnimationsBuilder.ts +0 -440
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
#import "REAAnimationsManager.h"
|
|
2
2
|
#import <React/RCTComponentData.h>
|
|
3
|
-
#import
|
|
4
|
-
#import <React/UIView+React.h>
|
|
3
|
+
#import <React/RCTTextView.h>
|
|
5
4
|
#import <React/UIView+Private.h>
|
|
6
|
-
#import
|
|
5
|
+
#import <React/UIView+React.h>
|
|
6
|
+
#import "REAUIManager.h"
|
|
7
7
|
|
|
8
8
|
@interface REAAnimationsManager ()
|
|
9
9
|
|
|
10
|
-
@property (atomic, nullable) void(^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber*);
|
|
11
|
-
@property (atomic, nullable) void(^removeConfigForTag)(NSNumber *);
|
|
10
|
+
@property (atomic, nullable) void (^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber *);
|
|
11
|
+
@property (atomic, nullable) void (^removeConfigForTag)(NSNumber *);
|
|
12
12
|
|
|
13
|
-
- (void)removeLeftovers
|
|
13
|
+
- (void)removeLeftovers;
|
|
14
14
|
- (void)scheduleCleaning;
|
|
15
15
|
|
|
16
16
|
@end
|
|
17
17
|
|
|
18
|
-
typedef NS_ENUM(NSInteger, ViewState) {
|
|
19
|
-
Appearing,
|
|
20
|
-
Disappearing,
|
|
21
|
-
Layout,
|
|
22
|
-
Inactive,
|
|
23
|
-
ToRemove,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
18
|
@implementation REAAnimationsManager {
|
|
27
|
-
RCTUIManager*
|
|
28
|
-
|
|
29
|
-
NSMutableDictionary<NSNumber*,
|
|
30
|
-
NSMutableDictionary<NSNumber*,
|
|
31
|
-
NSMutableSet<NSNumber
|
|
32
|
-
|
|
19
|
+
RCTUIManager *_uiManager;
|
|
20
|
+
REAUIManager *_reaUiManager;
|
|
21
|
+
NSMutableDictionary<NSNumber *, NSNumber *> *_states;
|
|
22
|
+
NSMutableDictionary<NSNumber *, UIView *> *_viewForTag;
|
|
23
|
+
NSMutableSet<NSNumber *> *_toRemove;
|
|
24
|
+
BOOL _cleaningScheduled;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+ (NSArray *)layoutKeys
|
|
28
|
+
{
|
|
29
|
+
static NSArray *_array;
|
|
30
|
+
static dispatch_once_t onceToken;
|
|
31
|
+
dispatch_once(&onceToken, ^{
|
|
32
|
+
_array = @[ @"originX", @"originY", @"width", @"height" ];
|
|
33
|
+
});
|
|
34
|
+
return _array;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
- (instancetype)initWithUIManager:(RCTUIManager *)uiManager
|
|
36
38
|
{
|
|
37
39
|
if (self = [super init]) {
|
|
38
40
|
_uiManager = uiManager;
|
|
41
|
+
_reaUiManager = (REAUIManager *)uiManager;
|
|
39
42
|
_states = [NSMutableDictionary new];
|
|
40
43
|
_viewForTag = [NSMutableDictionary new];
|
|
41
|
-
_animatedLayout = [NSMutableDictionary new];
|
|
42
44
|
_toRemove = [NSMutableSet new];
|
|
43
|
-
|
|
45
|
+
_cleaningScheduled = false;
|
|
44
46
|
}
|
|
45
47
|
return self;
|
|
46
48
|
}
|
|
@@ -51,255 +53,248 @@ typedef NS_ENUM(NSInteger, ViewState) {
|
|
|
51
53
|
_removeConfigForTag = nil;
|
|
52
54
|
_uiManager = nil;
|
|
53
55
|
_states = nil;
|
|
54
|
-
_animatedLayout = nil;
|
|
55
56
|
_viewForTag = nil;
|
|
56
57
|
_toRemove = nil;
|
|
57
|
-
|
|
58
|
+
_cleaningScheduled = false;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
- (void)
|
|
61
|
+
- (void)setAnimationStartingBlock:
|
|
62
|
+
(void (^)(NSNumber *tag, NSString *type, NSDictionary *yogaValues, NSNumber *depth))startAnimation
|
|
61
63
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
for (UIView * view in allViews) {
|
|
69
|
-
if (_states[view.reactTag] == nil) {
|
|
70
|
-
_states[view.reactTag] = [NSNumber numberWithInt:Inactive];
|
|
71
|
-
}
|
|
72
|
-
_viewForTag[view.reactTag] = view;
|
|
73
|
-
_animatedLayout[view.reactTag] = before.tag;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// attach all orphan views
|
|
77
|
-
for (UIView * view in allViews) {
|
|
78
|
-
if (view.superview != nil) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if ([view isKindOfClass:[REAAnimationRootView class]]) {
|
|
82
|
-
NSArray<UIView *> *pathToTheRoot = (NSArray<UIView *>*)before.capturedValues[[REASnapshooter idFor:view]][@"pathToWindow"];
|
|
83
|
-
for (int i = 1; i < [pathToTheRoot count]; ++i) {
|
|
84
|
-
UIView * current = pathToTheRoot[i-1];
|
|
85
|
-
UIView * parent = pathToTheRoot[i];
|
|
86
|
-
if (current.superview == nil) {
|
|
87
|
-
[parent addSubview:current];
|
|
88
|
-
_animatedLayoutHangingPoint[view.reactTag] = parent;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
UIView * parent = (UIView*) before.capturedValues[[REASnapshooter idFor:view]][@"parent"];
|
|
93
|
-
[parent addSubview:view];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
for (UIView * view in allViews) {
|
|
98
|
-
int tag = [view.reactTag intValue];
|
|
99
|
-
NSString * type = @"entering";
|
|
100
|
-
NSMutableDictionary * startValues = before.capturedValues[[REASnapshooter idFor:view]];
|
|
101
|
-
NSMutableDictionary * targetValues = after.capturedValues[[REASnapshooter idFor:view]];
|
|
102
|
-
|
|
103
|
-
ViewState viewState = [_states[view.reactTag] intValue];
|
|
104
|
-
if (viewState == Appearing || viewState == Disappearing || viewState == ToRemove) {
|
|
105
|
-
if (viewState == Appearing && startValues != nil && targetValues == nil) {
|
|
106
|
-
_states[view.reactTag] = [NSNumber numberWithInt: Disappearing];
|
|
107
|
-
type = @"exiting";
|
|
108
|
-
NSDictionary* preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
109
|
-
_startAnimationForTag(view.reactTag, type, preparedValues, @(0)); }
|
|
110
|
-
continue; // Maybe we should update an animation instead of skipping
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (viewState == Inactive) { // it can be a fresh view
|
|
114
|
-
if (startValues == nil && targetValues != nil) {
|
|
115
|
-
NSDictionary* preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
116
|
-
_startAnimationForTag(view.reactTag, type, preparedValues, @(0));
|
|
117
|
-
}
|
|
118
|
-
if (startValues != nil && targetValues == nil) {
|
|
119
|
-
_states[view.reactTag] = [NSNumber numberWithInt:ToRemove];
|
|
120
|
-
}
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
// View must be in Layout State
|
|
124
|
-
type = @"layout";
|
|
125
|
-
if (targetValues == nil && startValues != nil) {
|
|
126
|
-
_states[view.reactTag] = [NSNumber numberWithInt: Disappearing];
|
|
127
|
-
type = @"exiting";
|
|
128
|
-
NSDictionary* preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
129
|
-
_startAnimationForTag(view.reactTag, type, preparedValues, @(0));
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
NSDictionary* preparedStartValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
134
|
-
NSDictionary* preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
135
|
-
NSMutableDictionary * preparedValues = [NSMutableDictionary new];
|
|
136
|
-
[preparedValues addEntriesFromDictionary:preparedTargetValues];
|
|
137
|
-
for (NSString* key in preparedStartValues.allKeys) {
|
|
138
|
-
preparedValues[[NSString stringWithFormat:@"%@%@", @"b", key]] = preparedStartValues[key];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
_startAnimationForTag(view.reactTag, type, preparedValues, @(0));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
[self removeLeftovers: before.tag];
|
|
64
|
+
_startAnimationForTag = startAnimation;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)setRemovingConfigBlock:(void (^)(NSNumber *tag))block
|
|
68
|
+
{
|
|
69
|
+
_removeConfigForTag = block;
|
|
145
70
|
}
|
|
146
71
|
|
|
147
72
|
- (void)scheduleCleaning
|
|
148
73
|
{
|
|
74
|
+
if (_cleaningScheduled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
_cleaningScheduled = true;
|
|
78
|
+
|
|
149
79
|
__weak REAAnimationsManager *weakSelf = self;
|
|
150
80
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
81
|
+
self->_cleaningScheduled = false;
|
|
151
82
|
if (weakSelf == nil) {
|
|
152
83
|
return;
|
|
153
84
|
}
|
|
154
|
-
|
|
155
|
-
_toRemove = [NSMutableSet new];
|
|
156
|
-
|
|
157
|
-
NSMutableSet<NSNumber *>* candidates = [NSMutableSet new];
|
|
158
|
-
for (NSNumber * tag in toRemove) {
|
|
159
|
-
UIView * view = _viewForTag[tag];
|
|
160
|
-
if (view == nil) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
[candidates addObject: _animatedLayout[tag]];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
for (NSNumber * tag in candidates) {
|
|
167
|
-
[self removeLeftovers:tag];
|
|
168
|
-
}
|
|
85
|
+
[self removeLeftovers];
|
|
169
86
|
});
|
|
170
87
|
}
|
|
171
88
|
|
|
172
|
-
- (
|
|
89
|
+
- (void)findRoot:(UIView *)view roots:(NSMutableSet<NSNumber *> *)roots
|
|
173
90
|
{
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
91
|
+
UIView *currentView = view;
|
|
92
|
+
NSNumber *lastToRemoveTag = nil;
|
|
93
|
+
while (currentView != nil) {
|
|
94
|
+
ViewState state = [_states[currentView.reactTag] intValue];
|
|
95
|
+
if (state == Disappearing) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (state == ToRemove) {
|
|
99
|
+
lastToRemoveTag = currentView.reactTag;
|
|
100
|
+
}
|
|
101
|
+
currentView = currentView.superview;
|
|
181
102
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
[REAViewTraverser traverse:view withBlock:^(UIView * _Nonnull current) {
|
|
185
|
-
[_states removeObjectForKey:current.reactTag];
|
|
186
|
-
[_animatedLayout removeObjectForKey:current.reactTag];
|
|
187
|
-
[_viewForTag removeObjectForKey:current.reactTag];
|
|
188
|
-
_removeConfigForTag(current.reactTag);
|
|
189
|
-
if (view.reactTag == current.reactTag) {
|
|
190
|
-
if ([view isKindOfClass:[REAAnimationRootView class]]) {
|
|
191
|
-
UIView * hangingPoint = _animatedLayoutHangingPoint[view.reactTag];
|
|
192
|
-
UIView * tmp = view;
|
|
193
|
-
while (tmp.superview != nil && tmp != hangingPoint) {
|
|
194
|
-
UIView * next = tmp.superview;
|
|
195
|
-
[tmp removeFromSuperview];
|
|
196
|
-
tmp = next;
|
|
197
|
-
}
|
|
198
|
-
[_animatedLayoutHangingPoint removeObjectForKey:view.reactTag];
|
|
199
|
-
} else {
|
|
200
|
-
[view removeFromSuperview];
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
for (UIView * child in view.subviews) {
|
|
204
|
-
[child removeFromSuperview];
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
} shouldSkipAnimationRoots:false depth:(1e9)];
|
|
103
|
+
if (lastToRemoveTag != nil) {
|
|
104
|
+
[roots addObject:lastToRemoveTag];
|
|
208
105
|
}
|
|
209
|
-
|
|
210
|
-
return active || (!(ToRemove == state));
|
|
211
106
|
}
|
|
212
107
|
|
|
213
|
-
- (
|
|
108
|
+
- (BOOL)dfs:(UIView *)root view:(UIView *)view cands:(NSMutableSet<NSNumber *> *)cands
|
|
214
109
|
{
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
return;
|
|
110
|
+
NSNumber *tag = view.reactTag;
|
|
111
|
+
if (tag == nil) {
|
|
112
|
+
return true;
|
|
218
113
|
}
|
|
219
|
-
[
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
114
|
+
if (![cands containsObject:tag] && _states[tag] != nil) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
BOOL cannotStripe = false;
|
|
118
|
+
NSArray<UIView *> *toRemoveCopy = [view.reactSubviews copy];
|
|
119
|
+
for (UIView *child in toRemoveCopy) {
|
|
120
|
+
if (![view isKindOfClass:[RCTTextView class]]) {
|
|
121
|
+
cannotStripe |= [self dfs:root view:child cands:cands];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!cannotStripe) {
|
|
125
|
+
if (view.reactSuperview != nil) {
|
|
126
|
+
[_reaUiManager unregisterView:view];
|
|
127
|
+
}
|
|
128
|
+
[_states removeObjectForKey:tag];
|
|
129
|
+
[_viewForTag removeObjectForKey:tag];
|
|
130
|
+
[_toRemove removeObject:tag];
|
|
131
|
+
}
|
|
132
|
+
return cannotStripe;
|
|
230
133
|
}
|
|
231
134
|
|
|
232
|
-
- (void)
|
|
135
|
+
- (void)removeLeftovers
|
|
233
136
|
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
137
|
+
NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
|
|
138
|
+
for (NSNumber *viewTag in _toRemove) {
|
|
139
|
+
UIView *view = _viewForTag[viewTag];
|
|
140
|
+
[self findRoot:view roots:roots];
|
|
141
|
+
}
|
|
142
|
+
for (NSNumber *viewTag in roots) {
|
|
143
|
+
UIView *view = _viewForTag[viewTag];
|
|
144
|
+
[self dfs:view view:view cands:_toRemove];
|
|
237
145
|
}
|
|
238
|
-
|
|
239
|
-
NSMutableDictionary* dataComponenetsByName = [_uiManager valueForKey:@"_componentDataByName"];
|
|
240
|
-
RCTComponentData *componentData = dataComponenetsByName[@"RCTView"];
|
|
241
|
-
[self setNewProps:[newStyle mutableCopy] forView:_viewForTag[tag] withComponentData:componentData];
|
|
242
146
|
}
|
|
243
147
|
|
|
244
|
-
- (void)notifyAboutEnd:(NSNumber*)tag cancelled:(BOOL)cancelled
|
|
148
|
+
- (void)notifyAboutEnd:(NSNumber *)tag cancelled:(BOOL)cancelled
|
|
245
149
|
{
|
|
246
150
|
if (!cancelled) {
|
|
247
|
-
//Update State
|
|
248
151
|
ViewState state = [_states[tag] intValue];
|
|
249
152
|
if (state == Appearing) {
|
|
250
153
|
_states[tag] = [NSNumber numberWithInt:Layout];
|
|
251
154
|
}
|
|
252
155
|
if (state == Disappearing) {
|
|
253
156
|
_states[tag] = [NSNumber numberWithInt:ToRemove];
|
|
254
|
-
|
|
157
|
+
if (tag != nil) {
|
|
158
|
+
[_toRemove addObject:tag];
|
|
159
|
+
}
|
|
255
160
|
[self scheduleCleaning];
|
|
256
161
|
}
|
|
257
162
|
}
|
|
258
163
|
}
|
|
259
164
|
|
|
260
|
-
- (void)
|
|
165
|
+
- (void)notifyAboutProgress:(NSDictionary *)newStyle tag:(NSNumber *)tag
|
|
166
|
+
{
|
|
167
|
+
if (_states[tag] == nil) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
ViewState state = [_states[tag] intValue];
|
|
171
|
+
if (state == Inactive) {
|
|
172
|
+
_states[tag] = [NSNumber numberWithInt:Appearing];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
NSMutableDictionary *dataComponenetsByName = [_uiManager valueForKey:@"_componentDataByName"];
|
|
176
|
+
RCTComponentData *componentData = dataComponenetsByName[@"RCTView"];
|
|
177
|
+
[self setNewProps:[newStyle mutableCopy] forView:_viewForTag[tag] withComponentData:componentData];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)setNewProps:(NSMutableDictionary *)newProps
|
|
181
|
+
forView:(UIView *)view
|
|
182
|
+
withComponentData:(RCTComponentData *)componentData
|
|
261
183
|
{
|
|
262
184
|
if (newProps[@"height"]) {
|
|
263
185
|
double height = [newProps[@"height"] doubleValue];
|
|
264
186
|
double oldHeight = view.bounds.size.height;
|
|
265
187
|
view.bounds = CGRectMake(0, 0, view.bounds.size.width, height);
|
|
266
|
-
view.center = CGPointMake(view.center.x, view.center.y - oldHeight/2.0 + view.bounds.size.height/2.0);
|
|
188
|
+
view.center = CGPointMake(view.center.x, view.center.y - oldHeight / 2.0 + view.bounds.size.height / 2.0);
|
|
267
189
|
[newProps removeObjectForKey:@"height"];
|
|
268
190
|
}
|
|
269
191
|
if (newProps[@"width"]) {
|
|
270
192
|
double width = [newProps[@"width"] doubleValue];
|
|
271
193
|
double oldWidth = view.bounds.size.width;
|
|
272
194
|
view.bounds = CGRectMake(0, 0, width, view.bounds.size.height);
|
|
273
|
-
view.center = CGPointMake(view.center.x + view.bounds.size.width/2.0 - oldWidth/2.0, view.center.y);
|
|
195
|
+
view.center = CGPointMake(view.center.x + view.bounds.size.width / 2.0 - oldWidth / 2.0, view.center.y);
|
|
274
196
|
[newProps removeObjectForKey:@"width"];
|
|
275
197
|
}
|
|
276
198
|
if (newProps[@"originX"]) {
|
|
277
199
|
double originX = [newProps[@"originX"] doubleValue];
|
|
278
|
-
view.center = CGPointMake(originX + view.bounds.size.width/2.0, view.center.y);
|
|
200
|
+
view.center = CGPointMake(originX + view.bounds.size.width / 2.0, view.center.y);
|
|
279
201
|
[newProps removeObjectForKey:@"originX"];
|
|
280
202
|
}
|
|
281
203
|
if (newProps[@"originY"]) {
|
|
282
204
|
double originY = [newProps[@"originY"] doubleValue];
|
|
283
|
-
view.center = CGPointMake(view.center.x, originY + view.bounds.size.height/2.0);
|
|
205
|
+
view.center = CGPointMake(view.center.x, originY + view.bounds.size.height / 2.0);
|
|
284
206
|
[newProps removeObjectForKey:@"originY"];
|
|
285
207
|
}
|
|
286
208
|
[componentData setProps:newProps forView:view];
|
|
287
209
|
}
|
|
288
210
|
|
|
289
|
-
- (NSDictionary*)
|
|
211
|
+
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
|
|
290
212
|
{
|
|
291
213
|
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
292
|
-
NSDictionary*
|
|
293
|
-
@"width": values[@"width"],
|
|
294
|
-
@"height": values[@"height"],
|
|
295
|
-
@"originX": values[@"originX"],
|
|
296
|
-
@"originY": values[@"originY"],
|
|
297
|
-
@"globalOriginX": values[@"globalOriginX"],
|
|
298
|
-
@"globalOriginY": values[@"globalOriginY"],
|
|
299
|
-
@"windowWidth": [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
300
|
-
@"windowHeight": [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
214
|
+
NSDictionary *preparedData = @{
|
|
215
|
+
@"width" : values[@"width"],
|
|
216
|
+
@"height" : values[@"height"],
|
|
217
|
+
@"originX" : values[@"originX"],
|
|
218
|
+
@"originY" : values[@"originY"],
|
|
219
|
+
@"globalOriginX" : values[@"globalOriginX"],
|
|
220
|
+
@"globalOriginY" : values[@"globalOriginY"],
|
|
221
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
222
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
301
223
|
};
|
|
302
224
|
return preparedData;
|
|
303
225
|
}
|
|
304
226
|
|
|
227
|
+
- (void)onViewRemoval:(UIView *)view before:(REASnapshot *)before
|
|
228
|
+
{
|
|
229
|
+
NSNumber *tag = view.reactTag;
|
|
230
|
+
ViewState state = [_states[tag] intValue];
|
|
231
|
+
if (state == Disappearing || state == ToRemove || tag == nil) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
NSMutableDictionary<NSString *, NSObject *> *startValues = before.values;
|
|
235
|
+
if (state == Inactive) {
|
|
236
|
+
if (startValues != nil) {
|
|
237
|
+
_states[tag] = [NSNumber numberWithInt:ToRemove];
|
|
238
|
+
[_toRemove addObject:tag];
|
|
239
|
+
[self scheduleCleaning];
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
_states[tag] = [NSNumber numberWithInt:Disappearing];
|
|
244
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
245
|
+
_startAnimationForTag(tag, @"exiting", preparedValues, @(0));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
- (void)onViewCreate:(UIView *)view after:(REASnapshot *)after
|
|
249
|
+
{
|
|
250
|
+
NSNumber *tag = view.reactTag;
|
|
251
|
+
if (_states[tag] == nil) {
|
|
252
|
+
_states[tag] = [NSNumber numberWithInt:Inactive];
|
|
253
|
+
_viewForTag[tag] = view;
|
|
254
|
+
}
|
|
255
|
+
NSMutableDictionary *targetValues = after.values;
|
|
256
|
+
ViewState state = [_states[tag] intValue];
|
|
257
|
+
if (state == Inactive) {
|
|
258
|
+
if (targetValues != nil) {
|
|
259
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
260
|
+
_startAnimationForTag(tag, @"entering", preparedValues, @(0));
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
- (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after
|
|
267
|
+
{
|
|
268
|
+
NSNumber *tag = view.reactTag;
|
|
269
|
+
NSMutableDictionary *targetValues = after.values;
|
|
270
|
+
NSMutableDictionary *startValues = before.values;
|
|
271
|
+
if (_states[tag] == nil) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
ViewState state = [_states[tag] intValue];
|
|
275
|
+
if (state == Disappearing || state == ToRemove || state == Inactive) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (state == Appearing) {
|
|
279
|
+
BOOL doNotStartLayout = true;
|
|
280
|
+
for (NSString *key in [[self class] layoutKeys]) {
|
|
281
|
+
if ([((NSNumber *)startValues[key]) doubleValue] != [((NSNumber *)targetValues[key]) doubleValue]) {
|
|
282
|
+
doNotStartLayout = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (doNotStartLayout) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
_states[view.reactTag] = [NSNumber numberWithInt:Layout];
|
|
290
|
+
NSDictionary *preparedStartValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
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
|
+
}
|
|
297
|
+
_startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
|
|
298
|
+
}
|
|
299
|
+
|
|
305
300
|
@end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import "REASnapshot.h"
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@implementation REASnapshot {
|
|
7
|
+
UIView *_view;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
- (instancetype)init:(UIView *)view
|
|
11
|
+
{
|
|
12
|
+
self = [super init];
|
|
13
|
+
_view = view;
|
|
14
|
+
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
15
|
+
CGPoint originFromRootPerspective = [[view superview] convertPoint:view.center toView:windowView];
|
|
16
|
+
_values = [NSMutableDictionary new];
|
|
17
|
+
_values[@"width"] = [NSNumber numberWithDouble:(double)(view.bounds.size.width)];
|
|
18
|
+
_values[@"height"] = [NSNumber numberWithDouble:(double)(view.bounds.size.height)];
|
|
19
|
+
_values[@"originX"] = [NSNumber numberWithDouble:view.center.x - view.bounds.size.width / 2.0];
|
|
20
|
+
_values[@"originY"] = [NSNumber numberWithDouble:view.center.y - view.bounds.size.height / 2.0];
|
|
21
|
+
_values[@"globalOriginX"] = [NSNumber numberWithDouble:originFromRootPerspective.x - view.bounds.size.width / 2.0];
|
|
22
|
+
_values[@"globalOriginY"] = [NSNumber numberWithDouble:originFromRootPerspective.y - view.bounds.size.height / 2.0];
|
|
23
|
+
|
|
24
|
+
return self;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@end
|
|
28
|
+
|
|
29
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#import <React/RCTBridge+Private.h>
|
|
2
|
+
#import <React/RCTDefines.h>
|
|
3
|
+
#import <React/RCTUIManager.h>
|
|
4
|
+
#import "REAAnimationsManager.h"
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
@interface REAUIManager : RCTUIManager
|
|
9
|
+
@property BOOL blockSetter;
|
|
10
|
+
- (void)setBridge:(RCTBridge *)bridge;
|
|
11
|
+
- (void)setUp:(REAAnimationsManager *)animationsManager;
|
|
12
|
+
- (void)unregisterView:(id<RCTComponent>)view;
|
|
13
|
+
@property (nonatomic, copy) void (^flushUiOperations)();
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_END
|