1 /*
2  * Copyright (c) 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_PATTERN_INDEXER_INDEXER_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_INDEXER_INDEXER_MODEL_NG_H
18 
19 #include "core/components/common/properties/decoration.h"
20 #include "core/components_ng/pattern/indexer/indexer_model.h"
21 
22 namespace OHOS::Ace::NG {
23 class ACE_EXPORT IndexerModelNG : public OHOS::Ace::IndexerModel {
24 public:
25     void Create(std::vector<std::string>& indexerArray, int32_t selectedVal) override;
26     void SetSelectedColor(const std::optional<Color>& color) override;
27     void SetColor(const std::optional<Color>& color) override;
28     void SetPopupColor(const std::optional<Color>& color) override;
29     void SetSelectedBackgroundColor(const std::optional<Color>& color) override;
30     void SetPopupBackground(const std::optional<Color>& color) override;
31     void SetUsingPopup(bool state) override;
32     void SetSelectedFont(std::optional<Dimension>& fontSize, std::optional<FontWeight>& fontWeight,
33         std::optional<std::vector<std::string>>& fontFamily, std::optional<OHOS::Ace::FontStyle>& fontStyle) override;
34     void SetPopupFont(std::optional<Dimension>& fontSize, std::optional<FontWeight>& fontWeight,
35         std::optional<std::vector<std::string>>& fontFamily, std::optional<OHOS::Ace::FontStyle>& fontStyle) override;
36     void SetFont(std::optional<Dimension>& fontSize, std::optional<FontWeight>& fontWeight,
37         std::optional<std::vector<std::string>>& fontFamily, std::optional<OHOS::Ace::FontStyle>& fontStyle) override;
38     void SetItemSize(const Dimension& value) override;
39     void SetPopupHorizontalSpace(const Dimension& value) override;
40     void SetAlignStyle(int32_t value) override;
41     void SetSelected(int32_t selected) override;
42     void SetPopupPositionX(const std::optional<Dimension>& popupPositionXOpt) override;
43     void SetPopupPositionY(const std::optional<Dimension>& popupPositionYOpt) override;
44     void SetPopupItemBackground(const std::optional<Color>& color) override;
45     void SetPopupSelectedColor(const std::optional<Color>& color) override;
46     void SetPopupUnselectedColor(const std::optional<Color>& color) override;
47     void SetFontSize(const Dimension& fontSize) override;
48     void SetFontWeight(const FontWeight weight) override;
49     void SetOnSelected(std::function<void(const int32_t selected)>&& onSelect) override;
50     void SetOnRequestPopupData(
51         std::function<std::vector<std::string>(const int32_t selected)>&& RequestPopupData) override;
52     void SetOnPopupSelected(std::function<void(const int32_t selected)>&& onPopupSelected) override;
53     void SetChangeEvent(std::function<void(const int32_t selected)>&& changeEvent) override;
54     void SetCreatChangeEvent(std::function<void(const int32_t selected)>&& changeEvent) override;
55     void SetAutoCollapse(bool state) override;
56     void SetPopupBorderRadius(const Dimension& radius) override;
57     void SetPopupItemBorderRadius(const Dimension& radius) override;
58     void SetItemBorderRadius(const Dimension& radius) override;
59     void SetIndexerBorderRadius(const Dimension& radius) override;
60     void SetPopupBackgroundBlurStyle(const BlurStyleOption& indexerBlurStyle) override;
61     void SetPopupTitleBackground(const std::optional<Color>& color) override;
62     void SetAdaptiveWidth(bool state) override;
63     void SetEnableHapticFeedback(bool state) override;
64 
65     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
66     static void SetArrayValue(FrameNode* frameNode, const std::vector<std::string>& arrayValue);
67     static void SetAdaptiveWidth(FrameNode* frameNode, bool state);
68     static void SetFontSize(FrameNode* frameNode, const Dimension& fontSize);
69     static void SetFontWeight(FrameNode* frameNode, const FontWeight weight);
70     static void SetSelectedFont(FrameNode* frameNode, std::optional<Dimension>& fontSize,
71         std::optional<FontWeight>& fontWeight, std::optional<std::vector<std::string>>& fontFamily,
72         std::optional<OHOS::Ace::FontStyle>& fontStyle);
73     static void SetPopupFont(FrameNode* frameNode, std::optional<Dimension>& fontSize,
74         std::optional<FontWeight>& fontWeight, std::optional<std::vector<std::string>>& fontFamily,
75         std::optional<OHOS::Ace::FontStyle>& fontStyle);
76     static void SetFont(FrameNode* frameNode, std::optional<Dimension>& fontSize, std::optional<FontWeight>& fontWeight,
77         std::optional<std::vector<std::string>>& fontFamily, std::optional<OHOS::Ace::FontStyle>& fontStyle);
78     static void SetPopupUnselectedColor(FrameNode* frameNode, const std::optional<Color>& color);
79     static void SetPopupItemBackground(FrameNode* frameNode, const std::optional<Color>& color);
80     static void SetColor(FrameNode* frameNode, const std::optional<Color>& color);
81     static void SetPopupColor(FrameNode* frameNode, const std::optional<Color>& color);
82     static void SetSelectedColor(FrameNode* frameNode, const std::optional<Color>& color);
83     static void SetPopupBackground(FrameNode* frameNode, const std::optional<Color>& color);
84     static void SetSelectedBackgroundColor(FrameNode* frameNode, const std::optional<Color>& color);
85     static void SetPopupSelectedColor(FrameNode* frameNode, const std::optional<Color>& color);
86     static void SetAlignStyle(FrameNode* frameNode, int32_t value);
87     static void SetPopupHorizontalSpace(FrameNode* frameNode, const Dimension& popupHorizontalSpace);
88     static void SetUsingPopup(FrameNode* frameNode, bool state);
89     static void SetSelected(FrameNode* frameNode, int32_t selected);
90     static void SetItemSize(FrameNode* frameNode, const Dimension& value);
91     static void SetPopupPositionX(FrameNode* frameNode, const std::optional<Dimension>& popupPositionXOpt);
92     static void SetPopupPositionY(FrameNode* frameNode, const std::optional<Dimension>& popupPositionYOpt);
93     static void SetPopupBorderRadius(FrameNode* frameNode, const Dimension& radius);
94     static void SetPopupItemBorderRadius(FrameNode* frameNode, const Dimension& radius);
95     static void SetItemBorderRadius(FrameNode* frameNode, const Dimension& radius);
96     static void SetIndexerBorderRadius(FrameNode* frameNode, const Dimension& radius);
97     static void SetPopupBackgroundBlurStyle(FrameNode* frameNode, const BlurStyleOption& indexerBlurStyle);
98     static void SetPopupTitleBackground(FrameNode* frameNode, const std::optional<Color>& color);
99     static void SetAutoCollapse(FrameNode* frameNode, bool autoCollapse);
100     static void SetEnableHapticFeedback(FrameNode* frameNode, bool state);
101     static void SetOnSelected(FrameNode* frameNode,
102         std::function<void(const int32_t selected)>&& onSelect);
103     static void SetOnRequestPopupData(FrameNode* frameNode,
104         std::function<std::vector<std::string>(const int32_t selected)>&& RequestPopupData);
105     static void SetOnPopupSelected(FrameNode* frameNode,
106         std::function<void(const int32_t selected)>&& onPopupSelected);
107     static void SetChangeEvent(FrameNode* frameNode, std::function<void(const int32_t selected)>&& changeEvent);
108     static void SetCreatChangeEvent(FrameNode* frameNode, std::function<void(const int32_t selected)>&& changeEvent);
109 };
110 } // namespace OHOS::Ace::NG
111 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_INDEXER_INDEXER_MODEL_NG_H
112