• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_NG_PATTERNS_NAVIGATION_BAR_ITEM_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_BAR_ITEM_NODE_H
18 
19 #include <cstdint>
20 #include <optional>
21 
22 #include "core/components_ng/base/frame_node.h"
23 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
24 
25 namespace OHOS::Ace::NG {
26 
27 class ACE_EXPORT BarItemNode : public FrameNode {
28     DECLARE_ACE_TYPE(BarItemNode, FrameNode)
29 public:
30     BarItemNode(const std::string& tag, int32_t nodeId);
31     ~BarItemNode() override = default;
32 
IsAtomicNode()33     bool IsAtomicNode() const override
34     {
35         return false;
36     }
37 
SetTextNode(const RefPtr<UINode> & text)38     void SetTextNode(const RefPtr<UINode>& text)
39     {
40         text_ = text;
41     }
42 
GetTextNode()43     const RefPtr<UINode>& GetTextNode() const
44     {
45         return text_;
46     }
47 
SetIconNode(const RefPtr<UINode> & icon)48     void SetIconNode(const RefPtr<UINode>& icon)
49     {
50         icon_ = icon;
51     }
52 
GetIconNode()53     const RefPtr<UINode>& GetIconNode() const
54     {
55         return icon_;
56     }
57 
SetBarItemUsedInToolbarConfiguration(bool isInToolbar)58     void SetBarItemUsedInToolbarConfiguration(bool isInToolbar)
59     {
60         isInToolbar_ = isInToolbar;
61     }
62 
IsBarItemUsedInToolbarConfiguration()63     bool IsBarItemUsedInToolbarConfiguration() const
64     {
65         return isInToolbar_;
66     }
67 
SetIsMoreItemNode(bool isMoreItemNode)68     void SetIsMoreItemNode(bool isMoreItemNode)
69     {
70         isMoreItemNode_ = isMoreItemNode;
71     }
72 
IsMoreItemNode()73     bool IsMoreItemNode() const
74     {
75         return isMoreItemNode_;
76     }
77 
78     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(IconSrc, std::string);
OnIconSrcUpdate(const std::string & value)79     void OnIconSrcUpdate(const std::string& value) {}
80     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(Text, std::string);
OnTextUpdate(const std::string & value)81     void OnTextUpdate(const std::string& value) {}
82 
83 private:
84     RefPtr<UINode> text_;
85     RefPtr<UINode> icon_;
86     bool isInToolbar_ = false;
87     bool isMoreItemNode_ = false;
88 };
89 
90 } // namespace OHOS::Ace::NG
91 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_BAR_ITEM_NODE_H