• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TABS_TABS_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TABS_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/decoration.h"
25 #include "core/components_ng/pattern/swiper/swiper_event_hub.h"
26 #include "core/components_ng/pattern/swiper/swiper_layout_property.h"
27 #include "core/components_ng/pattern/tabs/tab_bar_layout_property.h"
28 #include "core/components_ng/pattern/tabs/tab_bar_paint_property.h"
29 #include "core/components_ng/pattern/tabs/tabs_model.h"
30 #include "core/components_ng/pattern/tabs/tabs_node.h"
31 
32 namespace OHOS::Ace::NG {
33 
34 class SwiperPaintProperty;
35 class ACE_EXPORT TabsModelNG : public OHOS::Ace::TabsModel {
36 public:
37     void Create(BarPosition barPosition, int32_t index, const RefPtr<TabController>& tabController,
38         const RefPtr<SwiperController>& swiperController) override;
39     void Pop() override;
40     void SetIndex(int32_t index) override;
41     void SetTabBarPosition(BarPosition tabBarPosition) override;
42     void SetBarBackgroundBlurStyle(BlurStyle tabBarBlurStyle) override;
43     void SetTabBarMode(TabBarMode tabBarMode) override;
44     void SetTabBarWidth(const Dimension& tabBarWidth) override;
45     void SetTabBarHeight(const Dimension& tabBarHeight) override;
46     void SetBarAdaptiveHeight(bool barAdaptiveHeight) override;
47     void SetIsVertical(bool isVertical) override;
48     void SetScrollable(bool scrollable) override;
49     void SetAnimationDuration(float duration) override;
50     void SetOnChange(std::function<void(const BaseEventInfo*)>&& onChange) override;
51     void SetOnTabBarClick(std::function<void(const BaseEventInfo*)>&& onTabBarClick) override;
52     void SetOnAnimationStart(AnimationStartEvent&& onAnimationStart) override;
53     void SetOnAnimationEnd(AnimationEndEvent&& onAnimationEnd) override;
54     void SetOnGestureSwipe(GestureSwipeEvent&& gestureSwipe) override;
55     void SetDivider(const TabsItemDivider& divider) override;
56     void SetFadingEdge(bool fadingEdge) override;
57     void SetBarOverlap(bool barOverlap) override;
58     void SetOnChangeEvent(std::function<void(const BaseEventInfo*)>&& onChangeEvent) override;
59     void SetBarBackgroundColor(const Color& backgroundColor) override;
60     void SetClipEdge(bool clipEdge) override;
61     void SetScrollableBarModeOptions(const ScrollableBarModeOptions& option) override;
62     void SetBarGridAlign(const BarGridColumnOptions& BarGridColumnOptions) override;
63     void SetIsCustomAnimation(bool isCustom) override;
64     void SetOnCustomAnimation(TabsCustomAnimationEvent&& onCustomAnimation) override;
65     void SetOnContentWillChange(std::function<bool(int32_t, int32_t)>&& callback) override;
66     static RefPtr<TabsNode> GetOrCreateTabsNode(
67         const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator);
68     static void SetTabBarMode(FrameNode* frameNode, TabBarMode tabBarMode);
69     static void SetBarGridAlign(FrameNode* frameNode, const BarGridColumnOptions& BarGridColumnOptions);
70     static void SetDivider(FrameNode* frameNode, const TabsItemDivider& divider);
71     static void SetFadingEdge(FrameNode* frameNode, bool fadingEdge);
72     static void SetBarBackgroundColor(FrameNode* frameNode, const Color& backgroundColor);
73     static void SetBarOverlap(FrameNode* frameNode, bool barOverlap);
74     static void SetIsVertical(FrameNode* frameNode, bool isVertical);
75     static void SetTabBarPosition(FrameNode* frameNode, BarPosition tabBarPosition);
76     static void SetScrollable(FrameNode* frameNode, bool scrollable);
77     static void SetTabBarWidth(FrameNode* frameNode, const Dimension& tabBarWidth);
78     static void SetTabBarHeight(FrameNode* frameNode, const Dimension& tabBarHeight);
79     static void SetAnimationDuration(FrameNode* frameNode, float duration);
80     static void SetBarAdaptiveHeight(FrameNode* frameNode, bool barAdaptiveHeight);
81     static void SetScrollableBarModeOptions(FrameNode* frameNode, const ScrollableBarModeOptions& option);
82     static void SetClipEdge(FrameNode* frameNode, bool clipEdge);
83 
84 private:
85     static RefPtr<TabBarLayoutProperty> GetTabBarLayoutProperty();
86     static RefPtr<TabBarPaintProperty> GetTabBarPaintProperty();
87     static RefPtr<SwiperLayoutProperty> GetSwiperLayoutProperty();
88     static RefPtr<SwiperPaintProperty> GetSwiperPaintProperty();
89     static RefPtr<TabBarLayoutProperty> GetTabBarLayoutProperty(FrameNode* frameNode);
90     static RefPtr<TabBarPaintProperty> GetTabBarPaintProperty(FrameNode* frameNode);
91     static RefPtr<SwiperLayoutProperty> GetSwiperLayoutProperty(FrameNode* frameNode);
92     static RefPtr<SwiperPaintProperty> GetSwiperPaintProperty(FrameNode* frameNode);
93 };
94 
95 } // namespace OHOS::Ace::NG
96 
97 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TABS_TABS_MODEL_NG_H
98