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); BarItemNode(const std::string & tag,int32_t nodeId,const RefPtr<Pattern> & pattern)31 BarItemNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern) 32 : FrameNode(tag, nodeId, pattern), isMoreItemNode_(false) 33 {} 34 ~BarItemNode() override = default; 35 36 static RefPtr<BarItemNode> GetOrCreateBarItemNode( 37 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); IsAtomicNode()38 bool IsAtomicNode() const override 39 { 40 return false; 41 } 42 SetTextNode(const RefPtr<UINode> & text)43 void SetTextNode(const RefPtr<UINode>& text) 44 { 45 text_ = text; 46 } 47 GetTextNode()48 const RefPtr<UINode>& GetTextNode() const 49 { 50 return text_; 51 } 52 SetIconNode(const RefPtr<UINode> & icon)53 void SetIconNode(const RefPtr<UINode>& icon) 54 { 55 icon_ = icon; 56 } 57 GetIconNode()58 const RefPtr<UINode>& GetIconNode() const 59 { 60 return icon_; 61 } 62 SetBarItemUsedInToolbarConfiguration(bool isInToolbar)63 void SetBarItemUsedInToolbarConfiguration(bool isInToolbar) 64 { 65 isInToolbar_ = isInToolbar; 66 } 67 IsBarItemUsedInToolbarConfiguration()68 bool IsBarItemUsedInToolbarConfiguration() const 69 { 70 return isInToolbar_; 71 } 72 SetIsMoreItemNode(bool isMoreItemNode)73 void SetIsMoreItemNode(bool isMoreItemNode) 74 { 75 isMoreItemNode_ = isMoreItemNode; 76 } 77 IsMoreItemNode()78 bool IsMoreItemNode() const 79 { 80 return isMoreItemNode_; 81 } 82 83 ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(IconSrc, std::string); OnIconSrcUpdate(const std::string & value)84 void OnIconSrcUpdate(const std::string& value) {} 85 ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(Text, std::string); OnTextUpdate(const std::string & value)86 void OnTextUpdate(const std::string& value) {} 87 88 private: 89 RefPtr<UINode> text_; 90 RefPtr<UINode> icon_; 91 bool isInToolbar_ = false; 92 bool isMoreItemNode_ = false; 93 }; 94 95 } // namespace OHOS::Ace::NG 96 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_BAR_ITEM_NODE_H