• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SWIPER_SWIPER_HELPER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SWIPER_SWIPER_HELPER_H
18 #include "swiper_pattern.h"
19 
20 #include "core/components/swiper/swiper_controller.h"
21 #include "core/components_ng/pattern/swiper_indicator/indicator_common/swiper_indicator_layout_property.h"
22 namespace OHOS::Ace::NG {
23 /* implements helper functions for SwiperPattern */
24 class SwiperHelper {
25 public:
26     /* Init controller of swiper, controller support showNext, showPrevious and finishAnimation interface. */
27     static void InitSwiperController(const RefPtr<SwiperController>& controller, const WeakPtr<SwiperPattern>& weak);
28 
29     static void SaveDigitIndicatorProperty(const RefPtr<FrameNode>& indicatorNode, SwiperPattern& swiper);
30     static void SaveDotIndicatorProperty(const RefPtr<FrameNode>& indicatorNode, SwiperPattern& swiper);
31 
32     static void DumpAdvanceInfo(SwiperPattern& swiper);
33 
34     static std::string GetDotIndicatorStyle(const std::shared_ptr<SwiperParameters>& params);
35     static std::string GetDigitIndicatorStyle(const std::shared_ptr<SwiperDigitalParameters>& params);
36 
37     static float CalculateFriction(float gamma);
38 
39 private:
40     static void DumpInfoAddPositionDesc(SwiperPattern& swiper);
41     static void DumpInfoAddGestureDesc(SwiperPattern& swiper);
42     static void DumpInfoAddAnimationDesc(SwiperPattern& swiper);
43     static void SetChangeIndexWithModeImpl(const RefPtr<SwiperController>& controller,
44         const WeakPtr<SwiperPattern>& weak);
45     static void SaveDigitIndicatorIgnoreSize(const SwiperPattern& swiper,
46         const std::shared_ptr<SwiperDigitalParameters>& digitalParams,
47         RefPtr<SwiperIndicatorLayoutProperty>& indicatorProps, bool isSidebarMiddle, bool isShowArrow);
48 };
49 } // namespace OHOS::Ace::NG
50 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SWIPER_SWIPER_HELPER_H
51