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_NAVROUTER_GROUP_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVROUTER_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/property/property.h" 25 26 namespace OHOS::Ace::NG { 27 28 class ACE_EXPORT NavRouterGroupNode : public GroupNode { DECLARE_ACE_TYPE(NavRouterGroupNode,GroupNode)29 DECLARE_ACE_TYPE(NavRouterGroupNode, GroupNode) 30 public: 31 NavRouterGroupNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern) 32 : GroupNode(tag, nodeId, pattern) 33 {} 34 ~NavRouterGroupNode() override = default; 35 void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override; 36 void DeleteChildFromGroup(int32_t slot = DEFAULT_NODE_SLOT) override; 37 static RefPtr<NavRouterGroupNode> GetOrCreateGroupNode( 38 const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator); 39 IsAtomicNode()40 bool IsAtomicNode() const override 41 { 42 return false; 43 } 44 SetNavDestinationNode(const RefPtr<UINode> & navDestinationNode)45 void SetNavDestinationNode(const RefPtr<UINode>& navDestinationNode) 46 { 47 navDestinationNode_ = navDestinationNode; 48 } 49 GetNavDestinationNode()50 const RefPtr<UINode>& GetNavDestinationNode() const 51 { 52 return navDestinationNode_; 53 } 54 55 void OnDetachFromMainTree() override; 56 void OnAttachToMainTree() override; 57 58 private: 59 void AddNavDestinationToNavigation(const RefPtr<UINode>& parent); 60 void SetDestinationChangeEvent(const RefPtr<UINode>& parent); 61 void InitNavigationContent(const RefPtr<UINode>& parent); 62 void SetBackButtonEvent(const RefPtr<UINode>& parent); 63 void SetOnStateChangeFalse( 64 const RefPtr<UINode>& preNavDestination, const RefPtr<UINode>& navigation, bool isBackButton = false); 65 void BackToNavBar(const RefPtr<UINode>& parent); 66 void BackToPreNavDestination(const RefPtr<UINode>& preNavDestination, const RefPtr<UINode>& navigation); 67 void AddBackButtonIconToNavDestination(const RefPtr<UINode>& parent); 68 bool CleanNodeInNavigation(const RefPtr<UINode>& parent); 69 void SetBackButtonVisible(const RefPtr<UINode>& navDestination); 70 71 RefPtr<UINode> navDestinationNode_; 72 }; 73 74 } // namespace OHOS::Ace::NG 75 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVROUTER_GROUP_NODE_H 76