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_V2_INDEXER_POPUP_LIST_ITEM_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INDEXER_POPUP_LIST_ITEM_COMPONENT_H
18 
19 #include <string>
20 
21 #include "base/utils/macros.h"
22 #include "base/utils/noncopyable.h"
23 #include "core/components/box/box_component.h"
24 #include "core/components/text/text_component.h"
25 #include "core/components_v2/common/common_def.h"
26 #include "core/pipeline/base/component_group.h"
27 
28 namespace OHOS::Ace::V2 {
29 inline constexpr double POPUP_BOX_SIZE = 56.0;
30 inline constexpr double POPUP_FONT_SIZE = 24.0;
31 inline constexpr double POPUP_ZERO_SIZE = 0.0;
32 inline constexpr uint32_t POPUP_BG_COLOR = 0xFFF1F3F5;
33 inline constexpr uint32_t POPUP_FONT_COLOR = 0xFF254FF7;
34 inline constexpr double POPUP_BG_OPACITY = 0.9;
35 
36 class ACE_EXPORT PopupListItemComponent : public ComponentGroup {
37     DECLARE_ACE_TYPE(V2::PopupListItemComponent, ComponentGroup);
38 
39 public:
40     PopupListItemComponent() = default;
PopupListItemComponent(const std::string & label)41     explicit PopupListItemComponent(const std::string& label) {
42         label_ = label;
43         BuildItem();
44     };
45     ~PopupListItemComponent() = default;
46 
47     RefPtr<Element> CreateElement() override;
48     RefPtr<RenderNode> CreateRenderNode() override;
49 
50 protected:
51     void BuildItem();
52 
53 private:
54     RefPtr<BoxComponent> boxComponent_;
55     RefPtr<Decoration> boxDecoration_;
56     RefPtr<TextComponent> boxText_;
57     TextStyle textStyle_;
58 
59     std::string label_ = "";
60 
61     ACE_DISALLOW_COPY_AND_MOVE(PopupListItemComponent);
62 };
63 } // namespace OHOS::Ace::V2
64 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INDEXER_POPUP_LIST_ITEM_COMPONENT_H
65