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_NAVROUTER_NAVDESTINATION_GROUP_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_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/navigation_declaration.h" 25 #include "core/components_ng/property/property.h" 26 #include "core/pipeline/base/element_register.h" 27 28 namespace OHOS::Ace::NG { 29 30 using NavDestinationBackButtonEvent = std::function<void(GestureEvent&)>; 31 32 class ACE_EXPORT NavDestinationGroupNode : public GroupNode { DECLARE_ACE_TYPE(NavDestinationGroupNode,GroupNode)33 DECLARE_ACE_TYPE(NavDestinationGroupNode, GroupNode) 34 public: 35 NavDestinationGroupNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern) 36 : GroupNode(tag, nodeId, pattern) {} 37 ~NavDestinationGroupNode() override = default; 38 void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override; 39 void DeleteChildFromGroup(int32_t slot = DEFAULT_NODE_SLOT) override; 40 static RefPtr<NavDestinationGroupNode> GetOrCreateGroupNode( 41 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 42 SetTitle(const RefPtr<UINode> & title)43 void SetTitle(const RefPtr<UINode>& title) 44 { 45 title_ = title; 46 } 47 GetTitle()48 const RefPtr<UINode>& GetTitle() const 49 { 50 return title_; 51 } 52 SetSubtitle(const RefPtr<UINode> & subtitle)53 void SetSubtitle(const RefPtr<UINode>& subtitle) 54 { 55 subtitle_ = subtitle; 56 } 57 GetSubtitle()58 const RefPtr<UINode>& GetSubtitle() const 59 { 60 return subtitle_; 61 } 62 SetTitleBarNode(const RefPtr<UINode> & title)63 void SetTitleBarNode(const RefPtr<UINode>& title) 64 { 65 titleBarNode_ = title; 66 } 67 GetTitleBarNode()68 const RefPtr<UINode>& GetTitleBarNode() const 69 { 70 return titleBarNode_; 71 } 72 SetContentNode(const RefPtr<UINode> & contentNode)73 void SetContentNode(const RefPtr<UINode>& contentNode) 74 { 75 contentNode_ = contentNode; 76 } 77 GetContentNode()78 const RefPtr<UINode>& GetContentNode() const 79 { 80 return contentNode_; 81 } 82 SetPreNode(const RefPtr<UINode> & preNode)83 void SetPreNode(const RefPtr<UINode>& preNode) 84 { 85 preNode_ = preNode; 86 } 87 GetPreNode()88 const RefPtr<UINode>& GetPreNode() const 89 { 90 return preNode_; 91 } 92 SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent & backButtonEvent)93 void SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent& backButtonEvent) 94 { 95 backButtonEvent_ = backButtonEvent; 96 } 97 GetNavDestinationBackButtonEvent()98 NavDestinationBackButtonEvent GetNavDestinationBackButtonEvent() const 99 { 100 return backButtonEvent_; 101 } 102 103 // custom node checking 104 ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(PrevTitleIsCustom, bool); OnPrevTitleIsCustomUpdate(bool value)105 void OnPrevTitleIsCustomUpdate(bool value) {} 106 107 // node operation related 108 ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(TitleNodeOperation, ChildNodeOperation); OnTitleNodeOperationUpdate(ChildNodeOperation value)109 void OnTitleNodeOperationUpdate(ChildNodeOperation value) {} 110 ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(SubtitleNodeOperation, ChildNodeOperation); OnSubtitleNodeOperationUpdate(ChildNodeOperation value)111 void OnSubtitleNodeOperationUpdate(ChildNodeOperation value) {} 112 113 void OnAttachToMainTree() override; 114 115 private: 116 RefPtr<UINode> title_; 117 RefPtr<UINode> subtitle_; 118 RefPtr<UINode> titleBarNode_; 119 RefPtr<UINode> contentNode_; 120 RefPtr<UINode> preNode_; 121 NavDestinationBackButtonEvent backButtonEvent_; 122 }; 123 124 } // namespace OHOS::Ace::NG 125 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_GROUP_NODE_H