1 /* 2 * Copyright (c) 2022-2023 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_PATTERNS_SWIPER_SWIPER_MODEL_NG_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_SWIPER_MODEL_NG_H 18 19 #include "base/geometry/axis.h" 20 #include "base/geometry/dimension.h" 21 #include "base/memory/referenced.h" 22 #include "base/utils/macros.h" 23 #include "core/components/common/layout/constants.h" 24 #include "core/components/common/properties/scroll_bar.h" 25 #include "core/components/declaration/swiper/swiper_declaration.h" 26 #include "core/components_ng/base/frame_node.h" 27 #include "core/components_ng/pattern/swiper/swiper_model.h" 28 29 namespace OHOS::Ace::NG { 30 class ACE_EXPORT SwiperModelNG : public OHOS::Ace::SwiperModel { 31 public: 32 RefPtr<SwiperController> Create() override; 33 void SetDirection(Axis axis) override; 34 void SetIndex(uint32_t index) override; 35 void SetAutoPlay(bool autoPlay) override; 36 void SetAutoPlayInterval(uint32_t interval) override; 37 void SetDuration(uint32_t duration) override; 38 void SetCurve(const RefPtr<Curve>& curve) override; 39 void SetLoop(bool loop) override; 40 void SetEnabled(bool enabled) override; 41 void SetDisableSwipe(bool disableSwipe) override; 42 void SetEdgeEffect(EdgeEffect EdgeEffect) override; 43 void SetDisplayMode(SwiperDisplayMode displayMode) override; 44 void SetDisplayCount(int32_t displayCount) override; 45 void ResetDisplayCount() override; 46 void SetMinSize(const Dimension& minSize) override; 47 void SetShowIndicator(bool showIndicator) override; 48 void SetIndicatorType(SwiperIndicatorType indicatorType) override; 49 void SetIsIndicatorCustomSize(bool isCustomSize) override; 50 void SetItemSpace(const Dimension& itemSpace) override; 51 void SetCachedCount(int32_t cachedCount) override; 52 void SetOnChange(std::function<void(const BaseEventInfo* info)>&& onChange) override; 53 void SetOnAnimationStart(AnimationStartEvent&& onAnimationStart) override; 54 void SetOnAnimationEnd(AnimationEndEvent&& onAnimationEnd) override; 55 void SetOnGestureSwipe(GestureSwipeEvent&& gestureSwipe) override; 56 57 void SetRemoteMessageEventId(RemoteCallback&& remoteCallback) override; 58 void SetOnClick( 59 std::function<void(const BaseEventInfo* info, const RefPtr<V2::InspectorFunctionImpl>& impl)>&& value) override; 60 void SetMainSwiperSizeWidth() override; 61 void SetMainSwiperSizeHeight() override; 62 void SetIndicatorStyle(const SwiperParameters& swiperParameters) override; 63 void SetDotIndicatorStyle(const SwiperParameters& swiperParameters) override; 64 void SetDigitIndicatorStyle(const SwiperDigitalParameters& swiperDigitalParameters) override; 65 void SetPreviousMargin(const Dimension& prevMargin) override; 66 void SetNextMargin(const Dimension& nextMargin) override; 67 void SetOnChangeEvent(std::function<void(const BaseEventInfo* info)>&& onChangeEvent) override; 68 void SetIndicatorIsBoolean(bool isBoolean) override; 69 void SetArrowStyle(const SwiperArrowParameters& swiperArrowParameters) override; 70 void SetDisplayArrow(bool displayArrow) override; 71 void SetHoverShow(bool hoverShow) override; 72 void SetNestedScroll(const NestedScrollOptions& nestedOpt) override; 73 void SetSwipeByGroup(bool swipeByGroup) override; 74 static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId); 75 static void SetNextMargin(FrameNode* frameNode, const Dimension& nextMargin); 76 static void SetPreviousMargin(FrameNode* frameNode, const Dimension& prevMargin); 77 static void SetIndex(FrameNode* frameNode, uint32_t index); 78 static void SetAutoPlayInterval(FrameNode* frameNode, uint32_t interval); 79 static void SetDuration(FrameNode* frameNode, uint32_t duration); 80 static void SetCachedCount(FrameNode* frameNode, int32_t cachedCount); 81 static void SetAutoPlay(FrameNode* frameNode, bool autoPlay); 82 static void SetLoop(FrameNode* frameNode, bool loop); 83 static void SetDirection(FrameNode* frameNode, Axis axis); 84 static void SetDisableSwipe(FrameNode* frameNode, bool disableSwipe); 85 static void SetItemSpace(FrameNode* frameNode, const Dimension& itemSpace); 86 static void SetDisplayMode(FrameNode* frameNode, SwiperDisplayMode displayMode); 87 static void SetEdgeEffect(FrameNode* frameNode, EdgeEffect EdgeEffect); 88 static void SetMinSize(FrameNode* frameNode, const Dimension& minSize); 89 static void SetDisplayCount(FrameNode* frameNode, int32_t displayCount); 90 static void ResetDisplayCount(FrameNode* frameNode); 91 static void SetCurve(FrameNode* frameNode, const RefPtr<Curve>& curve); 92 static void SetArrowStyle(FrameNode* frameNode, const SwiperArrowParameters& swiperArrowParameters); 93 static void SetDisplayArrow(FrameNode* frameNode, bool displayArrow); 94 static void SetHoverShow(FrameNode* frameNode, bool hoverShow); 95 static void SetShowIndicator(FrameNode* frameNode, bool showIndicator); 96 static void SetIndicatorIsBoolean(FrameNode* frameNode, bool isBoolean); 97 static void SetDigitIndicatorStyle(FrameNode* frameNode, const SwiperDigitalParameters& swiperDigitalParameters); 98 static void SetDotIndicatorStyle(FrameNode* frameNode, const SwiperParameters& swiperParameters); 99 static void SetIndicatorType(FrameNode* frameNode, SwiperIndicatorType indicatorType); 100 static void SetIsIndicatorCustomSize(FrameNode* frameNode, bool isCustomSize); 101 static void SetEnabled(FrameNode* frameNode, bool enabled); 102 }; 103 104 } // namespace OHOS::Ace::NG 105 106 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SWIPER_SWIPER_MODEL_NG_H 107