1 /* 2 * Copyright (c) 2024 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 COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_CONTROLLER_H 17 #define COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_CONTROLLER_H 18 19 #include <functional> 20 21 #include "base/memory/ace_type.h" 22 #include "core/components/swiper/swiper_controller.h" 23 24 namespace OHOS::Ace::NG { 25 26 class JsArcSwiperController : public virtual AceType { 27 DECLARE_ACE_TYPE(JsArcSwiperController, AceType) 28 29 public: 30 JsArcSwiperController() = default; 31 ~JsArcSwiperController() override = default; 32 ShowNext()33 void ShowNext() 34 { 35 if (controller_) { 36 controller_->ShowNext(); 37 } 38 } 39 ShowPrevious()40 void ShowPrevious() 41 { 42 if (controller_) { 43 controller_->ShowPrevious(); 44 } 45 } 46 FinishAnimation(const CommonFunc & onFinish)47 void FinishAnimation(const CommonFunc& onFinish) 48 { 49 if (!controller_) { 50 return; 51 } 52 if (onFinish) { 53 controller_->SetFinishCallback(onFinish); 54 } 55 controller_->FinishAnimation(); 56 } 57 SetController(const RefPtr<SwiperController> & controller)58 void SetController(const RefPtr<SwiperController>& controller) 59 { 60 controller_ = controller; 61 } 62 63 private: 64 RefPtr<SwiperController> controller_; 65 66 ACE_DISALLOW_COPY_AND_MOVE(JsArcSwiperController); 67 }; 68 69 } // namespace OHOS::Ace::NG 70 71 #endif // COMPONENT_EXT_ARC_SWIPER_ARC_SWIPER_CONTROLLER_H