1*4440fb50SKudo Chien #pragma once 2*4440fb50SKudo Chien 3*4440fb50SKudo Chien #include "ErrorHandler.h" 4*4440fb50SKudo Chien #include "LayoutAnimationType.h" 5*4440fb50SKudo Chien #include "Shareables.h" 6*4440fb50SKudo Chien 7*4440fb50SKudo Chien #include <jsi/jsi.h> 8*4440fb50SKudo Chien #include <stdio.h> 9*4440fb50SKudo Chien #include <functional> 10*4440fb50SKudo Chien #include <memory> 11*4440fb50SKudo Chien #include <mutex> 12*4440fb50SKudo Chien #include <string> 13*4440fb50SKudo Chien #include <unordered_map> 14*4440fb50SKudo Chien #include <vector> 15*4440fb50SKudo Chien 16*4440fb50SKudo Chien namespace reanimated { 17*4440fb50SKudo Chien 18*4440fb50SKudo Chien using namespace facebook; 19*4440fb50SKudo Chien 20*4440fb50SKudo Chien class LayoutAnimationsManager { 21*4440fb50SKudo Chien public: 22*4440fb50SKudo Chien void configureAnimation( 23*4440fb50SKudo Chien int tag, 24*4440fb50SKudo Chien LayoutAnimationType type, 25*4440fb50SKudo Chien const std::string &sharedTransitionTag, 26*4440fb50SKudo Chien std::shared_ptr<Shareable> config); 27*4440fb50SKudo Chien bool hasLayoutAnimation(int tag, LayoutAnimationType type); 28*4440fb50SKudo Chien void startLayoutAnimation( 29*4440fb50SKudo Chien jsi::Runtime &rt, 30*4440fb50SKudo Chien int tag, 31*4440fb50SKudo Chien LayoutAnimationType type, 32*4440fb50SKudo Chien const jsi::Object &values); 33*4440fb50SKudo Chien void clearLayoutAnimationConfig(int tag); 34*4440fb50SKudo Chien void cancelLayoutAnimation( 35*4440fb50SKudo Chien jsi::Runtime &rt, 36*4440fb50SKudo Chien int tag, 37*4440fb50SKudo Chien LayoutAnimationType type, 38*4440fb50SKudo Chien bool cancelled /* = true */, 39*4440fb50SKudo Chien bool removeView /* = true */); 40*4440fb50SKudo Chien int findPrecedingViewTagForTransition(int tag); 41*4440fb50SKudo Chien 42*4440fb50SKudo Chien private: 43*4440fb50SKudo Chien std::unordered_map<int, std::shared_ptr<Shareable>> &getConfigsForType( 44*4440fb50SKudo Chien LayoutAnimationType type); 45*4440fb50SKudo Chien 46*4440fb50SKudo Chien std::unordered_map<int, std::shared_ptr<Shareable>> enteringAnimations_; 47*4440fb50SKudo Chien std::unordered_map<int, std::shared_ptr<Shareable>> exitingAnimations_; 48*4440fb50SKudo Chien std::unordered_map<int, std::shared_ptr<Shareable>> layoutAnimations_; 49*4440fb50SKudo Chien std::unordered_map<int, std::shared_ptr<Shareable>> 50*4440fb50SKudo Chien sharedTransitionAnimations_; 51*4440fb50SKudo Chien std::unordered_map<std::string, std::vector<int>> sharedTransitionGroups_; 52*4440fb50SKudo Chien std::unordered_map<int, std::string> viewTagToSharedTag_; 53*4440fb50SKudo Chien mutable std::mutex 54*4440fb50SKudo Chien animationsMutex_; // Protects `enteringAnimations_`, `exitingAnimations_`, 55*4440fb50SKudo Chien // `layoutAnimations_` and `viewSharedValues_`. 56*4440fb50SKudo Chien }; 57*4440fb50SKudo Chien 58*4440fb50SKudo Chien } // namespace reanimated 59