#pragma once #include #include #include #include #include #include #include #include #include #include #include namespace reanimated { class ReanimatedModuleProxy; using namespace facebook; struct LayoutAnimation { std::shared_ptr finalView, currentView; Tag parentTag; std::optional opacity; int count = 1; LayoutAnimation &operator=(const LayoutAnimation &other) = default; }; struct LayoutAnimationsProxy : public MountingOverrideDelegate, public std::enable_shared_from_this { mutable std::unordered_map> nodeForTag_; mutable std::unordered_map layoutAnimations_; mutable std::recursive_mutex mutex; mutable SurfaceManager surfaceManager; mutable std::unordered_set> deadNodes; mutable std::unordered_map leastRemoved; mutable std::vector finishedAnimationTags_; std::shared_ptr layoutAnimationsManager_; std::shared_ptr contextContainer_; SharedComponentDescriptorRegistry componentDescriptorRegistry_; jsi::Runtime &uiRuntime_; const std::shared_ptr uiScheduler_; LayoutAnimationsProxy( std::shared_ptr layoutAnimationsManager, SharedComponentDescriptorRegistry componentDescriptorRegistry, std::shared_ptr contextContainer, jsi::Runtime &uiRuntime, const std::shared_ptr uiScheduler) : layoutAnimationsManager_(layoutAnimationsManager), contextContainer_(contextContainer), componentDescriptorRegistry_(componentDescriptorRegistry), uiRuntime_(uiRuntime), uiScheduler_(uiScheduler) {} void startEnteringAnimation(const int tag, ShadowViewMutation &mutation) const; void startExitingAnimation(const int tag, ShadowViewMutation &mutation) const; void startLayoutAnimation(const int tag, const ShadowViewMutation &mutation) const; void transferConfigFromNativeID(const std::string nativeId, const int tag) const; std::optional progressLayoutAnimation( int tag, const jsi::Object &newStyle); std::optional endLayoutAnimation(int tag, bool shouldRemove); void maybeCancelAnimation(const int tag) const; void parseRemoveMutations( std::unordered_map &movedViews, ShadowViewMutationList &mutations, std::vector> &roots) const; void handleRemovals( ShadowViewMutationList &filteredMutations, std::vector> &roots) const; void handleUpdatesAndEnterings( ShadowViewMutationList &filteredMutations, const std::unordered_map &movedViews, ShadowViewMutationList &mutations, const PropsParserContext &propsParserContext, SurfaceId surfaceId) const; void addOngoingAnimations( SurfaceId surfaceId, ShadowViewMutationList &mutations) const; void updateOngoingAnimationTarget( const int tag, const ShadowViewMutation &mutation) const; std::shared_ptr cloneViewWithoutOpacity( facebook::react::ShadowViewMutation &mutation, const PropsParserContext &propsParserContext) const; void maybeRestoreOpacity( LayoutAnimation &layoutAnimation, const jsi::Object &newStyle) const; void maybeUpdateWindowDimensions( facebook::react::ShadowViewMutation &mutation, SurfaceId surfaceId) const; void createLayoutAnimation( const ShadowViewMutation &mutation, ShadowView &oldView, const SurfaceId &surfaceId, const int tag) const; void updateIndexForMutation(ShadowViewMutation &mutation) const; void removeRecursively( std::shared_ptr node, ShadowViewMutationList &mutations) const; bool startAnimationsRecursively( std::shared_ptr node, const bool shouldRemoveSubviewsWithoutAnimations, const bool shouldAnimate, const bool isScreenPop, ShadowViewMutationList &mutations) const; void endAnimationsRecursively( std::shared_ptr node, ShadowViewMutationList &mutations) const; void maybeDropAncestors( std::shared_ptr node, std::shared_ptr child, ShadowViewMutationList &cleanupMutations) const; const ComponentDescriptor &getComponentDescriptorForShadowView( const ShadowView &shadowView) const; // MountingOverrideDelegate bool shouldOverridePullTransaction() const override; std::optional pullTransaction( SurfaceId surfaceId, MountingTransaction::Number number, const TransactionTelemetry &telemetry, ShadowViewMutationList mutations) const override; }; } // namespace reanimated