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