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 #include "bridge/cj_frontend/cppview/swiper_controller.h"
17 
18 #include <cinttypes>
19 
20 namespace OHOS::Ace::Framework {
21 
NativeSwiperController()22 NativeSwiperController::NativeSwiperController() : FFIData()
23 {
24     LOGI("Native SwiperController constructed: %{public}" PRId64, GetID());
25 }
26 
~NativeSwiperController()27 NativeSwiperController::~NativeSwiperController()
28 {
29     LOGI("Native SwiperController Destroyed: %{public}" PRId64, GetID());
30 }
31 
ShowNext()32 void NativeSwiperController::ShowNext()
33 {
34     if (controller_) {
35         controller_->ShowNext();
36     }
37 }
38 
ShowPrevious()39 void NativeSwiperController::ShowPrevious()
40 {
41     if (controller_) {
42         controller_->ShowPrevious();
43     }
44 }
45 
FinishAnimation()46 void NativeSwiperController::FinishAnimation()
47 {
48     if (controller_) {
49         controller_->FinishAnimation();
50     }
51 }
52 
FinishAnimationWithCallback(const std::function<void ()> & callback)53 void NativeSwiperController::FinishAnimationWithCallback(const std::function<void()>& callback)
54 {
55     if (controller_) {
56         controller_->SetFinishCallback(callback);
57         controller_->FinishAnimation();
58     }
59 }
60 
SetController(const RefPtr<SwiperController> & controller)61 void NativeSwiperController::SetController(const RefPtr<SwiperController>& controller)
62 {
63     controller_ = controller;
64 }
65 
66 } // namespace OHOS::Ace::Framework
67