#pragma once #include "JSLogger.h" #include "LayoutAnimationType.h" #include "Shareables.h" #include #include #include #include #include #include #include #include #include namespace reanimated { using namespace facebook; struct LayoutAnimationConfig { int tag; LayoutAnimationType type; std::shared_ptr config; }; class LayoutAnimationsManager { public: explicit LayoutAnimationsManager(const std::shared_ptr &jsLogger) : jsLogger_(jsLogger) {} void configureAnimation( const int tag, const LayoutAnimationType type, const std::string &sharedTransitionTag, const std::shared_ptr &config); 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; int findPrecedingViewTagForTransition(const int tag); #ifndef NDEBUG std::string getScreenSharedTagPairString( const int screenTag, const std::string &sharedTag) const; void checkDuplicateSharedTag(const int viewTag, const int screenTag); #endif private: std::unordered_map> &getConfigsForType( const LayoutAnimationType type); std::shared_ptr jsLogger_; #ifndef NDEBUG // This set's function is to detect duplicate sharedTags on a single screen // it contains strings in form: "reactScreenTag:sharedTag" std::unordered_set screenSharedTagSet_; // And this map is to remove collected pairs on SET removal std::unordered_map viewsScreenSharedTagMap_; #endif std::unordered_map> enteringAnimations_; std::unordered_map> exitingAnimations_; std::unordered_map> layoutAnimations_; std::unordered_map> sharedTransitionAnimations_; std::unordered_set ignoreProgressAnimationForTag_; std::unordered_map> sharedTransitionGroups_; std::unordered_map viewTagToSharedTag_; std::unordered_map shouldAnimateExitingForTag_; mutable std::mutex animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`, // `layoutAnimations_`, `viewSharedValues_` and `shouldAnimateExitingForTag_`. }; } // namespace reanimated