• 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_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/navdestination_node_base.h"
25 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
26 #include "core/components_ng/property/property.h"
27 #include "core/pipeline/base/element_register.h"
28 
29 namespace OHOS::Ace::NG {
30 
31 class CustomNodeBase;
32 class NavigationTransitionProxy;
33 
34 using NavDestinationBackButtonEvent = std::function<bool(GestureEvent&)>;
35 
36 class ACE_EXPORT NavDestinationGroupNode : public NavDestinationNodeBase {
DECLARE_ACE_TYPE(NavDestinationGroupNode,NavDestinationNodeBase)37     DECLARE_ACE_TYPE(NavDestinationGroupNode, NavDestinationNodeBase)
38 public:
39     NavDestinationGroupNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern)
40         : NavDestinationNodeBase(tag, nodeId, pattern)
41     {
42         isNewToolbar_ = true;
43     }
44     ~NavDestinationGroupNode() override;
45     void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override;
46     void DeleteChildFromGroup(int32_t slot = DEFAULT_NODE_SLOT) override;
47     static RefPtr<NavDestinationGroupNode> GetOrCreateGroupNode(
48         const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator);
49     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
50 
SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent & backButtonEvent)51     void SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent& backButtonEvent)
52     {
53         backButtonEvent_ = backButtonEvent;
54     }
55 
GetNavDestinationBackButtonEvent()56     NavDestinationBackButtonEvent GetNavDestinationBackButtonEvent() const
57     {
58         return backButtonEvent_;
59     }
60 
61     void OnAttachToMainTree(bool recursive) override;
62 
63     void OnOffscreenProcess(bool recursive) override;
64 
65     void ProcessShallowBuilder();
66 
SetIsOnAnimation(bool isOnAnimation)67     void SetIsOnAnimation(bool isOnAnimation)
68     {
69         isOnAnimation_ = isOnAnimation;
70     }
71 
IsOnAnimation()72     bool IsOnAnimation() const
73     {
74         return isOnAnimation_;
75     }
76 
77     RefPtr<CustomNodeBase> GetNavDestinationCustomNode();
78 
SetNavDestinationCustomNode(WeakPtr<CustomNodeBase> customNode)79     void SetNavDestinationCustomNode(WeakPtr<CustomNodeBase> customNode)
80     {
81         customNode_ = customNode;
82     }
83 
84     void SetNavDestinationMode(NavDestinationMode mode);
85 
GetNavDestinationMode()86     NavDestinationMode GetNavDestinationMode() const
87     {
88         return mode_;
89     }
90 
SetIndex(int32_t index)91     void SetIndex(int32_t index)
92     {
93         index_ = index;
94     }
95 
GetIndex()96     int32_t GetIndex() const
97     {
98         return index_;
99     }
100 
SetIsCacheNode(bool cache)101     void SetIsCacheNode(bool cache)
102     {
103         isCacheNode_ = cache;
104     }
105 
IsCacheNode()106     bool IsCacheNode() const
107     {
108         return isCacheNode_;
109     }
110 
SetIsAnimated(const bool isAnimated)111     void SetIsAnimated(const bool isAnimated)
112     {
113         isAnimated_ = isAnimated;
114     }
115 
GetIsAnimated()116     bool GetIsAnimated() const
117     {
118         return isAnimated_;
119     }
120 
SetCanReused(bool canReused)121     void SetCanReused(bool canReused)
122     {
123         canReused_ = canReused;
124     }
125 
GetCanReused()126     bool GetCanReused() const
127     {
128         return canReused_;
129     }
130 
SetNavDestinationPathInfo(const std::string & moduleName,const std::string & pagePath)131     void SetNavDestinationPathInfo(const std::string& moduleName, const std::string& pagePath)
132     {
133         navDestinationPathInfo_ = pagePath;
134         navDestinationModuleName_ = moduleName;
135     }
136 
GetNavDestinationPathInfo()137     const std::string& GetNavDestinationPathInfo() const
138     {
139         return navDestinationPathInfo_;
140     }
141 
SetNeedRemoveInPush(bool need)142     void SetNeedRemoveInPush(bool need)
143     {
144         needRemoveInPush_ = need;
145     }
146 
NeedRemoveInPush()147     bool NeedRemoveInPush() const
148     {
149         return needRemoveInPush_;
150     }
151 
152     void InitSystemTransitionPush(bool transitionIn);
153     void StartSystemTransitionPush(bool transitionIn);
154     void SystemTransitionPushCallback(bool transitionIn);
155     void InitSystemTransitionPop(bool isTransitionIn);
156     void StartSystemTransitionPop(bool transitionIn);
157     bool SystemTransitionPopCallback(bool transitionIn);
158     void InitDialogTransition(bool isZeroY);
159     bool IsNodeInvisible(const RefPtr<FrameNode>& node) override;
160 
161     void UpdateTextNodeListAsRenderGroup(bool isPopPage, const RefPtr<NavigationTransitionProxy>& proxy);
162     void ReleaseTextNodeList();
163     void CollectTextNodeAsRenderGroup(bool isPopPage);
164 
165     void CleanContent();
166 private:
167     WeakPtr<CustomNodeBase> customNode_; // nearest parent customNode
168     NavDestinationBackButtonEvent backButtonEvent_;
169     bool isOnAnimation_ = false;
170     int32_t index_ = -1;
171     NavDestinationMode mode_ = NavDestinationMode::STANDARD;
172     bool isCacheNode_ = false;
173     bool isAnimated_ = true;
174     bool canReused_ = true;
175     std::string navDestinationPathInfo_;
176     std::string navDestinationModuleName_;
177     bool needRemoveInPush_ = false;
178     std::list<WeakPtr<UINode>> textNodeList_;
179 };
180 
181 } // namespace OHOS::Ace::NG
182 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_GROUP_NODE_H
183