@react-native-ohos/react-native-reanimated 4.0.0-rc.1 → 4.0.2-beta.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/compatibility.json +161 -161
- package/harmony/reanimated/BuildProfile.ets +16 -16
- package/harmony/reanimated/build-profile.json5 +18 -18
- package/harmony/reanimated/hvigorfile.ts +4 -4
- package/harmony/reanimated/index.ets +4 -4
- package/harmony/reanimated/oh-package-lock.json5 +39 -0
- package/harmony/reanimated/oh-package.json5 +12 -12
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +65 -62
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +390 -390
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +30 -30
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h +21 -21
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.cpp +166 -166
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.cpp +368 -368
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp +594 -594
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.cpp +156 -156
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.h +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +94 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.cpp +48 -48
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.h +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +45 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +122 -122
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.h +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +63 -63
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +118 -118
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +111 -111
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.cpp +196 -196
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.cpp +134 -134
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +145 -145
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.cpp +69 -69
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.cpp +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.cpp +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +157 -157
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +189 -189
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/configs.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +136 -136
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.cpp +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/blur.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/brightness.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/contrast.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/dropShadow.h +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/grayscale.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/hueRotate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/invert.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/opacity.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/saturate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/sepia.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +99 -99
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +308 -308
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.cpp +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +103 -103
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +224 -224
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.h +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +218 -218
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +89 -89
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +208 -208
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.h +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.cpp +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.cpp +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.cpp +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +155 -155
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +170 -170
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/KeyframeProgressProvider.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +193 -193
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +77 -77
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +340 -340
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +167 -167
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.cpp +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +111 -110
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +75 -75
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.cpp +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.cpp +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +113 -113
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +104 -104
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +160 -160
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +161 -161
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +65 -65
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +137 -137
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +79 -79
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +864 -864
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +214 -214
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +897 -897
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +220 -220
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp +456 -456
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +102 -102
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +544 -544
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.cpp +119 -119
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +1380 -1376
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +230 -228
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +183 -183
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +54 -54
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +114 -114
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +18 -18
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +233 -230
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +30 -30
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +44 -44
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +16 -16
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +265 -265
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -36
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +35 -35
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +19 -19
- package/harmony/reanimated/src/main/cpp/TransformParser.h +93 -93
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +60 -60
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +51 -51
- package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +25 -25
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +70 -68
- package/scripts/deploy.js +191 -191
- package/scripts/set-reanimated-version.js +37 -37
- package/scripts/update-version.js +119 -119
- package/scripts/validate-react-native-version.js +46 -46
- package/scripts/validate-worklets-build.js +17 -17
- package/scripts/validate-worklets-version.js +84 -79
- package/scripts/worklets-version.json +4 -4
- package/src/index.ts +9 -9
|
@@ -1,897 +1,897 @@
|
|
|
1
|
-
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h>
|
|
2
|
-
#include <reanimated/NativeModules/ReanimatedModuleProxy.h>
|
|
3
|
-
|
|
4
|
-
#include <react/renderer/animations/utils.h>
|
|
5
|
-
#include <react/renderer/mounting/ShadowViewMutation.h>
|
|
6
|
-
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <ranges>
|
|
9
|
-
#include <set>
|
|
10
|
-
#include <string>
|
|
11
|
-
#include <unordered_map>
|
|
12
|
-
#include <unordered_set>
|
|
13
|
-
#include <utility>
|
|
14
|
-
#include <vector>
|
|
15
|
-
|
|
16
|
-
namespace reanimated {
|
|
17
|
-
|
|
18
|
-
// We never modify the Shadow Tree, we just send some additional
|
|
19
|
-
// mutations to the mounting layer.
|
|
20
|
-
// When animations finish, the Host Tree will represent the most recent Shadow
|
|
21
|
-
// Tree
|
|
22
|
-
// On android this code will be sometimes executed on the JS thread.
|
|
23
|
-
// That's why we have to schedule some of animation manager function on the UI
|
|
24
|
-
// thread
|
|
25
|
-
std::optional<MountingTransaction> LayoutAnimationsProxy_Legacy::pullTransaction(
|
|
26
|
-
SurfaceId surfaceId,
|
|
27
|
-
MountingTransaction::Number transactionNumber,
|
|
28
|
-
const TransactionTelemetry &telemetry,
|
|
29
|
-
ShadowViewMutationList mutations) const {
|
|
30
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
31
|
-
LOG(INFO) << std::endl;
|
|
32
|
-
LOG(INFO) << "pullTransaction " << std::this_thread::get_id() << " " << surfaceId << std::endl;
|
|
33
|
-
#endif
|
|
34
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
35
|
-
PropsParserContext propsParserContext{surfaceId, *contextContainer_};
|
|
36
|
-
ShadowViewMutationList filteredMutations;
|
|
37
|
-
auto &[deadNodes] = surfaceContext_[surfaceId];
|
|
38
|
-
|
|
39
|
-
std::vector<std::shared_ptr<MutationNode>> roots;
|
|
40
|
-
std::unordered_map<Tag, Tag> movedViews;
|
|
41
|
-
|
|
42
|
-
addOngoingAnimations(surfaceId, filteredMutations);
|
|
43
|
-
|
|
44
|
-
#ifdef ANDROID
|
|
45
|
-
restoreOpacityInCaseOfFlakyEnteringAnimation(surfaceId);
|
|
46
|
-
#endif // ANDROID
|
|
47
|
-
for (const auto tag : finishedAnimationTags_) {
|
|
48
|
-
auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
|
|
49
|
-
layoutAnimations_.erase(tag);
|
|
50
|
-
updateMap.erase(tag);
|
|
51
|
-
}
|
|
52
|
-
finishedAnimationTags_.clear();
|
|
53
|
-
|
|
54
|
-
parseRemoveMutations(movedViews, mutations, roots);
|
|
55
|
-
|
|
56
|
-
auto shouldAnimate = !surfacesToRemove_.contains(surfaceId);
|
|
57
|
-
surfacesToRemove_.erase(surfaceId);
|
|
58
|
-
handleRemovals(filteredMutations, roots, deadNodes, shouldAnimate);
|
|
59
|
-
|
|
60
|
-
handleUpdatesAndEnterings(filteredMutations, movedViews, mutations, propsParserContext, surfaceId);
|
|
61
|
-
|
|
62
|
-
addOngoingAnimations(surfaceId, filteredMutations);
|
|
63
|
-
|
|
64
|
-
return MountingTransaction{surfaceId, transactionNumber, std::move(filteredMutations), telemetry};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::progressLayoutAnimation(int tag, const jsi::Object &newStyle) {
|
|
68
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
69
|
-
LOG(INFO) << "progress layout animation for tag " << tag << std::endl;
|
|
70
|
-
#endif
|
|
71
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
72
|
-
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
73
|
-
|
|
74
|
-
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
auto &layoutAnimation = layoutAnimationIt->second;
|
|
79
|
-
|
|
80
|
-
maybeRestoreOpacity(layoutAnimation, newStyle);
|
|
81
|
-
|
|
82
|
-
auto rawProps = std::make_shared<RawProps>(uiRuntime_, jsi::Value(uiRuntime_, newStyle));
|
|
83
|
-
|
|
84
|
-
PropsParserContext propsParserContext{layoutAnimation.finalView.surfaceId, *contextContainer_};
|
|
85
|
-
#ifdef RN_SERIALIZABLE_STATE
|
|
86
|
-
rawProps = std::make_shared<RawProps>(
|
|
87
|
-
folly::dynamic::merge(layoutAnimation.finalView.props->rawProps, (folly::dynamic)*rawProps));
|
|
88
|
-
#endif
|
|
89
|
-
auto newProps = getComponentDescriptorForShadowView(layoutAnimation.finalView)
|
|
90
|
-
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(*rawProps));
|
|
91
|
-
auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
|
|
92
|
-
updateMap.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle)});
|
|
93
|
-
|
|
94
|
-
return layoutAnimation.finalView.surfaceId;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int tag, bool shouldRemove) {
|
|
98
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
99
|
-
LOG(INFO) << "end layout animation for " << tag << " - should remove " << shouldRemove << std::endl;
|
|
100
|
-
#endif
|
|
101
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
102
|
-
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
103
|
-
|
|
104
|
-
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
auto &layoutAnimation = layoutAnimationIt->second;
|
|
109
|
-
|
|
110
|
-
// multiple layout animations can be triggered for a view
|
|
111
|
-
// one after the other, so we need to keep count of how many
|
|
112
|
-
// were actually triggered, so that we don't cleanup necessary
|
|
113
|
-
// structures too early
|
|
114
|
-
if (layoutAnimation.count > 1) {
|
|
115
|
-
layoutAnimation.count--;
|
|
116
|
-
return {};
|
|
117
|
-
}
|
|
118
|
-
finishedAnimationTags_.push_back(tag);
|
|
119
|
-
auto surfaceId = layoutAnimation.finalView.surfaceId;
|
|
120
|
-
|
|
121
|
-
if (!shouldRemove || !nodeForTag_.contains(tag)) {
|
|
122
|
-
return {};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
auto node = nodeForTag_[tag];
|
|
126
|
-
auto mutationNode = std::static_pointer_cast<MutationNode>(node);
|
|
127
|
-
mutationNode->state = DEAD;
|
|
128
|
-
auto &[deadNodes] = surfaceContext_[surfaceId];
|
|
129
|
-
deadNodes.insert(mutationNode);
|
|
130
|
-
|
|
131
|
-
return surfaceId;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
Organizes removed views into a tree structure, allowing for convenient
|
|
136
|
-
traversals and index maintenance
|
|
137
|
-
*/
|
|
138
|
-
void LayoutAnimationsProxy_Legacy::parseRemoveMutations(
|
|
139
|
-
std::unordered_map<Tag, Tag> &movedViews,
|
|
140
|
-
ShadowViewMutationList &mutations,
|
|
141
|
-
std::vector<std::shared_ptr<MutationNode>> &roots) const {
|
|
142
|
-
std::set<Tag> deletedViews;
|
|
143
|
-
std::unordered_map<Tag, std::vector<std::shared_ptr<MutationNode>>> childrenForTag, unflattenedChildrenForTag;
|
|
144
|
-
|
|
145
|
-
std::vector<std::shared_ptr<MutationNode>> mutationNodes;
|
|
146
|
-
|
|
147
|
-
// iterate from the end, so that parents appear before children
|
|
148
|
-
for (auto it = mutations.rbegin(); it != mutations.rend(); it++) {
|
|
149
|
-
auto &mutation = *it;
|
|
150
|
-
if (mutation.type == ShadowViewMutation::Delete) {
|
|
151
|
-
deletedViews.insert(mutation.oldChildShadowView.tag);
|
|
152
|
-
}
|
|
153
|
-
if (mutation.type == ShadowViewMutation::Remove) {
|
|
154
|
-
updateIndexForMutation(mutation);
|
|
155
|
-
auto tag = mutation.oldChildShadowView.tag;
|
|
156
|
-
auto parentTag = mutation.parentTag;
|
|
157
|
-
auto unflattenedParentTag = parentTag; // temporary
|
|
158
|
-
|
|
159
|
-
std::shared_ptr<MutationNode> mutationNode;
|
|
160
|
-
std::shared_ptr<Node> node = nodeForTag_[tag], parent = nodeForTag_[parentTag],
|
|
161
|
-
unflattenedParent = nodeForTag_[unflattenedParentTag];
|
|
162
|
-
|
|
163
|
-
if (!node) {
|
|
164
|
-
mutationNode = std::make_shared<MutationNode>(mutation);
|
|
165
|
-
} else {
|
|
166
|
-
mutationNode = std::make_shared<MutationNode>(mutation, std::move(*node));
|
|
167
|
-
for (auto &subNode : mutationNode->children) {
|
|
168
|
-
subNode->parent = mutationNode;
|
|
169
|
-
}
|
|
170
|
-
for (auto &subNode : mutationNode->unflattenedChildren) {
|
|
171
|
-
subNode->unflattenedParent = mutationNode;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (!deletedViews.contains(mutation.oldChildShadowView.tag)) {
|
|
175
|
-
mutationNode->state = MOVED;
|
|
176
|
-
movedViews.insert_or_assign(mutation.oldChildShadowView.tag, -1);
|
|
177
|
-
}
|
|
178
|
-
nodeForTag_[tag] = mutationNode;
|
|
179
|
-
|
|
180
|
-
if (!parent) {
|
|
181
|
-
parent = std::make_shared<Node>(parentTag);
|
|
182
|
-
nodeForTag_[parentTag] = parent;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (!unflattenedParent) {
|
|
186
|
-
if (parentTag == unflattenedParentTag) {
|
|
187
|
-
unflattenedParent = parent;
|
|
188
|
-
} else {
|
|
189
|
-
unflattenedParent = std::make_shared<Node>(unflattenedParentTag);
|
|
190
|
-
nodeForTag_[unflattenedParentTag] = unflattenedParent;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
mutationNodes.push_back(mutationNode);
|
|
195
|
-
|
|
196
|
-
childrenForTag[parentTag].push_back(mutationNode);
|
|
197
|
-
unflattenedChildrenForTag[unflattenedParentTag].push_back(mutationNode);
|
|
198
|
-
mutationNode->parent = parent;
|
|
199
|
-
mutationNode->unflattenedParent = unflattenedParent;
|
|
200
|
-
}
|
|
201
|
-
if (mutation.type == ShadowViewMutation::Update && movedViews.contains(mutation.newChildShadowView.tag)) {
|
|
202
|
-
auto node = nodeForTag_[mutation.newChildShadowView.tag];
|
|
203
|
-
auto mutationNode = std::static_pointer_cast<MutationNode>(node);
|
|
204
|
-
mutationNode->mutation.oldChildShadowView = mutation.oldChildShadowView;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
for (const auto &mutation : mutations) {
|
|
209
|
-
if (mutation.type == ShadowViewMutation::Insert && movedViews.contains(mutation.newChildShadowView.tag)) {
|
|
210
|
-
movedViews[mutation.newChildShadowView.tag] = mutation.parentTag;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
for (auto &[parentTag, children] : childrenForTag) {
|
|
215
|
-
auto &parent = nodeForTag_[parentTag];
|
|
216
|
-
parent->insertChildren(children);
|
|
217
|
-
for (auto &child : children) {
|
|
218
|
-
child->parent = parent;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
for (auto &[unflattenedParentTag, children] : unflattenedChildrenForTag) {
|
|
222
|
-
auto &unflattenedParent = nodeForTag_[unflattenedParentTag];
|
|
223
|
-
unflattenedParent->insertUnflattenedChildren(children);
|
|
224
|
-
for (auto &child : children) {
|
|
225
|
-
child->unflattenedParent = unflattenedParent;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
for (auto &mutationNode : mutationNodes) {
|
|
230
|
-
if (!mutationNode->unflattenedParent->isMutationNode()) {
|
|
231
|
-
roots.push_back(mutationNode);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
void LayoutAnimationsProxy_Legacy::handleRemovals(
|
|
237
|
-
ShadowViewMutationList &filteredMutations,
|
|
238
|
-
std::vector<std::shared_ptr<MutationNode>> &roots,
|
|
239
|
-
std::unordered_set<std::shared_ptr<MutationNode>> &deadNodes,
|
|
240
|
-
bool shouldAnimate) const {
|
|
241
|
-
// iterate from the end, so that children
|
|
242
|
-
// with higher indices appear first in the mutations list
|
|
243
|
-
for (auto it = roots.rbegin(); it != roots.rend(); it++) {
|
|
244
|
-
auto &node = *it;
|
|
245
|
-
if (!startAnimationsRecursively(node, true, shouldAnimate, false, filteredMutations)) {
|
|
246
|
-
filteredMutations.push_back(node->mutation);
|
|
247
|
-
node->unflattenedParent->removeChildFromUnflattenedTree(node); //???
|
|
248
|
-
if (node->state != MOVED) {
|
|
249
|
-
maybeCancelAnimation(node->tag);
|
|
250
|
-
filteredMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
251
|
-
nodeForTag_.erase(node->tag);
|
|
252
|
-
node->state = DELETED;
|
|
253
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
254
|
-
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
255
|
-
#endif
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
for (const auto &node : deadNodes) {
|
|
261
|
-
if (node->state != DELETED) {
|
|
262
|
-
endAnimationsRecursively(node, filteredMutations);
|
|
263
|
-
maybeDropAncestors(node->unflattenedParent, node, filteredMutations);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
deadNodes.clear();
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
void LayoutAnimationsProxy_Legacy::handleUpdatesAndEnterings(
|
|
270
|
-
ShadowViewMutationList &filteredMutations,
|
|
271
|
-
const std::unordered_map<Tag, Tag> &movedViews,
|
|
272
|
-
ShadowViewMutationList &mutations,
|
|
273
|
-
const PropsParserContext &propsParserContext,
|
|
274
|
-
SurfaceId surfaceId) const {
|
|
275
|
-
std::unordered_map<Tag, ShadowView> oldShadowViewsForReparentings;
|
|
276
|
-
for (auto &mutation : mutations) {
|
|
277
|
-
maybeUpdateWindowDimensions(mutation, surfaceId);
|
|
278
|
-
|
|
279
|
-
Tag tag = mutation.type == ShadowViewMutation::Type::Create || mutation.type == ShadowViewMutation::Type::Insert
|
|
280
|
-
? mutation.newChildShadowView.tag
|
|
281
|
-
: mutation.oldChildShadowView.tag;
|
|
282
|
-
|
|
283
|
-
switch (mutation.type) {
|
|
284
|
-
case ShadowViewMutation::Type::Create: {
|
|
285
|
-
filteredMutations.push_back(mutation);
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case ShadowViewMutation::Type::Insert: {
|
|
289
|
-
updateIndexForMutation(mutation);
|
|
290
|
-
|
|
291
|
-
const auto parentTag = mutation.parentTag;
|
|
292
|
-
const auto mutationParent = parentTag;
|
|
293
|
-
if (nodeForTag_.contains(parentTag)) {
|
|
294
|
-
nodeForTag_[parentTag]->applyMutationToIndices(mutation);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (movedViews.contains(tag)) {
|
|
298
|
-
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
299
|
-
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
300
|
-
if (oldShadowViewsForReparentings.contains(tag)) {
|
|
301
|
-
filteredMutations.push_back(ShadowViewMutation::InsertMutation(
|
|
302
|
-
mutationParent, oldShadowViewsForReparentings[tag], mutation.index));
|
|
303
|
-
} else {
|
|
304
|
-
filteredMutations.push_back(mutation);
|
|
305
|
-
}
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
auto oldView = layoutAnimationIt->second.currentView;
|
|
310
|
-
filteredMutations.push_back(ShadowViewMutation::InsertMutation(mutationParent, oldView, mutation.index));
|
|
311
|
-
if (movedViews.contains(tag)) {
|
|
312
|
-
layoutAnimationIt->second.parentTag = movedViews.at(tag);
|
|
313
|
-
}
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
transferConfigFromNativeID(mutation.newChildShadowView.props->nativeId, mutation.newChildShadowView.tag);
|
|
318
|
-
if (!layoutAnimationsManager_->hasLayoutAnimation(tag, LayoutAnimationType::ENTERING)) {
|
|
319
|
-
filteredMutations.push_back(mutation);
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
startEnteringAnimation(tag, mutation);
|
|
324
|
-
filteredMutations.push_back(mutation);
|
|
325
|
-
|
|
326
|
-
// temporarily set opacity to 0 to prevent flickering on android
|
|
327
|
-
std::shared_ptr<ShadowView> newView = cloneViewWithoutOpacity(mutation, propsParserContext);
|
|
328
|
-
|
|
329
|
-
filteredMutations.push_back(
|
|
330
|
-
ShadowViewMutation::UpdateMutation(mutation.newChildShadowView, *newView, mutationParent));
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
case ShadowViewMutation::Type::Update: {
|
|
335
|
-
auto shouldAnimate = hasLayoutChanged(mutation);
|
|
336
|
-
if (!layoutAnimationsManager_->hasLayoutAnimation(tag, LayoutAnimationType::LAYOUT) ||
|
|
337
|
-
(!shouldAnimate && !layoutAnimations_.contains(tag))) {
|
|
338
|
-
// We should cancel any ongoing animation here to ensure that the
|
|
339
|
-
// proper final state is reached for this view However, due to how
|
|
340
|
-
// RNSScreens handle adding headers (a second commit is triggered to
|
|
341
|
-
// offset all the elements by the header height) this would lead to
|
|
342
|
-
// all entering animations being cancelled when a screen with a header
|
|
343
|
-
// is pushed onto a stack
|
|
344
|
-
// TODO: find a better solution for this problem
|
|
345
|
-
filteredMutations.push_back(mutation);
|
|
346
|
-
continue;
|
|
347
|
-
} else if (!shouldAnimate) {
|
|
348
|
-
updateOngoingAnimationTarget(tag, mutation);
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// store the oldChildShadowView, so that we can use this ShadowView when
|
|
353
|
-
// the view is inserted
|
|
354
|
-
oldShadowViewsForReparentings[tag] = mutation.oldChildShadowView;
|
|
355
|
-
if (movedViews.contains(tag)) {
|
|
356
|
-
mutation.parentTag = movedViews.at(tag);
|
|
357
|
-
}
|
|
358
|
-
if (mutation.parentTag != -1) {
|
|
359
|
-
startLayoutAnimation(tag, mutation);
|
|
360
|
-
}
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
case ShadowViewMutation::Type::Remove:
|
|
365
|
-
case ShadowViewMutation::Type::Delete: {
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
default:
|
|
370
|
-
filteredMutations.push_back(mutation);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
void LayoutAnimationsProxy_Legacy::addOngoingAnimations(SurfaceId surfaceId, ShadowViewMutationList &mutations) const {
|
|
376
|
-
auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
|
|
377
|
-
#ifdef ANDROID
|
|
378
|
-
std::vector<int> tagsToUpdate;
|
|
379
|
-
tagsToUpdate.reserve(updateMap.size());
|
|
380
|
-
|
|
381
|
-
for (auto &[tag, updateValues] : updateMap) {
|
|
382
|
-
tagsToUpdate.push_back(tag);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
auto maybeCorrectedTags = preserveMountedTags_(tagsToUpdate);
|
|
386
|
-
if (!maybeCorrectedTags.has_value()) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
auto correctedTags = maybeCorrectedTags->get();
|
|
391
|
-
|
|
392
|
-
// since the map is not updated, we can assume that the ordering of tags in
|
|
393
|
-
// correctedTags matches the iterator
|
|
394
|
-
int i = -1;
|
|
395
|
-
#endif
|
|
396
|
-
for (auto &[tag, updateValues] : updateMap) {
|
|
397
|
-
#ifdef ANDROID
|
|
398
|
-
i++;
|
|
399
|
-
if (correctedTags[i] == -1) {
|
|
400
|
-
// skip views that have not been mounted yet
|
|
401
|
-
// on Android we start entering animations from the JS thread
|
|
402
|
-
// so it might happen, that the first frame of the animation goes through
|
|
403
|
-
// before the view is first mounted
|
|
404
|
-
// https://github.com/software-mansion/react-native-reanimated/issues/7493
|
|
405
|
-
continue;
|
|
406
|
-
}
|
|
407
|
-
#endif
|
|
408
|
-
|
|
409
|
-
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
410
|
-
|
|
411
|
-
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
auto &layoutAnimation = layoutAnimationIt->second;
|
|
416
|
-
layoutAnimation.isViewAlreadyMounted = true;
|
|
417
|
-
auto newView = layoutAnimation.finalView;
|
|
418
|
-
newView.props = updateValues.newProps;
|
|
419
|
-
updateLayoutMetrics(newView.layoutMetrics, updateValues.frame);
|
|
420
|
-
|
|
421
|
-
mutations.push_back(
|
|
422
|
-
ShadowViewMutation::UpdateMutation(layoutAnimation.currentView, newView, layoutAnimation.parentTag));
|
|
423
|
-
layoutAnimation.currentView = newView;
|
|
424
|
-
}
|
|
425
|
-
updateMap.clear();
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
void LayoutAnimationsProxy_Legacy::endAnimationsRecursively(
|
|
429
|
-
const std::shared_ptr<MutationNode> &node,
|
|
430
|
-
ShadowViewMutationList &mutations) const {
|
|
431
|
-
maybeCancelAnimation(node->tag);
|
|
432
|
-
node->state = DELETED;
|
|
433
|
-
// iterate from the end, so that children
|
|
434
|
-
// with higher indices appear first in the mutations list
|
|
435
|
-
for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
|
|
436
|
-
auto &subNode = *it;
|
|
437
|
-
if (subNode->state != DELETED) {
|
|
438
|
-
endAnimationsRecursively(subNode, mutations);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
mutations.push_back(node->mutation);
|
|
442
|
-
nodeForTag_.erase(node->tag);
|
|
443
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
444
|
-
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
445
|
-
#endif
|
|
446
|
-
mutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
void LayoutAnimationsProxy_Legacy::maybeDropAncestors(
|
|
450
|
-
const std::shared_ptr<Node> &parent,
|
|
451
|
-
const std::shared_ptr<MutationNode> &child,
|
|
452
|
-
ShadowViewMutationList &cleanupMutations) const {
|
|
453
|
-
parent->removeChildFromUnflattenedTree(child);
|
|
454
|
-
if (!parent->isMutationNode()) {
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
auto node = std::static_pointer_cast<MutationNode>(parent);
|
|
459
|
-
|
|
460
|
-
if (node->children.size() == 0 && node->state != ANIMATING) {
|
|
461
|
-
nodeForTag_.erase(node->tag);
|
|
462
|
-
cleanupMutations.push_back(node->mutation);
|
|
463
|
-
maybeCancelAnimation(node->tag);
|
|
464
|
-
node->state = DELETED;
|
|
465
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
466
|
-
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
467
|
-
#endif
|
|
468
|
-
cleanupMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
469
|
-
maybeDropAncestors(node->unflattenedParent, node, cleanupMutations);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const ComponentDescriptor &LayoutAnimationsProxy_Legacy::getComponentDescriptorForShadowView(
|
|
474
|
-
const ShadowView &shadowView) const {
|
|
475
|
-
return componentDescriptorRegistry_->at(shadowView.componentHandle);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
|
|
479
|
-
const std::shared_ptr<MutationNode> &node,
|
|
480
|
-
bool shouldRemoveSubviewsWithoutAnimations,
|
|
481
|
-
bool shouldAnimate,
|
|
482
|
-
bool isScreenPop,
|
|
483
|
-
ShadowViewMutationList &mutations) const {
|
|
484
|
-
if (isRNSScreen(node)) {
|
|
485
|
-
isScreenPop = true;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
shouldAnimate = !isScreenPop && layoutAnimationsManager_->shouldAnimateExiting(node->tag, shouldAnimate);
|
|
489
|
-
|
|
490
|
-
bool hasExitAnimation =
|
|
491
|
-
shouldAnimate && layoutAnimationsManager_->hasLayoutAnimation(node->tag, LayoutAnimationType::EXITING);
|
|
492
|
-
bool hasAnimatedChildren = false;
|
|
493
|
-
|
|
494
|
-
shouldRemoveSubviewsWithoutAnimations =
|
|
495
|
-
shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == MOVED);
|
|
496
|
-
std::vector<std::shared_ptr<MutationNode>> toBeRemoved;
|
|
497
|
-
|
|
498
|
-
// iterate from the end, so that children
|
|
499
|
-
// with higher indices appear first in the mutations list
|
|
500
|
-
for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
|
|
501
|
-
auto &subNode = *it;
|
|
502
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
503
|
-
LOG(INFO) << "child " << subNode->tag << " "
|
|
504
|
-
<< " " << shouldAnimate << " " << shouldRemoveSubviewsWithoutAnimations << std::endl;
|
|
505
|
-
#endif
|
|
506
|
-
if (subNode->state != UNDEFINED && subNode->state != MOVED) {
|
|
507
|
-
if (shouldAnimate && subNode->state != DEAD) {
|
|
508
|
-
hasAnimatedChildren = true;
|
|
509
|
-
} else {
|
|
510
|
-
endAnimationsRecursively(subNode, mutations);
|
|
511
|
-
toBeRemoved.push_back(subNode);
|
|
512
|
-
}
|
|
513
|
-
} else if (startAnimationsRecursively(
|
|
514
|
-
subNode, shouldRemoveSubviewsWithoutAnimations, shouldAnimate, isScreenPop, mutations)) {
|
|
515
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
516
|
-
LOG(INFO) << "child " << subNode->tag << " start animations returned true " << std::endl;
|
|
517
|
-
#endif
|
|
518
|
-
hasAnimatedChildren = true;
|
|
519
|
-
} else if (subNode->state == MOVED) {
|
|
520
|
-
mutations.push_back(subNode->mutation);
|
|
521
|
-
toBeRemoved.push_back(subNode);
|
|
522
|
-
} else if (shouldRemoveSubviewsWithoutAnimations) {
|
|
523
|
-
maybeCancelAnimation(subNode->tag);
|
|
524
|
-
mutations.push_back(subNode->mutation);
|
|
525
|
-
toBeRemoved.push_back(subNode);
|
|
526
|
-
subNode->state = DELETED;
|
|
527
|
-
nodeForTag_.erase(subNode->tag);
|
|
528
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
529
|
-
LOG(INFO) << "delete " << subNode->tag << std::endl;
|
|
530
|
-
#endif
|
|
531
|
-
mutations.push_back(ShadowViewMutation::DeleteMutation(subNode->mutation.oldChildShadowView));
|
|
532
|
-
} else {
|
|
533
|
-
subNode->state = WAITING;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
for (auto &subNode : toBeRemoved) {
|
|
538
|
-
node->removeChildFromUnflattenedTree(subNode);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (node->state == MOVED) {
|
|
542
|
-
auto replacement = std::make_shared<Node>(*node);
|
|
543
|
-
for (const auto &subNode : node->children) {
|
|
544
|
-
subNode->parent = replacement;
|
|
545
|
-
}
|
|
546
|
-
for (const auto &subNode : node->unflattenedChildren) {
|
|
547
|
-
subNode->unflattenedParent = replacement;
|
|
548
|
-
}
|
|
549
|
-
nodeForTag_[replacement->tag] = replacement;
|
|
550
|
-
return false;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
bool wantAnimateExit = hasExitAnimation || hasAnimatedChildren;
|
|
554
|
-
|
|
555
|
-
if (hasExitAnimation) {
|
|
556
|
-
node->state = ANIMATING;
|
|
557
|
-
startExitingAnimation(node->tag, node->mutation);
|
|
558
|
-
} else {
|
|
559
|
-
layoutAnimationsManager_->clearLayoutAnimationConfig(node->tag);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return wantAnimateExit;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
void LayoutAnimationsProxy_Legacy::updateIndexForMutation(ShadowViewMutation &mutation) const {
|
|
566
|
-
if (mutation.index == -1) {
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
const auto parentTag = mutation.parentTag;
|
|
571
|
-
|
|
572
|
-
if (!nodeForTag_.contains(parentTag)) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
auto parent = nodeForTag_[parentTag];
|
|
577
|
-
int size = 0, prevIndex = -1, offset = 0;
|
|
578
|
-
|
|
579
|
-
for (auto &subNode : parent->children) {
|
|
580
|
-
size += subNode->mutation.index - prevIndex - 1;
|
|
581
|
-
if (mutation.index < size) {
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
offset++;
|
|
585
|
-
prevIndex = subNode->mutation.index;
|
|
586
|
-
}
|
|
587
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
588
|
-
int tag =
|
|
589
|
-
mutation.type == ShadowViewMutation::Insert ? mutation.newChildShadowView.tag : mutation.oldChildShadowView.tag;
|
|
590
|
-
LOG(INFO) << "update index for " << tag << " in " << parentTag << ": " << mutation.index << " -> "
|
|
591
|
-
<< mutation.index + offset << std::endl;
|
|
592
|
-
#endif
|
|
593
|
-
mutation.index += offset;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
bool LayoutAnimationsProxy_Legacy::shouldOverridePullTransaction() const {
|
|
597
|
-
return true;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
void LayoutAnimationsProxy_Legacy::createLayoutAnimation(
|
|
601
|
-
const ShadowViewMutation &mutation,
|
|
602
|
-
ShadowView &oldView,
|
|
603
|
-
const SurfaceId &surfaceId,
|
|
604
|
-
const int tag) const {
|
|
605
|
-
int count = 1;
|
|
606
|
-
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
607
|
-
|
|
608
|
-
if (layoutAnimationIt != layoutAnimations_.end()) {
|
|
609
|
-
auto &layoutAnimation = layoutAnimationIt->second;
|
|
610
|
-
oldView = layoutAnimation.currentView;
|
|
611
|
-
count = layoutAnimation.count + 1;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
auto finalView =
|
|
615
|
-
mutation.type == ShadowViewMutation::Remove ? mutation.oldChildShadowView : mutation.newChildShadowView;
|
|
616
|
-
auto currentView = oldView;
|
|
617
|
-
|
|
618
|
-
layoutAnimations_.insert_or_assign(
|
|
619
|
-
tag,
|
|
620
|
-
LayoutAnimation{
|
|
621
|
-
.finalView = finalView,
|
|
622
|
-
.currentView = currentView,
|
|
623
|
-
.parentTag = mutation.parentTag,
|
|
624
|
-
.opacity = {},
|
|
625
|
-
.isViewAlreadyMounted = false,
|
|
626
|
-
.count = count});
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
void LayoutAnimationsProxy_Legacy::startEnteringAnimation(const int tag, ShadowViewMutation &mutation) const {
|
|
630
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
631
|
-
LOG(INFO) << "start entering animation for tag " << tag << std::endl;
|
|
632
|
-
#endif
|
|
633
|
-
auto finalView = mutation.newChildShadowView;
|
|
634
|
-
auto current = mutation.newChildShadowView;
|
|
635
|
-
|
|
636
|
-
auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
|
|
637
|
-
auto opacity = viewProps.opacity;
|
|
638
|
-
|
|
639
|
-
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
|
|
640
|
-
auto strongThis = weakThis.lock();
|
|
641
|
-
if (!strongThis) {
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
Rect window{};
|
|
646
|
-
{
|
|
647
|
-
auto &mutex = strongThis->mutex;
|
|
648
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
649
|
-
strongThis->layoutAnimations_.insert_or_assign(
|
|
650
|
-
tag,
|
|
651
|
-
LayoutAnimation{
|
|
652
|
-
.finalView = finalView, .currentView = current, .parentTag = mutation.parentTag, .opacity = opacity});
|
|
653
|
-
window = strongThis->surfaceManager.getWindow(mutation.newChildShadowView.surfaceId);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
Snapshot values(mutation.newChildShadowView, window);
|
|
657
|
-
auto &uiRuntime = strongThis->uiRuntime_;
|
|
658
|
-
jsi::Object yogaValues(uiRuntime);
|
|
659
|
-
yogaValues.setProperty(uiRuntime, "targetOriginX", values.x);
|
|
660
|
-
yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", values.x);
|
|
661
|
-
yogaValues.setProperty(uiRuntime, "targetOriginY", values.y);
|
|
662
|
-
yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", values.y);
|
|
663
|
-
yogaValues.setProperty(uiRuntime, "targetWidth", values.width);
|
|
664
|
-
yogaValues.setProperty(uiRuntime, "targetHeight", values.height);
|
|
665
|
-
yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
|
|
666
|
-
yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
|
|
667
|
-
strongThis->layoutAnimationsManager_->startLayoutAnimation(
|
|
668
|
-
uiRuntime, tag, LayoutAnimationType::ENTERING, yogaValues);
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowViewMutation &mutation) const {
|
|
673
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
674
|
-
LOG(INFO) << "start exiting animation for tag " << tag << std::endl;
|
|
675
|
-
#endif
|
|
676
|
-
auto surfaceId = mutation.oldChildShadowView.surfaceId;
|
|
677
|
-
|
|
678
|
-
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, mutation, surfaceId]() {
|
|
679
|
-
auto strongThis = weakThis.lock();
|
|
680
|
-
if (!strongThis) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
auto oldView = mutation.oldChildShadowView;
|
|
685
|
-
Rect window{};
|
|
686
|
-
{
|
|
687
|
-
auto &mutex = strongThis->mutex;
|
|
688
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
689
|
-
strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
|
|
690
|
-
window = strongThis->surfaceManager.getWindow(surfaceId);
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
Snapshot values(oldView, window);
|
|
694
|
-
|
|
695
|
-
auto &uiRuntime = strongThis->uiRuntime_;
|
|
696
|
-
jsi::Object yogaValues(uiRuntime);
|
|
697
|
-
yogaValues.setProperty(uiRuntime, "currentOriginX", values.x);
|
|
698
|
-
yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", values.x);
|
|
699
|
-
yogaValues.setProperty(uiRuntime, "currentOriginY", values.y);
|
|
700
|
-
yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", values.y);
|
|
701
|
-
yogaValues.setProperty(uiRuntime, "currentWidth", values.width);
|
|
702
|
-
yogaValues.setProperty(uiRuntime, "currentHeight", values.height);
|
|
703
|
-
yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
|
|
704
|
-
yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
|
|
705
|
-
strongThis->layoutAnimationsManager_->startLayoutAnimation(
|
|
706
|
-
uiRuntime, tag, LayoutAnimationType::EXITING, yogaValues);
|
|
707
|
-
strongThis->layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const ShadowViewMutation &mutation) const {
|
|
712
|
-
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
713
|
-
LOG(INFO) << "start layout animation for tag " << tag << std::endl;
|
|
714
|
-
#endif
|
|
715
|
-
auto surfaceId = mutation.oldChildShadowView.surfaceId;
|
|
716
|
-
|
|
717
|
-
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), mutation, surfaceId, tag]() {
|
|
718
|
-
auto strongThis = weakThis.lock();
|
|
719
|
-
if (!strongThis) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
auto oldView = mutation.oldChildShadowView;
|
|
724
|
-
Rect window{};
|
|
725
|
-
{
|
|
726
|
-
auto &mutex = strongThis->mutex;
|
|
727
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
728
|
-
strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
|
|
729
|
-
window = strongThis->surfaceManager.getWindow(surfaceId);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
Snapshot currentValues(oldView, window);
|
|
733
|
-
Snapshot targetValues(mutation.newChildShadowView, window);
|
|
734
|
-
|
|
735
|
-
auto &uiRuntime = strongThis->uiRuntime_;
|
|
736
|
-
jsi::Object yogaValues(uiRuntime);
|
|
737
|
-
yogaValues.setProperty(uiRuntime, "currentOriginX", currentValues.x);
|
|
738
|
-
yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", currentValues.x);
|
|
739
|
-
yogaValues.setProperty(uiRuntime, "currentOriginY", currentValues.y);
|
|
740
|
-
yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", currentValues.y);
|
|
741
|
-
yogaValues.setProperty(uiRuntime, "currentWidth", currentValues.width);
|
|
742
|
-
yogaValues.setProperty(uiRuntime, "currentHeight", currentValues.height);
|
|
743
|
-
yogaValues.setProperty(uiRuntime, "targetOriginX", targetValues.x);
|
|
744
|
-
yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", targetValues.x);
|
|
745
|
-
yogaValues.setProperty(uiRuntime, "targetOriginY", targetValues.y);
|
|
746
|
-
yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", targetValues.y);
|
|
747
|
-
yogaValues.setProperty(uiRuntime, "targetWidth", targetValues.width);
|
|
748
|
-
yogaValues.setProperty(uiRuntime, "targetHeight", targetValues.height);
|
|
749
|
-
yogaValues.setProperty(uiRuntime, "windowWidth", targetValues.windowWidth);
|
|
750
|
-
yogaValues.setProperty(uiRuntime, "windowHeight", targetValues.windowHeight);
|
|
751
|
-
strongThis->layoutAnimationsManager_->startLayoutAnimation(uiRuntime, tag, LayoutAnimationType::LAYOUT, yogaValues);
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
void LayoutAnimationsProxy_Legacy::updateOngoingAnimationTarget(const int tag, const ShadowViewMutation &mutation)
|
|
756
|
-
const {
|
|
757
|
-
auto copy = mutation.newChildShadowView;
|
|
758
|
-
layoutAnimations_[tag].finalView = copy;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
void LayoutAnimationsProxy_Legacy::maybeCancelAnimation(const int tag) const {
|
|
762
|
-
if (!layoutAnimations_.contains(tag)) {
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
layoutAnimations_.erase(tag);
|
|
766
|
-
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
|
|
767
|
-
auto strongThis = weakThis.lock();
|
|
768
|
-
if (!strongThis) {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
auto &uiRuntime = strongThis->uiRuntime_;
|
|
773
|
-
strongThis->layoutAnimationsManager_->cancelLayoutAnimation(uiRuntime, tag);
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
void LayoutAnimationsProxy_Legacy::transferConfigFromNativeID(const std::string &nativeIdString, const int tag) const {
|
|
778
|
-
if (nativeIdString.empty()) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
try {
|
|
782
|
-
auto nativeId = stoi(nativeIdString);
|
|
783
|
-
layoutAnimationsManager_->transferConfigFromNativeID(nativeId, tag);
|
|
784
|
-
} catch (std::invalid_argument) {
|
|
785
|
-
} catch (std::out_of_range) {}
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// When entering animations start, we temporarily set opacity to 0
|
|
789
|
-
// so that we can immediately insert the view at the right position
|
|
790
|
-
// and schedule the animation on the UI thread
|
|
791
|
-
std::shared_ptr<ShadowView> LayoutAnimationsProxy_Legacy::cloneViewWithoutOpacity(
|
|
792
|
-
facebook::react::ShadowViewMutation &mutation,
|
|
793
|
-
const PropsParserContext &propsParserContext) const {
|
|
794
|
-
auto newView = std::make_shared<ShadowView>(mutation.newChildShadowView);
|
|
795
|
-
folly::dynamic opacity = folly::dynamic::object("opacity", 0);
|
|
796
|
-
auto newProps =
|
|
797
|
-
getComponentDescriptorForShadowView(*newView).cloneProps(propsParserContext, newView->props, RawProps(opacity));
|
|
798
|
-
newView->props = newProps;
|
|
799
|
-
return newView;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
void LayoutAnimationsProxy_Legacy::maybeRestoreOpacity(LayoutAnimation &layoutAnimation, const jsi::Object &newStyle)
|
|
803
|
-
const {
|
|
804
|
-
if (layoutAnimation.opacity && !newStyle.hasProperty(uiRuntime_, "opacity")) {
|
|
805
|
-
newStyle.setProperty(uiRuntime_, "opacity", jsi::Value(*layoutAnimation.opacity));
|
|
806
|
-
if (layoutAnimation.isViewAlreadyMounted) {
|
|
807
|
-
// We want to reset opacity only when we are sure that this update will be
|
|
808
|
-
// applied to the native view. Otherwise, we want to update opacity using
|
|
809
|
-
// the `restoreOpacityInCaseOfFlakyEnteringAnimation` method.
|
|
810
|
-
layoutAnimation.opacity.reset();
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
void LayoutAnimationsProxy_Legacy::maybeUpdateWindowDimensions(
|
|
816
|
-
facebook::react::ShadowViewMutation &mutation,
|
|
817
|
-
SurfaceId surfaceId) const {
|
|
818
|
-
if (mutation.type == ShadowViewMutation::Update &&
|
|
819
|
-
!std::strcmp(mutation.oldChildShadowView.componentName, RootComponentName)) {
|
|
820
|
-
surfaceManager.updateWindow(
|
|
821
|
-
surfaceId,
|
|
822
|
-
mutation.newChildShadowView.layoutMetrics.frame.size.width,
|
|
823
|
-
mutation.newChildShadowView.layoutMetrics.frame.size.height);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
void Node::applyMutationToIndices(ShadowViewMutation mutation) {
|
|
828
|
-
const auto parentTag = mutation.parentTag;
|
|
829
|
-
if (tag != parentTag) {
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
int delta = mutation.type == ShadowViewMutation::Insert ? 1 : -1;
|
|
834
|
-
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
|
835
|
-
const auto& child = *it;
|
|
836
|
-
if (child->mutation.index < mutation.index) {
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
child->mutation.index += delta;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
// Should only be called on unflattened parents
|
|
844
|
-
void Node::removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child) {
|
|
845
|
-
for (int i = unflattenedChildren.size() - 1; i >= 0; i--) {
|
|
846
|
-
if (unflattenedChildren[i]->tag == child->tag) {
|
|
847
|
-
unflattenedChildren.erase(unflattenedChildren.begin() + i);
|
|
848
|
-
break;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
auto &flattenedChildren = child->parent->children;
|
|
853
|
-
for (int i = flattenedChildren.size() - 1; i >= 0; i--) {
|
|
854
|
-
if (flattenedChildren[i]->tag == child->tag) {
|
|
855
|
-
flattenedChildren.erase(flattenedChildren.begin() + i);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
flattenedChildren[i]->mutation.index--;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
void Node::insertChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren) {
|
|
863
|
-
mergeAndSwap(children, newChildren);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
void Node::insertUnflattenedChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren) {
|
|
867
|
-
mergeAndSwap(unflattenedChildren, newChildren);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
inline bool Node::isMutationNode() {
|
|
871
|
-
return false;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
inline bool MutationNode::isMutationNode() {
|
|
875
|
-
return true;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
// UIManagerAnimationDelegate
|
|
879
|
-
|
|
880
|
-
void LayoutAnimationsProxy_Legacy::uiManagerDidConfigureNextLayoutAnimation(
|
|
881
|
-
jsi::Runtime &runtime,
|
|
882
|
-
const RawValue &config,
|
|
883
|
-
const jsi::Value &successCallbackValue,
|
|
884
|
-
const jsi::Value &failureCallbackValue) const {}
|
|
885
|
-
|
|
886
|
-
void LayoutAnimationsProxy_Legacy::setComponentDescriptorRegistry(
|
|
887
|
-
const SharedComponentDescriptorRegistry &componentDescriptorRegistry) {}
|
|
888
|
-
|
|
889
|
-
bool LayoutAnimationsProxy_Legacy::shouldAnimateFrame() const {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
void LayoutAnimationsProxy_Legacy::stopSurface(SurfaceId surfaceId) {
|
|
894
|
-
surfacesToRemove_.insert(surfaceId);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
} // namespace reanimated
|
|
1
|
+
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h>
|
|
2
|
+
#include <reanimated/NativeModules/ReanimatedModuleProxy.h>
|
|
3
|
+
|
|
4
|
+
#include <react/renderer/animations/utils.h>
|
|
5
|
+
#include <react/renderer/mounting/ShadowViewMutation.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <ranges>
|
|
9
|
+
#include <set>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <unordered_set>
|
|
13
|
+
#include <utility>
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace reanimated {
|
|
17
|
+
|
|
18
|
+
// We never modify the Shadow Tree, we just send some additional
|
|
19
|
+
// mutations to the mounting layer.
|
|
20
|
+
// When animations finish, the Host Tree will represent the most recent Shadow
|
|
21
|
+
// Tree
|
|
22
|
+
// On android this code will be sometimes executed on the JS thread.
|
|
23
|
+
// That's why we have to schedule some of animation manager function on the UI
|
|
24
|
+
// thread
|
|
25
|
+
std::optional<MountingTransaction> LayoutAnimationsProxy_Legacy::pullTransaction(
|
|
26
|
+
SurfaceId surfaceId,
|
|
27
|
+
MountingTransaction::Number transactionNumber,
|
|
28
|
+
const TransactionTelemetry &telemetry,
|
|
29
|
+
ShadowViewMutationList mutations) const {
|
|
30
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
31
|
+
LOG(INFO) << std::endl;
|
|
32
|
+
LOG(INFO) << "pullTransaction " << std::this_thread::get_id() << " " << surfaceId << std::endl;
|
|
33
|
+
#endif
|
|
34
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
35
|
+
PropsParserContext propsParserContext{surfaceId, *contextContainer_};
|
|
36
|
+
ShadowViewMutationList filteredMutations;
|
|
37
|
+
auto &[deadNodes] = surfaceContext_[surfaceId];
|
|
38
|
+
|
|
39
|
+
std::vector<std::shared_ptr<MutationNode>> roots;
|
|
40
|
+
std::unordered_map<Tag, Tag> movedViews;
|
|
41
|
+
|
|
42
|
+
addOngoingAnimations(surfaceId, filteredMutations);
|
|
43
|
+
|
|
44
|
+
#ifdef ANDROID
|
|
45
|
+
restoreOpacityInCaseOfFlakyEnteringAnimation(surfaceId);
|
|
46
|
+
#endif // ANDROID
|
|
47
|
+
for (const auto tag : finishedAnimationTags_) {
|
|
48
|
+
auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
|
|
49
|
+
layoutAnimations_.erase(tag);
|
|
50
|
+
updateMap.erase(tag);
|
|
51
|
+
}
|
|
52
|
+
finishedAnimationTags_.clear();
|
|
53
|
+
|
|
54
|
+
parseRemoveMutations(movedViews, mutations, roots);
|
|
55
|
+
|
|
56
|
+
auto shouldAnimate = !surfacesToRemove_.contains(surfaceId);
|
|
57
|
+
surfacesToRemove_.erase(surfaceId);
|
|
58
|
+
handleRemovals(filteredMutations, roots, deadNodes, shouldAnimate);
|
|
59
|
+
|
|
60
|
+
handleUpdatesAndEnterings(filteredMutations, movedViews, mutations, propsParserContext, surfaceId);
|
|
61
|
+
|
|
62
|
+
addOngoingAnimations(surfaceId, filteredMutations);
|
|
63
|
+
|
|
64
|
+
return MountingTransaction{surfaceId, transactionNumber, std::move(filteredMutations), telemetry};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::progressLayoutAnimation(int tag, const jsi::Object &newStyle) {
|
|
68
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
69
|
+
LOG(INFO) << "progress layout animation for tag " << tag << std::endl;
|
|
70
|
+
#endif
|
|
71
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
72
|
+
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
73
|
+
|
|
74
|
+
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
auto &layoutAnimation = layoutAnimationIt->second;
|
|
79
|
+
|
|
80
|
+
maybeRestoreOpacity(layoutAnimation, newStyle);
|
|
81
|
+
|
|
82
|
+
auto rawProps = std::make_shared<RawProps>(uiRuntime_, jsi::Value(uiRuntime_, newStyle));
|
|
83
|
+
|
|
84
|
+
PropsParserContext propsParserContext{layoutAnimation.finalView.surfaceId, *contextContainer_};
|
|
85
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
86
|
+
rawProps = std::make_shared<RawProps>(
|
|
87
|
+
folly::dynamic::merge(layoutAnimation.finalView.props->rawProps, (folly::dynamic)*rawProps));
|
|
88
|
+
#endif
|
|
89
|
+
auto newProps = getComponentDescriptorForShadowView(layoutAnimation.finalView)
|
|
90
|
+
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(*rawProps));
|
|
91
|
+
auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
|
|
92
|
+
updateMap.insert_or_assign(tag, UpdateValues{newProps, Frame(uiRuntime_, newStyle)});
|
|
93
|
+
|
|
94
|
+
return layoutAnimation.finalView.surfaceId;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int tag, bool shouldRemove) {
|
|
98
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
99
|
+
LOG(INFO) << "end layout animation for " << tag << " - should remove " << shouldRemove << std::endl;
|
|
100
|
+
#endif
|
|
101
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
102
|
+
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
103
|
+
|
|
104
|
+
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
auto &layoutAnimation = layoutAnimationIt->second;
|
|
109
|
+
|
|
110
|
+
// multiple layout animations can be triggered for a view
|
|
111
|
+
// one after the other, so we need to keep count of how many
|
|
112
|
+
// were actually triggered, so that we don't cleanup necessary
|
|
113
|
+
// structures too early
|
|
114
|
+
if (layoutAnimation.count > 1) {
|
|
115
|
+
layoutAnimation.count--;
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
finishedAnimationTags_.push_back(tag);
|
|
119
|
+
auto surfaceId = layoutAnimation.finalView.surfaceId;
|
|
120
|
+
|
|
121
|
+
if (!shouldRemove || !nodeForTag_.contains(tag)) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
auto node = nodeForTag_[tag];
|
|
126
|
+
auto mutationNode = std::static_pointer_cast<MutationNode>(node);
|
|
127
|
+
mutationNode->state = DEAD;
|
|
128
|
+
auto &[deadNodes] = surfaceContext_[surfaceId];
|
|
129
|
+
deadNodes.insert(mutationNode);
|
|
130
|
+
|
|
131
|
+
return surfaceId;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
Organizes removed views into a tree structure, allowing for convenient
|
|
136
|
+
traversals and index maintenance
|
|
137
|
+
*/
|
|
138
|
+
void LayoutAnimationsProxy_Legacy::parseRemoveMutations(
|
|
139
|
+
std::unordered_map<Tag, Tag> &movedViews,
|
|
140
|
+
ShadowViewMutationList &mutations,
|
|
141
|
+
std::vector<std::shared_ptr<MutationNode>> &roots) const {
|
|
142
|
+
std::set<Tag> deletedViews;
|
|
143
|
+
std::unordered_map<Tag, std::vector<std::shared_ptr<MutationNode>>> childrenForTag, unflattenedChildrenForTag;
|
|
144
|
+
|
|
145
|
+
std::vector<std::shared_ptr<MutationNode>> mutationNodes;
|
|
146
|
+
|
|
147
|
+
// iterate from the end, so that parents appear before children
|
|
148
|
+
for (auto it = mutations.rbegin(); it != mutations.rend(); it++) {
|
|
149
|
+
auto &mutation = *it;
|
|
150
|
+
if (mutation.type == ShadowViewMutation::Delete) {
|
|
151
|
+
deletedViews.insert(mutation.oldChildShadowView.tag);
|
|
152
|
+
}
|
|
153
|
+
if (mutation.type == ShadowViewMutation::Remove) {
|
|
154
|
+
updateIndexForMutation(mutation);
|
|
155
|
+
auto tag = mutation.oldChildShadowView.tag;
|
|
156
|
+
auto parentTag = mutation.parentTag;
|
|
157
|
+
auto unflattenedParentTag = parentTag; // temporary
|
|
158
|
+
|
|
159
|
+
std::shared_ptr<MutationNode> mutationNode;
|
|
160
|
+
std::shared_ptr<Node> node = nodeForTag_[tag], parent = nodeForTag_[parentTag],
|
|
161
|
+
unflattenedParent = nodeForTag_[unflattenedParentTag];
|
|
162
|
+
|
|
163
|
+
if (!node) {
|
|
164
|
+
mutationNode = std::make_shared<MutationNode>(mutation);
|
|
165
|
+
} else {
|
|
166
|
+
mutationNode = std::make_shared<MutationNode>(mutation, std::move(*node));
|
|
167
|
+
for (auto &subNode : mutationNode->children) {
|
|
168
|
+
subNode->parent = mutationNode;
|
|
169
|
+
}
|
|
170
|
+
for (auto &subNode : mutationNode->unflattenedChildren) {
|
|
171
|
+
subNode->unflattenedParent = mutationNode;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (!deletedViews.contains(mutation.oldChildShadowView.tag)) {
|
|
175
|
+
mutationNode->state = MOVED;
|
|
176
|
+
movedViews.insert_or_assign(mutation.oldChildShadowView.tag, -1);
|
|
177
|
+
}
|
|
178
|
+
nodeForTag_[tag] = mutationNode;
|
|
179
|
+
|
|
180
|
+
if (!parent) {
|
|
181
|
+
parent = std::make_shared<Node>(parentTag);
|
|
182
|
+
nodeForTag_[parentTag] = parent;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!unflattenedParent) {
|
|
186
|
+
if (parentTag == unflattenedParentTag) {
|
|
187
|
+
unflattenedParent = parent;
|
|
188
|
+
} else {
|
|
189
|
+
unflattenedParent = std::make_shared<Node>(unflattenedParentTag);
|
|
190
|
+
nodeForTag_[unflattenedParentTag] = unflattenedParent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
mutationNodes.push_back(mutationNode);
|
|
195
|
+
|
|
196
|
+
childrenForTag[parentTag].push_back(mutationNode);
|
|
197
|
+
unflattenedChildrenForTag[unflattenedParentTag].push_back(mutationNode);
|
|
198
|
+
mutationNode->parent = parent;
|
|
199
|
+
mutationNode->unflattenedParent = unflattenedParent;
|
|
200
|
+
}
|
|
201
|
+
if (mutation.type == ShadowViewMutation::Update && movedViews.contains(mutation.newChildShadowView.tag)) {
|
|
202
|
+
auto node = nodeForTag_[mutation.newChildShadowView.tag];
|
|
203
|
+
auto mutationNode = std::static_pointer_cast<MutationNode>(node);
|
|
204
|
+
mutationNode->mutation.oldChildShadowView = mutation.oldChildShadowView;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
for (const auto &mutation : mutations) {
|
|
209
|
+
if (mutation.type == ShadowViewMutation::Insert && movedViews.contains(mutation.newChildShadowView.tag)) {
|
|
210
|
+
movedViews[mutation.newChildShadowView.tag] = mutation.parentTag;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
for (auto &[parentTag, children] : childrenForTag) {
|
|
215
|
+
auto &parent = nodeForTag_[parentTag];
|
|
216
|
+
parent->insertChildren(children);
|
|
217
|
+
for (auto &child : children) {
|
|
218
|
+
child->parent = parent;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
for (auto &[unflattenedParentTag, children] : unflattenedChildrenForTag) {
|
|
222
|
+
auto &unflattenedParent = nodeForTag_[unflattenedParentTag];
|
|
223
|
+
unflattenedParent->insertUnflattenedChildren(children);
|
|
224
|
+
for (auto &child : children) {
|
|
225
|
+
child->unflattenedParent = unflattenedParent;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
for (auto &mutationNode : mutationNodes) {
|
|
230
|
+
if (!mutationNode->unflattenedParent->isMutationNode()) {
|
|
231
|
+
roots.push_back(mutationNode);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void LayoutAnimationsProxy_Legacy::handleRemovals(
|
|
237
|
+
ShadowViewMutationList &filteredMutations,
|
|
238
|
+
std::vector<std::shared_ptr<MutationNode>> &roots,
|
|
239
|
+
std::unordered_set<std::shared_ptr<MutationNode>> &deadNodes,
|
|
240
|
+
bool shouldAnimate) const {
|
|
241
|
+
// iterate from the end, so that children
|
|
242
|
+
// with higher indices appear first in the mutations list
|
|
243
|
+
for (auto it = roots.rbegin(); it != roots.rend(); it++) {
|
|
244
|
+
auto &node = *it;
|
|
245
|
+
if (!startAnimationsRecursively(node, true, shouldAnimate, false, filteredMutations)) {
|
|
246
|
+
filteredMutations.push_back(node->mutation);
|
|
247
|
+
node->unflattenedParent->removeChildFromUnflattenedTree(node); //???
|
|
248
|
+
if (node->state != MOVED) {
|
|
249
|
+
maybeCancelAnimation(node->tag);
|
|
250
|
+
filteredMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
251
|
+
nodeForTag_.erase(node->tag);
|
|
252
|
+
node->state = DELETED;
|
|
253
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
254
|
+
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
255
|
+
#endif
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
for (const auto &node : deadNodes) {
|
|
261
|
+
if (node->state != DELETED) {
|
|
262
|
+
endAnimationsRecursively(node, filteredMutations);
|
|
263
|
+
maybeDropAncestors(node->unflattenedParent, node, filteredMutations);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
deadNodes.clear();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
void LayoutAnimationsProxy_Legacy::handleUpdatesAndEnterings(
|
|
270
|
+
ShadowViewMutationList &filteredMutations,
|
|
271
|
+
const std::unordered_map<Tag, Tag> &movedViews,
|
|
272
|
+
ShadowViewMutationList &mutations,
|
|
273
|
+
const PropsParserContext &propsParserContext,
|
|
274
|
+
SurfaceId surfaceId) const {
|
|
275
|
+
std::unordered_map<Tag, ShadowView> oldShadowViewsForReparentings;
|
|
276
|
+
for (auto &mutation : mutations) {
|
|
277
|
+
maybeUpdateWindowDimensions(mutation, surfaceId);
|
|
278
|
+
|
|
279
|
+
Tag tag = mutation.type == ShadowViewMutation::Type::Create || mutation.type == ShadowViewMutation::Type::Insert
|
|
280
|
+
? mutation.newChildShadowView.tag
|
|
281
|
+
: mutation.oldChildShadowView.tag;
|
|
282
|
+
|
|
283
|
+
switch (mutation.type) {
|
|
284
|
+
case ShadowViewMutation::Type::Create: {
|
|
285
|
+
filteredMutations.push_back(mutation);
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case ShadowViewMutation::Type::Insert: {
|
|
289
|
+
updateIndexForMutation(mutation);
|
|
290
|
+
|
|
291
|
+
const auto parentTag = mutation.parentTag;
|
|
292
|
+
const auto mutationParent = parentTag;
|
|
293
|
+
if (nodeForTag_.contains(parentTag)) {
|
|
294
|
+
nodeForTag_[parentTag]->applyMutationToIndices(mutation);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (movedViews.contains(tag)) {
|
|
298
|
+
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
299
|
+
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
300
|
+
if (oldShadowViewsForReparentings.contains(tag)) {
|
|
301
|
+
filteredMutations.push_back(ShadowViewMutation::InsertMutation(
|
|
302
|
+
mutationParent, oldShadowViewsForReparentings[tag], mutation.index));
|
|
303
|
+
} else {
|
|
304
|
+
filteredMutations.push_back(mutation);
|
|
305
|
+
}
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
auto oldView = layoutAnimationIt->second.currentView;
|
|
310
|
+
filteredMutations.push_back(ShadowViewMutation::InsertMutation(mutationParent, oldView, mutation.index));
|
|
311
|
+
if (movedViews.contains(tag)) {
|
|
312
|
+
layoutAnimationIt->second.parentTag = movedViews.at(tag);
|
|
313
|
+
}
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
transferConfigFromNativeID(mutation.newChildShadowView.props->nativeId, mutation.newChildShadowView.tag);
|
|
318
|
+
if (!layoutAnimationsManager_->hasLayoutAnimation(tag, LayoutAnimationType::ENTERING)) {
|
|
319
|
+
filteredMutations.push_back(mutation);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
startEnteringAnimation(tag, mutation);
|
|
324
|
+
filteredMutations.push_back(mutation);
|
|
325
|
+
|
|
326
|
+
// temporarily set opacity to 0 to prevent flickering on android
|
|
327
|
+
std::shared_ptr<ShadowView> newView = cloneViewWithoutOpacity(mutation, propsParserContext);
|
|
328
|
+
|
|
329
|
+
filteredMutations.push_back(
|
|
330
|
+
ShadowViewMutation::UpdateMutation(mutation.newChildShadowView, *newView, mutationParent));
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
case ShadowViewMutation::Type::Update: {
|
|
335
|
+
auto shouldAnimate = hasLayoutChanged(mutation);
|
|
336
|
+
if (!layoutAnimationsManager_->hasLayoutAnimation(tag, LayoutAnimationType::LAYOUT) ||
|
|
337
|
+
(!shouldAnimate && !layoutAnimations_.contains(tag))) {
|
|
338
|
+
// We should cancel any ongoing animation here to ensure that the
|
|
339
|
+
// proper final state is reached for this view However, due to how
|
|
340
|
+
// RNSScreens handle adding headers (a second commit is triggered to
|
|
341
|
+
// offset all the elements by the header height) this would lead to
|
|
342
|
+
// all entering animations being cancelled when a screen with a header
|
|
343
|
+
// is pushed onto a stack
|
|
344
|
+
// TODO: find a better solution for this problem
|
|
345
|
+
filteredMutations.push_back(mutation);
|
|
346
|
+
continue;
|
|
347
|
+
} else if (!shouldAnimate) {
|
|
348
|
+
updateOngoingAnimationTarget(tag, mutation);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// store the oldChildShadowView, so that we can use this ShadowView when
|
|
353
|
+
// the view is inserted
|
|
354
|
+
oldShadowViewsForReparentings[tag] = mutation.oldChildShadowView;
|
|
355
|
+
if (movedViews.contains(tag)) {
|
|
356
|
+
mutation.parentTag = movedViews.at(tag);
|
|
357
|
+
}
|
|
358
|
+
if (mutation.parentTag != -1) {
|
|
359
|
+
startLayoutAnimation(tag, mutation);
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
case ShadowViewMutation::Type::Remove:
|
|
365
|
+
case ShadowViewMutation::Type::Delete: {
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
default:
|
|
370
|
+
filteredMutations.push_back(mutation);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
void LayoutAnimationsProxy_Legacy::addOngoingAnimations(SurfaceId surfaceId, ShadowViewMutationList &mutations) const {
|
|
376
|
+
auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
|
|
377
|
+
#ifdef ANDROID
|
|
378
|
+
std::vector<int> tagsToUpdate;
|
|
379
|
+
tagsToUpdate.reserve(updateMap.size());
|
|
380
|
+
|
|
381
|
+
for (auto &[tag, updateValues] : updateMap) {
|
|
382
|
+
tagsToUpdate.push_back(tag);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
auto maybeCorrectedTags = preserveMountedTags_(tagsToUpdate);
|
|
386
|
+
if (!maybeCorrectedTags.has_value()) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
auto correctedTags = maybeCorrectedTags->get();
|
|
391
|
+
|
|
392
|
+
// since the map is not updated, we can assume that the ordering of tags in
|
|
393
|
+
// correctedTags matches the iterator
|
|
394
|
+
int i = -1;
|
|
395
|
+
#endif
|
|
396
|
+
for (auto &[tag, updateValues] : updateMap) {
|
|
397
|
+
#ifdef ANDROID
|
|
398
|
+
i++;
|
|
399
|
+
if (correctedTags[i] == -1) {
|
|
400
|
+
// skip views that have not been mounted yet
|
|
401
|
+
// on Android we start entering animations from the JS thread
|
|
402
|
+
// so it might happen, that the first frame of the animation goes through
|
|
403
|
+
// before the view is first mounted
|
|
404
|
+
// https://github.com/software-mansion/react-native-reanimated/issues/7493
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
#endif
|
|
408
|
+
|
|
409
|
+
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
410
|
+
|
|
411
|
+
if (layoutAnimationIt == layoutAnimations_.end()) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
auto &layoutAnimation = layoutAnimationIt->second;
|
|
416
|
+
layoutAnimation.isViewAlreadyMounted = true;
|
|
417
|
+
auto newView = layoutAnimation.finalView;
|
|
418
|
+
newView.props = updateValues.newProps;
|
|
419
|
+
updateLayoutMetrics(newView.layoutMetrics, updateValues.frame);
|
|
420
|
+
|
|
421
|
+
mutations.push_back(
|
|
422
|
+
ShadowViewMutation::UpdateMutation(layoutAnimation.currentView, newView, layoutAnimation.parentTag));
|
|
423
|
+
layoutAnimation.currentView = newView;
|
|
424
|
+
}
|
|
425
|
+
updateMap.clear();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
void LayoutAnimationsProxy_Legacy::endAnimationsRecursively(
|
|
429
|
+
const std::shared_ptr<MutationNode> &node,
|
|
430
|
+
ShadowViewMutationList &mutations) const {
|
|
431
|
+
maybeCancelAnimation(node->tag);
|
|
432
|
+
node->state = DELETED;
|
|
433
|
+
// iterate from the end, so that children
|
|
434
|
+
// with higher indices appear first in the mutations list
|
|
435
|
+
for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
|
|
436
|
+
auto &subNode = *it;
|
|
437
|
+
if (subNode->state != DELETED) {
|
|
438
|
+
endAnimationsRecursively(subNode, mutations);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
mutations.push_back(node->mutation);
|
|
442
|
+
nodeForTag_.erase(node->tag);
|
|
443
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
444
|
+
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
445
|
+
#endif
|
|
446
|
+
mutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
void LayoutAnimationsProxy_Legacy::maybeDropAncestors(
|
|
450
|
+
const std::shared_ptr<Node> &parent,
|
|
451
|
+
const std::shared_ptr<MutationNode> &child,
|
|
452
|
+
ShadowViewMutationList &cleanupMutations) const {
|
|
453
|
+
parent->removeChildFromUnflattenedTree(child);
|
|
454
|
+
if (!parent->isMutationNode()) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
auto node = std::static_pointer_cast<MutationNode>(parent);
|
|
459
|
+
|
|
460
|
+
if (node->children.size() == 0 && node->state != ANIMATING) {
|
|
461
|
+
nodeForTag_.erase(node->tag);
|
|
462
|
+
cleanupMutations.push_back(node->mutation);
|
|
463
|
+
maybeCancelAnimation(node->tag);
|
|
464
|
+
node->state = DELETED;
|
|
465
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
466
|
+
LOG(INFO) << "delete " << node->tag << std::endl;
|
|
467
|
+
#endif
|
|
468
|
+
cleanupMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
|
|
469
|
+
maybeDropAncestors(node->unflattenedParent, node, cleanupMutations);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const ComponentDescriptor &LayoutAnimationsProxy_Legacy::getComponentDescriptorForShadowView(
|
|
474
|
+
const ShadowView &shadowView) const {
|
|
475
|
+
return componentDescriptorRegistry_->at(shadowView.componentHandle);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
|
|
479
|
+
const std::shared_ptr<MutationNode> &node,
|
|
480
|
+
bool shouldRemoveSubviewsWithoutAnimations,
|
|
481
|
+
bool shouldAnimate,
|
|
482
|
+
bool isScreenPop,
|
|
483
|
+
ShadowViewMutationList &mutations) const {
|
|
484
|
+
if (isRNSScreen(node)) {
|
|
485
|
+
isScreenPop = true;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
shouldAnimate = !isScreenPop && layoutAnimationsManager_->shouldAnimateExiting(node->tag, shouldAnimate);
|
|
489
|
+
|
|
490
|
+
bool hasExitAnimation =
|
|
491
|
+
shouldAnimate && layoutAnimationsManager_->hasLayoutAnimation(node->tag, LayoutAnimationType::EXITING);
|
|
492
|
+
bool hasAnimatedChildren = false;
|
|
493
|
+
|
|
494
|
+
shouldRemoveSubviewsWithoutAnimations =
|
|
495
|
+
shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == MOVED);
|
|
496
|
+
std::vector<std::shared_ptr<MutationNode>> toBeRemoved;
|
|
497
|
+
|
|
498
|
+
// iterate from the end, so that children
|
|
499
|
+
// with higher indices appear first in the mutations list
|
|
500
|
+
for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
|
|
501
|
+
auto &subNode = *it;
|
|
502
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
503
|
+
LOG(INFO) << "child " << subNode->tag << " "
|
|
504
|
+
<< " " << shouldAnimate << " " << shouldRemoveSubviewsWithoutAnimations << std::endl;
|
|
505
|
+
#endif
|
|
506
|
+
if (subNode->state != UNDEFINED && subNode->state != MOVED) {
|
|
507
|
+
if (shouldAnimate && subNode->state != DEAD) {
|
|
508
|
+
hasAnimatedChildren = true;
|
|
509
|
+
} else {
|
|
510
|
+
endAnimationsRecursively(subNode, mutations);
|
|
511
|
+
toBeRemoved.push_back(subNode);
|
|
512
|
+
}
|
|
513
|
+
} else if (startAnimationsRecursively(
|
|
514
|
+
subNode, shouldRemoveSubviewsWithoutAnimations, shouldAnimate, isScreenPop, mutations)) {
|
|
515
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
516
|
+
LOG(INFO) << "child " << subNode->tag << " start animations returned true " << std::endl;
|
|
517
|
+
#endif
|
|
518
|
+
hasAnimatedChildren = true;
|
|
519
|
+
} else if (subNode->state == MOVED) {
|
|
520
|
+
mutations.push_back(subNode->mutation);
|
|
521
|
+
toBeRemoved.push_back(subNode);
|
|
522
|
+
} else if (shouldRemoveSubviewsWithoutAnimations) {
|
|
523
|
+
maybeCancelAnimation(subNode->tag);
|
|
524
|
+
mutations.push_back(subNode->mutation);
|
|
525
|
+
toBeRemoved.push_back(subNode);
|
|
526
|
+
subNode->state = DELETED;
|
|
527
|
+
nodeForTag_.erase(subNode->tag);
|
|
528
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
529
|
+
LOG(INFO) << "delete " << subNode->tag << std::endl;
|
|
530
|
+
#endif
|
|
531
|
+
mutations.push_back(ShadowViewMutation::DeleteMutation(subNode->mutation.oldChildShadowView));
|
|
532
|
+
} else {
|
|
533
|
+
subNode->state = WAITING;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
for (auto &subNode : toBeRemoved) {
|
|
538
|
+
node->removeChildFromUnflattenedTree(subNode);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (node->state == MOVED) {
|
|
542
|
+
auto replacement = std::make_shared<Node>(*node);
|
|
543
|
+
for (const auto &subNode : node->children) {
|
|
544
|
+
subNode->parent = replacement;
|
|
545
|
+
}
|
|
546
|
+
for (const auto &subNode : node->unflattenedChildren) {
|
|
547
|
+
subNode->unflattenedParent = replacement;
|
|
548
|
+
}
|
|
549
|
+
nodeForTag_[replacement->tag] = replacement;
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
bool wantAnimateExit = hasExitAnimation || hasAnimatedChildren;
|
|
554
|
+
|
|
555
|
+
if (hasExitAnimation) {
|
|
556
|
+
node->state = ANIMATING;
|
|
557
|
+
startExitingAnimation(node->tag, node->mutation);
|
|
558
|
+
} else {
|
|
559
|
+
layoutAnimationsManager_->clearLayoutAnimationConfig(node->tag);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return wantAnimateExit;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
void LayoutAnimationsProxy_Legacy::updateIndexForMutation(ShadowViewMutation &mutation) const {
|
|
566
|
+
if (mutation.index == -1) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const auto parentTag = mutation.parentTag;
|
|
571
|
+
|
|
572
|
+
if (!nodeForTag_.contains(parentTag)) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
auto parent = nodeForTag_[parentTag];
|
|
577
|
+
int size = 0, prevIndex = -1, offset = 0;
|
|
578
|
+
|
|
579
|
+
for (auto &subNode : parent->children) {
|
|
580
|
+
size += subNode->mutation.index - prevIndex - 1;
|
|
581
|
+
if (mutation.index < size) {
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
offset++;
|
|
585
|
+
prevIndex = subNode->mutation.index;
|
|
586
|
+
}
|
|
587
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
588
|
+
int tag =
|
|
589
|
+
mutation.type == ShadowViewMutation::Insert ? mutation.newChildShadowView.tag : mutation.oldChildShadowView.tag;
|
|
590
|
+
LOG(INFO) << "update index for " << tag << " in " << parentTag << ": " << mutation.index << " -> "
|
|
591
|
+
<< mutation.index + offset << std::endl;
|
|
592
|
+
#endif
|
|
593
|
+
mutation.index += offset;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
bool LayoutAnimationsProxy_Legacy::shouldOverridePullTransaction() const {
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
void LayoutAnimationsProxy_Legacy::createLayoutAnimation(
|
|
601
|
+
const ShadowViewMutation &mutation,
|
|
602
|
+
ShadowView &oldView,
|
|
603
|
+
const SurfaceId &surfaceId,
|
|
604
|
+
const int tag) const {
|
|
605
|
+
int count = 1;
|
|
606
|
+
auto layoutAnimationIt = layoutAnimations_.find(tag);
|
|
607
|
+
|
|
608
|
+
if (layoutAnimationIt != layoutAnimations_.end()) {
|
|
609
|
+
auto &layoutAnimation = layoutAnimationIt->second;
|
|
610
|
+
oldView = layoutAnimation.currentView;
|
|
611
|
+
count = layoutAnimation.count + 1;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
auto finalView =
|
|
615
|
+
mutation.type == ShadowViewMutation::Remove ? mutation.oldChildShadowView : mutation.newChildShadowView;
|
|
616
|
+
auto currentView = oldView;
|
|
617
|
+
|
|
618
|
+
layoutAnimations_.insert_or_assign(
|
|
619
|
+
tag,
|
|
620
|
+
LayoutAnimation{
|
|
621
|
+
.finalView = finalView,
|
|
622
|
+
.currentView = currentView,
|
|
623
|
+
.parentTag = mutation.parentTag,
|
|
624
|
+
.opacity = {},
|
|
625
|
+
.isViewAlreadyMounted = false,
|
|
626
|
+
.count = count});
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
void LayoutAnimationsProxy_Legacy::startEnteringAnimation(const int tag, ShadowViewMutation &mutation) const {
|
|
630
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
631
|
+
LOG(INFO) << "start entering animation for tag " << tag << std::endl;
|
|
632
|
+
#endif
|
|
633
|
+
auto finalView = mutation.newChildShadowView;
|
|
634
|
+
auto current = mutation.newChildShadowView;
|
|
635
|
+
|
|
636
|
+
auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
|
|
637
|
+
auto opacity = viewProps.opacity;
|
|
638
|
+
|
|
639
|
+
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
|
|
640
|
+
auto strongThis = weakThis.lock();
|
|
641
|
+
if (!strongThis) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
Rect window{};
|
|
646
|
+
{
|
|
647
|
+
auto &mutex = strongThis->mutex;
|
|
648
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
649
|
+
strongThis->layoutAnimations_.insert_or_assign(
|
|
650
|
+
tag,
|
|
651
|
+
LayoutAnimation{
|
|
652
|
+
.finalView = finalView, .currentView = current, .parentTag = mutation.parentTag, .opacity = opacity});
|
|
653
|
+
window = strongThis->surfaceManager.getWindow(mutation.newChildShadowView.surfaceId);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
Snapshot values(mutation.newChildShadowView, window);
|
|
657
|
+
auto &uiRuntime = strongThis->uiRuntime_;
|
|
658
|
+
jsi::Object yogaValues(uiRuntime);
|
|
659
|
+
yogaValues.setProperty(uiRuntime, "targetOriginX", values.x);
|
|
660
|
+
yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", values.x);
|
|
661
|
+
yogaValues.setProperty(uiRuntime, "targetOriginY", values.y);
|
|
662
|
+
yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", values.y);
|
|
663
|
+
yogaValues.setProperty(uiRuntime, "targetWidth", values.width);
|
|
664
|
+
yogaValues.setProperty(uiRuntime, "targetHeight", values.height);
|
|
665
|
+
yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
|
|
666
|
+
yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
|
|
667
|
+
strongThis->layoutAnimationsManager_->startLayoutAnimation(
|
|
668
|
+
uiRuntime, tag, LayoutAnimationType::ENTERING, yogaValues);
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowViewMutation &mutation) const {
|
|
673
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
674
|
+
LOG(INFO) << "start exiting animation for tag " << tag << std::endl;
|
|
675
|
+
#endif
|
|
676
|
+
auto surfaceId = mutation.oldChildShadowView.surfaceId;
|
|
677
|
+
|
|
678
|
+
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, mutation, surfaceId]() {
|
|
679
|
+
auto strongThis = weakThis.lock();
|
|
680
|
+
if (!strongThis) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
auto oldView = mutation.oldChildShadowView;
|
|
685
|
+
Rect window{};
|
|
686
|
+
{
|
|
687
|
+
auto &mutex = strongThis->mutex;
|
|
688
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
689
|
+
strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
|
|
690
|
+
window = strongThis->surfaceManager.getWindow(surfaceId);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
Snapshot values(oldView, window);
|
|
694
|
+
|
|
695
|
+
auto &uiRuntime = strongThis->uiRuntime_;
|
|
696
|
+
jsi::Object yogaValues(uiRuntime);
|
|
697
|
+
yogaValues.setProperty(uiRuntime, "currentOriginX", values.x);
|
|
698
|
+
yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", values.x);
|
|
699
|
+
yogaValues.setProperty(uiRuntime, "currentOriginY", values.y);
|
|
700
|
+
yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", values.y);
|
|
701
|
+
yogaValues.setProperty(uiRuntime, "currentWidth", values.width);
|
|
702
|
+
yogaValues.setProperty(uiRuntime, "currentHeight", values.height);
|
|
703
|
+
yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
|
|
704
|
+
yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
|
|
705
|
+
strongThis->layoutAnimationsManager_->startLayoutAnimation(
|
|
706
|
+
uiRuntime, tag, LayoutAnimationType::EXITING, yogaValues);
|
|
707
|
+
strongThis->layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const ShadowViewMutation &mutation) const {
|
|
712
|
+
#ifdef LAYOUT_ANIMATIONS_LOGS
|
|
713
|
+
LOG(INFO) << "start layout animation for tag " << tag << std::endl;
|
|
714
|
+
#endif
|
|
715
|
+
auto surfaceId = mutation.oldChildShadowView.surfaceId;
|
|
716
|
+
|
|
717
|
+
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), mutation, surfaceId, tag]() {
|
|
718
|
+
auto strongThis = weakThis.lock();
|
|
719
|
+
if (!strongThis) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
auto oldView = mutation.oldChildShadowView;
|
|
724
|
+
Rect window{};
|
|
725
|
+
{
|
|
726
|
+
auto &mutex = strongThis->mutex;
|
|
727
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
728
|
+
strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
|
|
729
|
+
window = strongThis->surfaceManager.getWindow(surfaceId);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
Snapshot currentValues(oldView, window);
|
|
733
|
+
Snapshot targetValues(mutation.newChildShadowView, window);
|
|
734
|
+
|
|
735
|
+
auto &uiRuntime = strongThis->uiRuntime_;
|
|
736
|
+
jsi::Object yogaValues(uiRuntime);
|
|
737
|
+
yogaValues.setProperty(uiRuntime, "currentOriginX", currentValues.x);
|
|
738
|
+
yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", currentValues.x);
|
|
739
|
+
yogaValues.setProperty(uiRuntime, "currentOriginY", currentValues.y);
|
|
740
|
+
yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", currentValues.y);
|
|
741
|
+
yogaValues.setProperty(uiRuntime, "currentWidth", currentValues.width);
|
|
742
|
+
yogaValues.setProperty(uiRuntime, "currentHeight", currentValues.height);
|
|
743
|
+
yogaValues.setProperty(uiRuntime, "targetOriginX", targetValues.x);
|
|
744
|
+
yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", targetValues.x);
|
|
745
|
+
yogaValues.setProperty(uiRuntime, "targetOriginY", targetValues.y);
|
|
746
|
+
yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", targetValues.y);
|
|
747
|
+
yogaValues.setProperty(uiRuntime, "targetWidth", targetValues.width);
|
|
748
|
+
yogaValues.setProperty(uiRuntime, "targetHeight", targetValues.height);
|
|
749
|
+
yogaValues.setProperty(uiRuntime, "windowWidth", targetValues.windowWidth);
|
|
750
|
+
yogaValues.setProperty(uiRuntime, "windowHeight", targetValues.windowHeight);
|
|
751
|
+
strongThis->layoutAnimationsManager_->startLayoutAnimation(uiRuntime, tag, LayoutAnimationType::LAYOUT, yogaValues);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
void LayoutAnimationsProxy_Legacy::updateOngoingAnimationTarget(const int tag, const ShadowViewMutation &mutation)
|
|
756
|
+
const {
|
|
757
|
+
auto copy = mutation.newChildShadowView;
|
|
758
|
+
layoutAnimations_[tag].finalView = copy;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
void LayoutAnimationsProxy_Legacy::maybeCancelAnimation(const int tag) const {
|
|
762
|
+
if (!layoutAnimations_.contains(tag)) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
layoutAnimations_.erase(tag);
|
|
766
|
+
uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
|
|
767
|
+
auto strongThis = weakThis.lock();
|
|
768
|
+
if (!strongThis) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
auto &uiRuntime = strongThis->uiRuntime_;
|
|
773
|
+
strongThis->layoutAnimationsManager_->cancelLayoutAnimation(uiRuntime, tag);
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
void LayoutAnimationsProxy_Legacy::transferConfigFromNativeID(const std::string &nativeIdString, const int tag) const {
|
|
778
|
+
if (nativeIdString.empty()) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
try {
|
|
782
|
+
auto nativeId = stoi(nativeIdString);
|
|
783
|
+
layoutAnimationsManager_->transferConfigFromNativeID(nativeId, tag);
|
|
784
|
+
} catch (std::invalid_argument) {
|
|
785
|
+
} catch (std::out_of_range) {}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// When entering animations start, we temporarily set opacity to 0
|
|
789
|
+
// so that we can immediately insert the view at the right position
|
|
790
|
+
// and schedule the animation on the UI thread
|
|
791
|
+
std::shared_ptr<ShadowView> LayoutAnimationsProxy_Legacy::cloneViewWithoutOpacity(
|
|
792
|
+
facebook::react::ShadowViewMutation &mutation,
|
|
793
|
+
const PropsParserContext &propsParserContext) const {
|
|
794
|
+
auto newView = std::make_shared<ShadowView>(mutation.newChildShadowView);
|
|
795
|
+
folly::dynamic opacity = folly::dynamic::object("opacity", 0);
|
|
796
|
+
auto newProps =
|
|
797
|
+
getComponentDescriptorForShadowView(*newView).cloneProps(propsParserContext, newView->props, RawProps(opacity));
|
|
798
|
+
newView->props = newProps;
|
|
799
|
+
return newView;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
void LayoutAnimationsProxy_Legacy::maybeRestoreOpacity(LayoutAnimation &layoutAnimation, const jsi::Object &newStyle)
|
|
803
|
+
const {
|
|
804
|
+
if (layoutAnimation.opacity && !newStyle.hasProperty(uiRuntime_, "opacity")) {
|
|
805
|
+
newStyle.setProperty(uiRuntime_, "opacity", jsi::Value(*layoutAnimation.opacity));
|
|
806
|
+
if (layoutAnimation.isViewAlreadyMounted) {
|
|
807
|
+
// We want to reset opacity only when we are sure that this update will be
|
|
808
|
+
// applied to the native view. Otherwise, we want to update opacity using
|
|
809
|
+
// the `restoreOpacityInCaseOfFlakyEnteringAnimation` method.
|
|
810
|
+
layoutAnimation.opacity.reset();
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
void LayoutAnimationsProxy_Legacy::maybeUpdateWindowDimensions(
|
|
816
|
+
facebook::react::ShadowViewMutation &mutation,
|
|
817
|
+
SurfaceId surfaceId) const {
|
|
818
|
+
if (mutation.type == ShadowViewMutation::Update &&
|
|
819
|
+
!std::strcmp(mutation.oldChildShadowView.componentName, RootComponentName)) {
|
|
820
|
+
surfaceManager.updateWindow(
|
|
821
|
+
surfaceId,
|
|
822
|
+
mutation.newChildShadowView.layoutMetrics.frame.size.width,
|
|
823
|
+
mutation.newChildShadowView.layoutMetrics.frame.size.height);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
void Node::applyMutationToIndices(ShadowViewMutation mutation) {
|
|
828
|
+
const auto parentTag = mutation.parentTag;
|
|
829
|
+
if (tag != parentTag) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
int delta = mutation.type == ShadowViewMutation::Insert ? 1 : -1;
|
|
834
|
+
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
|
835
|
+
const auto& child = *it;
|
|
836
|
+
if (child->mutation.index < mutation.index) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
child->mutation.index += delta;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// Should only be called on unflattened parents
|
|
844
|
+
void Node::removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child) {
|
|
845
|
+
for (int i = unflattenedChildren.size() - 1; i >= 0; i--) {
|
|
846
|
+
if (unflattenedChildren[i]->tag == child->tag) {
|
|
847
|
+
unflattenedChildren.erase(unflattenedChildren.begin() + i);
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
auto &flattenedChildren = child->parent->children;
|
|
853
|
+
for (int i = flattenedChildren.size() - 1; i >= 0; i--) {
|
|
854
|
+
if (flattenedChildren[i]->tag == child->tag) {
|
|
855
|
+
flattenedChildren.erase(flattenedChildren.begin() + i);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
flattenedChildren[i]->mutation.index--;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
void Node::insertChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren) {
|
|
863
|
+
mergeAndSwap(children, newChildren);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
void Node::insertUnflattenedChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren) {
|
|
867
|
+
mergeAndSwap(unflattenedChildren, newChildren);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
inline bool Node::isMutationNode() {
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
inline bool MutationNode::isMutationNode() {
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// UIManagerAnimationDelegate
|
|
879
|
+
|
|
880
|
+
void LayoutAnimationsProxy_Legacy::uiManagerDidConfigureNextLayoutAnimation(
|
|
881
|
+
jsi::Runtime &runtime,
|
|
882
|
+
const RawValue &config,
|
|
883
|
+
const jsi::Value &successCallbackValue,
|
|
884
|
+
const jsi::Value &failureCallbackValue) const {}
|
|
885
|
+
|
|
886
|
+
void LayoutAnimationsProxy_Legacy::setComponentDescriptorRegistry(
|
|
887
|
+
const SharedComponentDescriptorRegistry &componentDescriptorRegistry) {}
|
|
888
|
+
|
|
889
|
+
bool LayoutAnimationsProxy_Legacy::shouldAnimateFrame() const {
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
void LayoutAnimationsProxy_Legacy::stopSurface(SurfaceId surfaceId) {
|
|
894
|
+
surfacesToRemove_.insert(surfaceId);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
} // namespace reanimated
|