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_GROUP_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_GROUP_NODE_H 18 19 #include <cstdint> 20 #include <list> 21 22 #include "core/components_ng/base/frame_node.h" 23 #include "core/components_ng/base/group_node.h" 24 #include "core/components_ng/pattern/navigation/bar_item_node.h" 25 #include "core/components_ng/pattern/navigation/navigation_declaration.h" 26 #include "core/components_ng/property/property.h" 27 28 namespace OHOS::Ace::NG { 29 30 class ACE_EXPORT NavigationGroupNode : public GroupNode { DECLARE_ACE_TYPE(NavigationGroupNode,GroupNode)31 DECLARE_ACE_TYPE(NavigationGroupNode, GroupNode) 32 public: 33 NavigationGroupNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern) 34 : GroupNode(tag, nodeId, pattern) 35 {} 36 ~NavigationGroupNode() override = default; 37 void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override; 38 static RefPtr<NavigationGroupNode> GetOrCreateGroupNode( 39 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 40 IsAtomicNode()41 bool IsAtomicNode() const override 42 { 43 return false; 44 } 45 SetNavBarNode(const RefPtr<UINode> & navBarNode)46 void SetNavBarNode(const RefPtr<UINode>& navBarNode) 47 { 48 navBarNode_ = navBarNode; 49 } 50 GetNavBarNode()51 const RefPtr<UINode>& GetNavBarNode() const 52 { 53 return navBarNode_; 54 } 55 SetContentNode(const RefPtr<UINode> & contentNode)56 void SetContentNode(const RefPtr<UINode>& contentNode) 57 { 58 contentNode_ = contentNode; 59 } 60 GetContentNode()61 const RefPtr<UINode>& GetContentNode() const 62 { 63 return contentNode_; 64 } 65 SetDividerNode(const RefPtr<UINode> & dividerNode)66 void SetDividerNode(const RefPtr<UINode>& dividerNode) 67 { 68 dividerNode_ = dividerNode; 69 } 70 GetDividerNode()71 const RefPtr<UINode>& GetDividerNode() const 72 { 73 return dividerNode_; 74 } 75 MarkIsFirstNavDestination(bool isFirstNavDestination)76 void MarkIsFirstNavDestination(bool isFirstNavDestination) 77 { 78 isFirstNavDestination_ = isFirstNavDestination; 79 } 80 IsFirstNavDestination()81 bool IsFirstNavDestination() const 82 { 83 return isFirstNavDestination_; 84 } 85 void ToJsonValue(std::unique_ptr<JsonValue>& json) const override; 86 private: 87 RefPtr<UINode> navBarNode_; 88 RefPtr<UINode> contentNode_; 89 RefPtr<UINode> dividerNode_; 90 bool isFirstNavDestination_ = true; 91 }; 92 93 } // namespace OHOS::Ace::NG 94 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_GROUP_NODE_H