• 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 using NavDestinationBackButtonEvent = std::function<bool(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     {}
38     ~NavDestinationGroupNode() override = default;
39     void AddChildToGroup(const RefPtr<UINode>& child, int32_t slot = DEFAULT_NODE_SLOT) override;
40     void DeleteChildFromGroup(int32_t slot = DEFAULT_NODE_SLOT) override;
41     static RefPtr<NavDestinationGroupNode> GetOrCreateGroupNode(
42         const std::string& tag, int32_t nodeId, const std::function<RefPtr<Pattern>(void)>& patternCreator);
43 
SetTitle(const RefPtr<UINode> & title)44     void SetTitle(const RefPtr<UINode>& title)
45     {
46         title_ = title;
47     }
48 
GetTitle()49     const RefPtr<UINode>& GetTitle() const
50     {
51         return title_;
52     }
53 
SetSubtitle(const RefPtr<UINode> & subtitle)54     void SetSubtitle(const RefPtr<UINode>& subtitle)
55     {
56         subtitle_ = subtitle;
57     }
58 
GetSubtitle()59     const RefPtr<UINode>& GetSubtitle() const
60     {
61         return subtitle_;
62     }
63 
SetTitleBarNode(const RefPtr<UINode> & title)64     void SetTitleBarNode(const RefPtr<UINode>& title)
65     {
66         titleBarNode_ = title;
67     }
68 
GetTitleBarNode()69     const RefPtr<UINode>& GetTitleBarNode() const
70     {
71         return titleBarNode_;
72     }
73 
SetContentNode(const RefPtr<UINode> & contentNode)74     void SetContentNode(const RefPtr<UINode>& contentNode)
75     {
76         contentNode_ = contentNode;
77     }
78 
GetContentNode()79     const RefPtr<UINode>& GetContentNode() const
80     {
81         return contentNode_;
82     }
83 
SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent & backButtonEvent)84     void SetNavDestinationBackButtonEvent(const NavDestinationBackButtonEvent& backButtonEvent)
85     {
86         backButtonEvent_ = backButtonEvent;
87     }
88 
GetNavDestinationBackButtonEvent()89     NavDestinationBackButtonEvent GetNavDestinationBackButtonEvent() const
90     {
91         return backButtonEvent_;
92     }
93 
94     // custom node checking
95     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(PrevTitleIsCustom, bool);
OnPrevTitleIsCustomUpdate(bool value)96     void OnPrevTitleIsCustomUpdate(bool value) {}
97 
98     // node operation related
99     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(TitleNodeOperation, ChildNodeOperation);
OnTitleNodeOperationUpdate(ChildNodeOperation value)100     void OnTitleNodeOperationUpdate(ChildNodeOperation value) {}
101     ACE_DEFINE_PROPERTY_ITEM_FUNC_WITHOUT_GROUP(SubtitleNodeOperation, ChildNodeOperation);
OnSubtitleNodeOperationUpdate(ChildNodeOperation value)102     void OnSubtitleNodeOperationUpdate(ChildNodeOperation value) {}
103 
104     void OnAttachToMainTree(bool recursive) override;
105 
106     void OnOffscreenProcess(bool recursive) override;
107 
108     void ProcessShallowBuilder();
109 
110     void UpdateTitleFontSize(bool showBackButton);
111 
SetTransitionType(PageTransitionType type)112     void SetTransitionType(PageTransitionType type)
113     {
114         transitionType_ = type;
115     }
116 
GetTransitionType()117     PageTransitionType GetTransitionType() const
118     {
119         return transitionType_;
120     }
121 
122 private:
123     RefPtr<UINode> title_;
124     RefPtr<UINode> subtitle_;
125     RefPtr<UINode> titleBarNode_;
126     RefPtr<UINode> contentNode_;
127     NavDestinationBackButtonEvent backButtonEvent_;
128 
129     PageTransitionType transitionType_ = PageTransitionType::NONE;
130 };
131 
132 } // namespace OHOS::Ace::NG
133 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_GROUP_NODE_H
134