#pragma once #include #include #include #include #include #include #include #include #include #include #include #include namespace reanimated { using namespace facebook; using namespace worklets; struct LayoutAnimationConfig { int tag; LayoutAnimationType type; std::shared_ptr config; }; class LayoutAnimationsManager { public: explicit LayoutAnimationsManager(const std::shared_ptr &jsLogger) : jsLogger_(jsLogger) {} void configureAnimationBatch( const std::vector &layoutAnimationsBatch); void setShouldAnimateExiting(const int tag, const bool value); bool shouldAnimateExiting(const int tag, const bool shouldAnimate); bool hasLayoutAnimation(const int tag, const LayoutAnimationType type); void startLayoutAnimation( jsi::Runtime &rt, const int tag, const LayoutAnimationType type, const jsi::Object &values); void clearLayoutAnimationConfig(const int tag); void cancelLayoutAnimation(jsi::Runtime &rt, const int tag) const; void transferConfigFromNativeID(const int nativeId, const int tag); private: std::unordered_map> &getConfigsForType( const LayoutAnimationType type); std::shared_ptr jsLogger_; std::unordered_map> enteringAnimationsForNativeID_; std::unordered_map> enteringAnimations_; std::unordered_map> exitingAnimations_; std::unordered_map> layoutAnimations_; std::unordered_map shouldAnimateExitingForTag_; mutable std::recursive_mutex animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`, // `layoutAnimations_` and `shouldAnimateExitingForTag_`. }; } // namespace reanimated