• 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/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 class CustomNodeBase;
31 
32 using NavDestinationBackButtonEvent = std::function<bool(GestureEvent&)>;
33 
34 class ACE_EXPORT NavDestinationGroupNode : public GroupNode {
DECLARE_ACE_TYPE(NavDestinationGroupNode,GroupNode)35     DECLARE_ACE_TYPE(NavDestinationGroupNode, GroupNode)
36 public:
37     NavDestinationGroupNode(const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern)
38         : GroupNode(tag, nodeId, pattern)
39     {}
40     ~NavDestinationGroupNode() override;
41     void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override;
42     void DeleteChildFromGroup(int32_t slot = DEFAULT_NODE_SLOT) override;
43     static RefPtr<NavDestinationGroupNode> GetOrCreateGroupNode(
44         const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator);
45 
SetTitleBarNode(const RefPtr<UINode> & title)46     void SetTitleBarNode(const RefPtr<UINode>& title)
47     {
48         titleBarNode_ = title;
49     }
50 
GetTitleBarNode()51     const RefPtr<UINode>& GetTitleBarNode() const
52     {
53         return titleBarNode_;
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 
SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent & backButtonEvent)66     void SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent& backButtonEvent)
67     {
68         backButtonEvent_ = backButtonEvent;
69     }
70 
GetNavDestinationBackButtonEvent()71     NavDestinationBackButtonEvent GetNavDestinationBackButtonEvent() const
72     {
73         return backButtonEvent_;
74     }
75 
76     // custom node checking
77     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(PrevTitleIsCustom, bool);
OnPrevTitleIsCustomUpdate(bool value)78     void OnPrevTitleIsCustomUpdate(bool value) {}
79 
80     void OnAttachToMainTree(bool recursive) override;
81 
82     void OnOffscreenProcess(bool recursive) override;
83 
84     void ProcessShallowBuilder();
85 
SetTransitionType(PageTransitionType type)86     void SetTransitionType(PageTransitionType type)
87     {
88         transitionType_ = type;
89     }
90 
SetIsOnAnimation(bool isOnAnimation)91     void SetIsOnAnimation(bool isOnAnimation)
92     {
93         isOnAnimation_ = isOnAnimation;
94     }
95 
IsOnAnimation()96     bool IsOnAnimation() const
97     {
98         return isOnAnimation_;
99     }
100 
GetTransitionType()101     PageTransitionType GetTransitionType() const
102     {
103         return transitionType_;
104     }
105 
106     RefPtr<CustomNodeBase> GetNavDestinationCustomNode();
107 
SetNavDestinationMode(NavDestinationMode mode)108     void SetNavDestinationMode(NavDestinationMode mode)
109     {
110         mode_ = mode;
111     }
112 
GetNavDestinationMode()113     NavDestinationMode GetNavDestinationMode() const
114     {
115         return mode_;
116     }
117 
SetIndex(int32_t index)118     void SetIndex(int32_t index)
119     {
120         index_ = index;
121     }
122 
GetIndex()123     int32_t GetIndex() const
124     {
125         return index_;
126     }
127 
SetIsCacheNode(bool cache)128     void SetIsCacheNode(bool cache)
129     {
130         isCacheNode_ = cache;
131     }
132 
IsCacheNode()133     bool IsCacheNode() const
134     {
135         return isCacheNode_;
136     }
137 
138 private:
139     RefPtr<UINode> titleBarNode_;
140     RefPtr<UINode> contentNode_;
141     NavDestinationBackButtonEvent backButtonEvent_;
142     bool isOnAnimation_ = false;
143     int32_t index_ = -1;
144     PageTransitionType transitionType_ = PageTransitionType::NONE;
145     NavDestinationMode mode_ = NavDestinationMode::STANDARD;
146     bool isCacheNode_ = false;
147 };
148 
149 } // namespace OHOS::Ace::NG
150 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_GROUP_NODE_H
151