1 /*
2  * Copyright (c) 2021-2022 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_PICKER_PICKER_OPTION_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_OPTION_COMPONENT_H
18 
19 #include "core/components/box/box_component.h"
20 #include "core/components/picker/picker_theme.h"
21 #include "core/components/text/text_component.h"
22 #include "core/pipeline/base/sole_child_component.h"
23 
24 namespace OHOS::Ace {
25 
26 class PickerOptionComponent : public SoleChildComponent {
27     DECLARE_ACE_TYPE(PickerOptionComponent, SoleChildComponent);
28 
29 public:
30     PickerOptionComponent();
31     ~PickerOptionComponent() override = default;
32 
33     RefPtr<RenderNode> CreateRenderNode() override;
34     RefPtr<Element> CreateElement() override;
35 
36     void Initialize();
37 
GetSelected()38     bool GetSelected() const
39     {
40         return selected_;
41     }
SetSelected(bool value)42     void SetSelected(bool value)
43     {
44         selected_ = value;
45     }
46 
GetAutoLayout()47     bool GetAutoLayout() const
48     {
49         return autoLayout_;
50     }
SetAutoLayout(bool value)51     void SetAutoLayout(bool value)
52     {
53         autoLayout_ = value;
54     }
55 
GetText()56     const std::string& GetText() const
57     {
58         return text_;
59     }
SetText(const std::string & value)60     void SetText(const std::string& value)
61     {
62         text_ = value;
63     }
64 
GetTheme()65     const RefPtr<PickerTheme>& GetTheme() const
66     {
67         return theme_;
68     }
SetTheme(const RefPtr<PickerTheme> & value)69     void SetTheme(const RefPtr<PickerTheme>& value)
70     {
71         theme_ = value;
72     }
73 
GetIndex()74     uint32_t GetIndex() const
75     {
76         return index_;
77     }
SetIndex(uint32_t value)78     void SetIndex(uint32_t value)
79     {
80         index_ = value;
81     }
82 
GetTextComponent()83     const RefPtr<TextComponent>& GetTextComponent()
84     {
85         return textComponent_;
86     }
87 
GetBoxComponent()88     const RefPtr<BoxComponent>& GetBoxComponent()
89     {
90         return boxComponent_;
91     }
92 
GetAlignTop()93     bool GetAlignTop() const
94     {
95         return alignTop_;
96     }
SetAlignTop(bool value)97     void SetAlignTop(bool value)
98     {
99         alignTop_ = value;
100     }
101 
GetAlignBottom()102     bool GetAlignBottom() const
103     {
104         return alignBottom_;
105     }
SetAlignBottom(bool value)106     void SetAlignBottom(bool value)
107     {
108         alignBottom_ = value;
109     }
110 
GetDisappear()111     bool GetDisappear() const
112     {
113         return disappear_;
114     }
SetDisappear(bool value)115     void SetDisappear(bool value)
116     {
117         disappear_ = value;
118     }
119 
GetFixHeight()120     const Dimension& GetFixHeight() const
121     {
122         return fixHeight_;
123     }
SetFixHeight(const Dimension & value)124     void SetFixHeight(const Dimension& value)
125     {
126         fixHeight_ = value;
127     }
128 
GetDefaultHeight()129     bool GetDefaultHeight() const
130     {
131         return defaultHeight_;
132     }
133 
SetDefaultHeight(bool value)134     void SetDefaultHeight(bool value)
135     {
136         defaultHeight_ = value;
137     }
138 private:
139     bool selected_ = false;
140     bool autoLayout_ = false;
141     bool alignTop_ = false;
142     bool alignBottom_ = false;
143     bool disappear_ = false;
144     std::string text_;
145     uint32_t index_ = 0;
146     RefPtr<PickerTheme> theme_;
147     Dimension fixHeight_;
148     bool defaultHeight_ = false;
149 
150     RefPtr<BoxComponent> boxComponent_;
151     RefPtr<TextComponent> textComponent_;
152 };
153 
154 } // namespace OHOS::Ace
155 
156 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_OPTION_COMPONENT_H
157