1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_ANIMATION_UTILS_H 17 #define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_ANIMATION_UTILS_H 18 19 #include <functional> 20 #include <memory> 21 22 #include "ui/animation/animation_option.h" 23 #include "ui/base/macros.h" 24 25 namespace OHOS::Ace::Kit { 26 27 using AnimationCallback = std::function<void()>; 28 29 class ACE_FORCE_EXPORT AnimationUtils { 30 public: 31 class Animation; 32 33 static void Animate(const AnimationOption& option, const AnimationCallback& callback, 34 const AnimationCallback& finishCallback = nullptr, const AnimationCallback& repeatCallback = nullptr); 35 static std::shared_ptr<AnimationUtils::Animation> StartAnimation(const AnimationOption& option, 36 const AnimationCallback& callback, const AnimationCallback& finishCallback = nullptr, 37 const AnimationCallback& repeatCallback = nullptr, bool flushUITasks = true); 38 static void PauseAnimation(const std::shared_ptr<AnimationUtils::Animation>& animation); 39 static void ResumeAnimation(const std::shared_ptr<AnimationUtils::Animation>& animation); 40 // need to reset the attribute of arkui node after Reverse in case of attribute inconsistent 41 static void ReverseAnimation(const std::shared_ptr<AnimationUtils::Animation>& animation); 42 static void StopAnimation(const std::shared_ptr<AnimationUtils::Animation>& animation); 43 }; 44 } // namespace OHOS::Ace::Kit 45 #endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_ANIMATION_ANIMATION_UTIL_H 46