• 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_NAVIGATION_NAVIGATION_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_PATTERN_H
18 
19 #include "base/memory/referenced.h"
20 #include "base/system_bar/system_bar_style.h"
21 #include "core/components_ng/base/ui_node.h"
22 #include "core/components_ng/pattern/navigation/custom_safe_area_expander.h"
23 #include "core/components_ng/pattern/navigation/inner_navigation_controller.h"
24 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
25 #include "core/components_ng/pattern/navigation/navigation_event_hub.h"
26 #include "core/components_ng/pattern/navigation/navigation_group_node.h"
27 #include "core/components_ng/pattern/navigation/navigation_layout_algorithm.h"
28 #include "core/components_ng/pattern/navigation/navigation_layout_property.h"
29 #include "core/components_ng/pattern/navigation/navigation_stack.h"
30 #include "core/components_ng/pattern/navigation/title_bar_layout_property.h"
31 #include "core/components_ng/pattern/navigation/title_bar_node.h"
32 #include "core/components_ng/pattern/navigation/navigation_transition_proxy.h"
33 #include "core/components_ng/pattern/navrouter/navdestination_group_node.h"
34 #include "core/components_ng/pattern/pattern.h"
35 
36 namespace OHOS::Ace::NG {
37 
38 using namespace Framework;
39 using OnNavigationAnimation = std::function<NavigationTransition(RefPtr<NavDestinationContext>,
40         RefPtr<NavDestinationContext>, NavigationOperation)>;
41 class NavigationPattern : public Pattern, public IAvoidInfoListener, public CustomSafeAreaExpander {
42     DECLARE_ACE_TYPE(NavigationPattern, Pattern, IAvoidInfoListener, CustomSafeAreaExpander);
43 
44 public:
45     NavigationPattern();
46     ~NavigationPattern() override = default;
47 
IsAtomicNode()48     bool IsAtomicNode() const override
49     {
50         return false;
51     }
52 
CreateLayoutProperty()53     RefPtr<LayoutProperty> CreateLayoutProperty() override
54     {
55         return MakeRefPtr<NavigationLayoutProperty>();
56     }
57 
CreateEventHub()58     RefPtr<EventHub> CreateEventHub() override
59     {
60         return MakeRefPtr<NavigationEventHub>();
61     }
62 
CreateLayoutAlgorithm()63     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
64     {
65         auto layoutAlgorithm = MakeRefPtr<NavigationLayoutAlgorithm>();
66         layoutAlgorithm->SetRealNavBarWidth(realNavBarWidth_);
67         layoutAlgorithm->SetIfNeedInit(ifNeedInit_);
68         return layoutAlgorithm;
69     }
70 
71     void OnAttachToFrameNode() override;
72     void OnDetachFromFrameNode(FrameNode* frameNode) override;
73     void OnModifyDone() override;
74     void OnWindowHide() override;
75     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
76     void BeforeSyncGeometryProperties(const DirtySwapConfig& /* config */) override;
77     void UpdateColorModeForNodes(const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath);
78 
79     void OnLanguageConfigurationUpdate() override;
80 
GetFocusPattern()81     FocusPattern GetFocusPattern() const override
82     {
83         return { FocusType::SCOPE, true };
84     }
85 
GetScopeFocusAlgorithm()86     ScopeFocusAlgorithm GetScopeFocusAlgorithm() override
87     {
88         return { false, true, ScopeType::FLEX };
89     }
90 
SetNavDestination(std::function<void (std::string)> && builder)91     void SetNavDestination(std::function<void(std::string)>&& builder)
92     {
93         builder_ = std::move(builder);
94     }
95 
GetNavigationMode()96     NavigationMode GetNavigationMode() const
97     {
98         return navigationMode_;
99     }
100 
SetNavigationMode(NavigationMode navigationMode)101     void SetNavigationMode(NavigationMode navigationMode)
102     {
103         navigationMode_ = navigationMode;
104     }
105 
106     bool JudgeFoldStateChangeAndUpdateState();
107 
108     void SetNavigationStack(const RefPtr<NavigationStack>& navigationStack);
109 
GetNavigationStack()110     const RefPtr<NavigationStack>& GetNavigationStack()
111     {
112         return navigationStack_;
113     }
114 
115     // use for navRouter case
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode)116     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode)
117     {
118         addByNavRouter_ = true;
119         navigationStack_->Add(name, navDestinationNode);
120     }
121 
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode,NavRouteMode mode)122     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode, NavRouteMode mode)
123     {
124         addByNavRouter_ = true;
125         navigationStack_->Add(name, navDestinationNode, mode);
126     }
127 
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode,NavRouteMode mode,const RefPtr<RouteInfo> & routeInfo)128     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode, NavRouteMode mode,
129         const RefPtr<RouteInfo>& routeInfo)
130     {
131         addByNavRouter_ = true;
132         navigationStack_->Add(name, navDestinationNode, mode, routeInfo);
133     }
134 
GetNavDestinationNode(const std::string & name)135     RefPtr<UINode> GetNavDestinationNode(const std::string& name)
136     {
137         RefPtr<UINode> uiNode;
138         int32_t index;
139         navigationStack_->Get(name, uiNode, index);
140         return uiNode;
141     }
142 
GetNavDestinationNode()143     RefPtr<UINode> GetNavDestinationNode()
144     {
145         // get NavDestinationNode from the stack top
146         return navigationStack_->Get();
147     }
148 
GetPreNavDestination(const std::string & name,const RefPtr<UINode> & navDestinationNode)149     RefPtr<UINode> GetPreNavDestination(const std::string& name, const RefPtr<UINode>& navDestinationNode)
150     {
151         return navigationStack_->GetPre(name, navDestinationNode);
152     }
153 
GetAllNavDestinationNodes()154     const std::vector<std::pair<std::string, RefPtr<UINode>>>& GetAllNavDestinationNodes()
155     {
156         return navigationStack_->GetAllNavDestinationNodes();
157     }
158 
RemoveIfNeeded(const std::string & name,const RefPtr<UINode> & navDestinationNode)159     void RemoveIfNeeded(const std::string& name, const RefPtr<UINode>& navDestinationNode)
160     {
161         navigationStack_->Remove(name, navDestinationNode);
162     }
163 
RemoveNavDestination()164     void RemoveNavDestination()
165     {
166         navigationStack_->Remove();
167     }
168 
169     void InitDividerMouseEvent(const RefPtr<InputEventHub>& inputHub);
170 
CleanStack()171     void CleanStack()
172     {
173         navigationStack_->RemoveAll();
174     }
175 
UpdateAnimatedValue(bool animated)176     void UpdateAnimatedValue(bool animated)
177     {
178         navigationStack_->UpdateAnimatedValue(animated);
179     }
180 
SetNavigationStackProvided(bool provided)181     void SetNavigationStackProvided(bool provided)
182     {
183         navigationStackProvided_ = provided;
184     }
185 
GetNavigationStackProvided()186     bool GetNavigationStackProvided() const
187     {
188         return navigationStackProvided_;
189     }
190 
SetNavBarVisibilityChange(bool isChange)191     void SetNavBarVisibilityChange(bool isChange)
192     {
193         navBarVisibilityChange_ = isChange;
194     }
195 
GetNavBarVisibilityChange()196     bool GetNavBarVisibilityChange() const
197     {
198         return navBarVisibilityChange_;
199     }
200 
201     void OnVisibleChange(bool isVisible) override;
202 
203     void OnColorConfigurationUpdate() override;
204 
205     bool OnThemeScopeUpdate(int32_t themeScopeId) override;
206 
207     void AddDragBarHotZoneRect();
208 
GetMinNavBarWidthValue()209     Dimension GetMinNavBarWidthValue() const
210     {
211         return minNavBarWidthValue_;
212     }
SetMinNavBarWidthValue(Dimension minNavBarWidthValue)213     void SetMinNavBarWidthValue(Dimension minNavBarWidthValue)
214     {
215         minNavBarWidthValue_ = minNavBarWidthValue;
216     }
217 
GetMaxNavBarWidthValue()218     Dimension GetMaxNavBarWidthValue() const
219     {
220         return maxNavBarWidthValue_;
221     }
SetMaxNavBarWidthValue(Dimension maxNavBarWidthValue)222     void SetMaxNavBarWidthValue(Dimension maxNavBarWidthValue)
223     {
224         maxNavBarWidthValue_ = maxNavBarWidthValue;
225     }
226 
GetMinContentWidthValue()227     Dimension GetMinContentWidthValue() const
228     {
229         return minContentWidthValue_;
230     }
231 
SetMinContentWidthValue(Dimension minContentWidthValue)232     void SetMinContentWidthValue(Dimension minContentWidthValue)
233     {
234         minContentWidthValue_ = minContentWidthValue;
235     }
236 
GetUserSetNavBarRangeFlag()237     bool GetUserSetNavBarRangeFlag() const
238     {
239         return userSetNavBarRangeFlag_;
240     }
241 
SetUserSetNavBarRangeFlag(bool userSetNavBarRangeFlag)242     void SetUserSetNavBarRangeFlag(bool userSetNavBarRangeFlag)
243     {
244         userSetNavBarRangeFlag_ = userSetNavBarRangeFlag;
245     }
246 
GetUserSetMinContentFlag()247     bool GetUserSetMinContentFlag() const
248     {
249         return userSetMinContentFlag_;
250     }
251 
SetUserSetMinContentFlag(bool userSetMinContentFlag)252     void SetUserSetMinContentFlag(bool userSetMinContentFlag)
253     {
254         userSetMinContentFlag_ = userSetMinContentFlag;
255     }
256 
GetUserSetNavBarWidthFlag()257     bool GetUserSetNavBarWidthFlag() const
258     {
259         return userSetNavBarWidthFlag_;
260     }
261 
SetUserSetNavBarWidthFlag(bool userSetNavBarWidthFlag)262     void SetUserSetNavBarWidthFlag(bool userSetNavBarWidthFlag)
263     {
264         userSetNavBarWidthFlag_ = userSetNavBarWidthFlag;
265     }
266 
SetInitNavBarWidth(const Dimension & initNavBarWidth)267     void SetInitNavBarWidth(const Dimension& initNavBarWidth)
268     {
269         realNavBarWidth_ = static_cast<float>(initNavBarWidth.ConvertToPx());
270         initNavBarWidthValue_ = initNavBarWidth;
271     }
272 
GetInitNavBarWidth()273     Dimension GetInitNavBarWidth() const
274     {
275         return initNavBarWidthValue_;
276     }
277 
SetIfNeedInit(bool ifNeedInit)278     void SetIfNeedInit(bool ifNeedInit)
279     {
280         ifNeedInit_ = ifNeedInit;
281     }
282 
283     void UpdateContextRect(
284         const RefPtr<NavDestinationGroupNode>& curDestination, const RefPtr<NavigationGroupNode>& navigation);
285 
GetNavigationModeChange()286     bool GetNavigationModeChange() const
287     {
288         return navigationModeChange_;
289     }
290 
SetNavigationModeChange(bool modeChange)291     void SetNavigationModeChange(bool modeChange)
292     {
293         navigationModeChange_ = modeChange;
294     }
295 
AddOnStateChangeItem(int32_t nodeId,std::function<void (bool)> callback)296     void AddOnStateChangeItem(int32_t nodeId, std::function<void(bool)> callback)
297     {
298         onStateChangeMap_.emplace(nodeId, callback);
299     }
300 
DeleteOnStateChangeItem(int32_t nodeId)301     void DeleteOnStateChangeItem(int32_t nodeId)
302     {
303         onStateChangeMap_.erase(nodeId);
304     }
305 
GetNavigationController()306     const std::shared_ptr<NavigationController>& GetNavigationController() const
307     {
308         return navigationController_;
309     }
310 
GetOnStateChangeMap()311     const std::map<int32_t, std::function<void(bool)>>& GetOnStateChangeMap()
312     {
313         return onStateChangeMap_;
314     }
315 
316     void OnNavigationModeChange(bool modeChange);
317 
318     void OnNavBarStateChange(bool modeChange);
319 
320     static void FireNavigationChange(const RefPtr<UINode>& node, bool isShow, bool isFirst);
321 
322     static void FireNavigationLifecycle(const RefPtr<UINode>& node, NavDestinationLifecycle lifecycle,
323         NavDestinationActiveReason reason = NavDestinationActiveReason::TRANSITION);
324 
325     static void FireNavigationInner(const RefPtr<UINode>& node, bool isShow);
326 
327     static void FireNavigationStateChange(const RefPtr<UINode>& node, bool isShow);
328 
329     static void FireNavigationLifecycleChange(const RefPtr<UINode>& node, NavDestinationLifecycle lifecycle);
330 
331     static bool CheckParentDestinationIsOnhide(const RefPtr<NavDestinationGroupNode>& destinationNode);
332     static bool CheckDestinationIsPush(const RefPtr<NavDestinationGroupNode>& destinationNode);
333     static void NotifyPerfMonitorPageMsg(const std::string& pageName);
334 
335     bool CheckParentDestinationInactive();
336 
337     void FireOnActiveLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination,
338         NavDestinationActiveReason reason);
339 
340     void FireOnInactiveLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination,
341         NavDestinationActiveReason reason);
342 
343     void FireOnShowLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination);
344 
345     // type: will_show + on_show, will_hide + on_hide, hide, show, willShow, willHide
346     void NotifyDialogChange(NavDestinationLifecycle lifecycle, bool isFromStandard);
347     void NotifyPageHide(const std::string& pageName);
348     void CheckContentNeedMeasure(const RefPtr<FrameNode>& node);
349     void DumpInfo() override;
350     void DumpInfo(std::unique_ptr<JsonValue>& json) override;
DumpSimplifyInfo(std::shared_ptr<JsonValue> & json)351     void DumpSimplifyInfo(std::shared_ptr<JsonValue>& json) override {}
SetIsCustomAnimation(bool isCustom)352     void SetIsCustomAnimation(bool isCustom)
353     {
354         isCustomAnimation_ = isCustom;
355     }
356 
SetNavigationTransition(const OnNavigationAnimation navigationAnimation)357     void SetNavigationTransition(const OnNavigationAnimation navigationAnimation)
358     {
359         auto currentProxy = GetTopNavigationProxy();
360         if (currentProxy && !currentProxy->GetIsFinished()) {
361             TAG_LOGI(AceLogTag::ACE_NAVIGATION, "not support to update callback during animation");
362             return;
363         }
364         onTransition_ = std::move(navigationAnimation);
365     }
366 
NeedSyncWithJsStackMarked()367     bool NeedSyncWithJsStackMarked() const
368     {
369         return needSyncWithJsStack_;
370     }
371 
MarkNeedSyncWithJsStack()372     void MarkNeedSyncWithJsStack()
373     {
374         needSyncWithJsStack_ = true;
375     }
376 
377     void SyncWithJsStackIfNeeded();
378 
379     void AttachNavigationStackToParent();
380     void DetachNavigationStackFromParent();
381 
382     void AddToDumpManager();
383     void RemoveFromDumpManager();
384 
385     void NotifyDestinationLifecycle(const RefPtr<UINode>& destinationNode, NavDestinationLifecycle lifecycle,
386         NavDestinationActiveReason reason = NavDestinationActiveReason::TRANSITION);
387     void AbortAnimation(RefPtr<NavigationGroupNode>& hostNode);
388 
SetParentCustomNode(const RefPtr<UINode> & parentNode)389     void SetParentCustomNode(const RefPtr<UINode>& parentNode)
390     {
391         parentNode_ = parentNode;
392     }
393 
GetParentCustomNode()394     WeakPtr<UINode> GetParentCustomNode() const
395     {
396         return parentNode_;
397     }
398 
399     void SetSystemBarStyle(const RefPtr<SystemBarStyle>& style);
400 
401     void OnAttachToMainTree() override;
402     void OnDetachFromMainTree() override;
403 
IsFullPageNavigation()404     bool IsFullPageNavigation() const
405     {
406         return isFullPageNavigation_;
407     }
408 
409     bool IsTopNavDestination(const RefPtr<UINode>& node) const;
410     void TryRestoreSystemBarStyle(const RefPtr<WindowManager>& windowManager);
411 
IsFinishInteractiveAnimation()412     bool IsFinishInteractiveAnimation() const
413     {
414         return isFinishInteractiveAnimation_;
415     }
416 
GetTopNavigationProxy()417     const RefPtr<NavigationTransitionProxy> GetTopNavigationProxy() const
418     {
419         return proxyList_.empty() ? nullptr : proxyList_.back();
420     }
421 
422     RefPtr<NavigationTransitionProxy> GetProxyById(uint64_t id) const;
423 
424     void RemoveProxyById(uint64_t id);
425 
IsCurTopNewInstance()426     bool IsCurTopNewInstance() const
427     {
428         return isCurTopNewInstance_;
429     }
430 
GetAllNavDestinationNodesPrev()431     const std::vector<std::pair<std::string, WeakPtr<UINode>>>& GetAllNavDestinationNodesPrev()
432     {
433         return navigationStack_->GetAllNavDestinationNodesPrev();
434     }
435 
GetIsPreForceSetList()436     bool GetIsPreForceSetList()
437     {
438         return navigationStack_->GetIsPreForceSetList();
439     }
440 
441     void DialogAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
442         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage, bool isNeedVisible);
443 
444     bool IsLastStdChange();
445     void ReplaceAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
446         const RefPtr<NavDestinationGroupNode>& newTopNavDestination);
447     void TransitionWithDialogAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
448         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
449     void FollowStdNavdestinationAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
450     const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
451     bool FindInCurStack(const RefPtr<FrameNode>& navDestinationNode);
452 
453     std::unique_ptr<JsonValue> GetNavdestinationJsonArray();
454     std::unique_ptr<JsonValue> GetTopNavdestinationJson(bool needParam);
455     RefPtr<NavigationPattern> GetParentNavigationPattern();
456     void RestoreJsStackIfNeeded();
457 
GetNavBasePageNode()458     RefPtr<FrameNode> GetNavBasePageNode() const
459     {
460         return pageNode_.Upgrade();
461     }
462 
463     RefPtr<FrameNode> GetDragBarNode() const;
464     void BuildDragBar();
465     void InitDragBarEvent();
466     void ClearDragBarEvent();
467     void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub);
468     void HandleTouchEvent(const TouchEventInfo& info);
469     void HandleTouchDown();
470     void HandleTouchUp();
471     void ClearRecoveryList();
472 
SetEnableDragBar(bool enabled)473     void SetEnableDragBar(bool enabled)
474     {
475         enableDragBar_ = enabled;
476     }
477 
GetEnableDragBar()478     bool GetEnableDragBar() const
479     {
480         return enableDragBar_;
481     }
482 
SetNavigationSize(const SizeF & size)483     void SetNavigationSize(const SizeF& size)
484     {
485         navigationSize_ = size;
486     }
GetNavigationSize()487     const SizeF& GetNavigationSize() const
488     {
489         return navigationSize_;
490     }
491 
GetIsInDividerDrag()492     bool GetIsInDividerDrag() const
493     {
494         return isInDividerDrag_;
495     }
496 
497     void SetPageViewportConfig(const RefPtr<PageViewportConfig>& config) override;
498     bool IsPageLevelConfigEnabled(bool considerSize = true);
499     void OnStartOneTransitionAnimation();
500     void OnFinishOneTransitionAnimation();
501     bool HandleIntent(bool needTransition);
502 
InitToolBarManager()503     void InitToolBarManager()
504     {
505         if (!toolbarManager_) {
506             auto pipeline = GetHost()->GetContext();
507             CHECK_NULL_VOID(pipeline);
508             toolbarManager_ = pipeline->GetToolbarManager();
509             UpdateNavigationStatus();
510         }
511     }
512 
GetToolBarManager()513     RefPtr<ToolbarManager> GetToolBarManager()
514     {
515         return toolbarManager_;
516     }
517 
IsForceSplitSuccess()518     bool IsForceSplitSuccess() const
519     {
520         return forceSplitSuccess_;
521     }
SetForceSplitUseNavBar(bool use)522     void SetForceSplitUseNavBar(bool use)
523     {
524         forceSplitUseNavBar_ = use;
525     }
IsForceSplitUseNavBar()526     bool IsForceSplitUseNavBar() const
527     {
528         return forceSplitUseNavBar_;
529     }
530 
IsHomeNodeTouched()531     bool IsHomeNodeTouched() const
532     {
533         return homeNodeTouched_;
534     }
SetIsHomeNodeTouched(bool touch)535     void SetIsHomeNodeTouched(bool touch)
536     {
537         homeNodeTouched_ = touch;
538     }
539     bool IsForceSplitSupported(const RefPtr<PipelineContext>& context);
540 
GetHomeNode()541     RefPtr<NavDestinationGroupNode> GetHomeNode() const
542     {
543         return homeNode_.Upgrade();
544     }
GetPrimaryNodes()545     const std::vector<WeakPtr<NavDestinationGroupNode>>& GetPrimaryNodes() const
546     {
547         return primaryNodes_;
548     }
BackupPrimaryNodes()549     void BackupPrimaryNodes()
550     {
551         prePrimaryNodes_ = primaryNodes_;
552     }
SetPrimaryNodesToBeRemoved(std::vector<RefPtr<NavDestinationGroupNode>> && primaryNodesToBeRemoved)553     void SetPrimaryNodesToBeRemoved(std::vector<RefPtr<NavDestinationGroupNode>>&& primaryNodesToBeRemoved)
554     {
555         primaryNodesToBeRemoved_ = primaryNodesToBeRemoved;
556     }
557     void RecognizeHomePageIfNeeded();
558     void TryForceSplitIfNeeded(const SizeF& frameSize);
559     void SwapNavDestinationAndProxyNode(bool needFireLifecycle);
560     bool IsPrimaryNode(const RefPtr<NavDestinationGroupNode>& destNode) const;
561     // Only used for the toolbar in 'container_modal' component
562     void SetToolbarManagerNavigationMode(NavigationMode mode);
563 
SetIsTargetForceSplitNav(bool isTargetForceSplitNav)564     void SetIsTargetForceSplitNav(bool isTargetForceSplitNav)
565     {
566         isTargetForceSplitNav_ = isTargetForceSplitNav;
567     }
GetIsTargetForceSplitNav()568     bool GetIsTargetForceSplitNav() const
569     {
570         return isTargetForceSplitNav_;
571     }
572 
573     bool CreateHomeDestination(RefPtr<UINode>& customNode, RefPtr<NavDestinationGroupNode>& homeDest);
574     bool IsHomeDestinationVisible();
575     void FireHomeDestinationLifeCycleIfNeeded(NavDestinationLifecycle lifecycle, bool isModeChange = false,
576         NavDestinationActiveReason reason = NavDestinationActiveReason::TRANSITION);
577 
578     bool CheckNeedCreate(int32_t index);
579 private:
580     void ClearNavigationCustomTransition();
581     bool IsDestinationNeedHideInPush(
582         const RefPtr<NavigationGroupNode>& hostNode, const RefPtr<NavDestinationGroupNode>& destNode) const;
583     void FirePrimaryNodesLifecycle(NavDestinationLifecycle lifecycle);
584     void FireOnNewParam(const RefPtr<UINode>& uiNode);
585     void UpdateIsFullPageNavigation(const RefPtr<FrameNode>& host);
586     void UpdateSystemBarStyleOnFullPageStateChange(const RefPtr<WindowManager>& windowManager);
587     void UpdateSystemBarStyleOnTopNavPathChange(
588         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath);
589     void UpdateSystemBarStyleWithTopNavPath(const RefPtr<WindowManager>& windowManager,
590         const std::optional<std::pair<std::string, RefPtr<UINode>>>& topNavPath);
591     void UpdateSystemBarStyleOnPageVisibilityChange(bool show);
592     void RegisterPageVisibilityChangeCallback();
593     bool ApplyTopNavPathSystemBarStyleOrRestore(const RefPtr<WindowManager>& windowManager,
594         const std::optional<std::pair<std::string, RefPtr<UINode>>>& topNavPath);
595     void InitPageNode(const RefPtr<FrameNode>& host);
596     void InitFoldState();
597 
598     void CheckTopNavPathChange(const std::optional<std::pair<std::string, RefPtr<UINode>>>& preTopNavPath,
599         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath,
600         int32_t preLastStandardIndex = -1);
601     void TransitionWithAnimation(RefPtr<NavDestinationGroupNode> preTopNavDestination,
602         RefPtr<NavDestinationGroupNode> newTopNavDestination, bool isPopPage, bool isNeedVisible = false);
603     bool TriggerCustomAnimation(RefPtr<NavDestinationGroupNode> preTopNavDestination,
604         RefPtr<NavDestinationGroupNode> newTopNavDestination, bool isPopPage);
605 
606     void OnCustomAnimationFinish(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
607         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
608     void TransitionWithOutAnimation(RefPtr<NavDestinationGroupNode> preTopNavDestination,
609         RefPtr<NavDestinationGroupNode> newTopNavDestination, bool isPopPage, bool needVisible = false);
610     NavigationTransition ExecuteTransition(const RefPtr<NavDestinationGroupNode>& preTopDestination,
611         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
612     RefPtr<RenderContext> GetTitleBarRenderContext();
613     void DoAnimation(NavigationMode usrNavigationMode);
614     void RecoveryToLastStack(const RefPtr<NavDestinationGroupNode>& preTopDestination,
615         const RefPtr<NavDestinationGroupNode>& newTopDestination);
616     bool GenerateUINodeByIndex(int32_t index, RefPtr<UINode>& node);
617     int32_t GenerateUINodeFromRecovery(int32_t lastStandardIndex, NavPathList& navPathList);
618     void DoNavbarHideAnimation(const RefPtr<NavigationGroupNode>& hostNode);
619     RefPtr<FrameNode> GetNavigationNode() const;
620     RefPtr<FrameNode> GetNavBarNode() const;
621     RefPtr<FrameNode> GetNavBarNodeOrHomeDestination() const;
622     RefPtr<FrameNode> GetContentNode() const;
623     RefPtr<FrameNode> GetDividerNode() const;
624     void FireInterceptionEvent(bool isBefore,
625         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath);
626     void InitDividerPanEvent(const RefPtr<GestureEventHub>& gestureHub);
627     void InitDragBarPanEvent(const RefPtr<GestureEventHub>& gestureHub);
628     void HandleDragStart();
629     void HandleDragUpdate(float xOffset);
630     void HandleDragEnd();
631     void OnHover(bool isHover);
GetPaintRectHeight(const RefPtr<FrameNode> & node)632     float GetPaintRectHeight(const RefPtr<FrameNode>& node)
633     {
634         auto renderContext = node->GetRenderContext();
635         CHECK_NULL_RETURN(renderContext, 0.0f);
636         return renderContext->GetPaintRectWithoutTransform().Height();
637     }
638     void AddDividerHotZoneRect();
639     void RangeCalculation(
640         const RefPtr<NavigationGroupNode>& hostNode, const RefPtr<NavigationLayoutProperty>& navigationLayoutProperty);
641     bool UpdateTitleModeChangeEventHub(const RefPtr<NavigationGroupNode>& hostNode);
642     void FireNavBarWidthChangeEvent(const RefPtr<LayoutWrapper>& layoutWrapper);
643     void NotifyPageShow(const std::string& pageName);
644     void ProcessPageShowEvent();
645     int32_t FireNavDestinationStateChange(NavDestinationLifecycle lifecycle);
646     void UpdatePreNavDesZIndex(const RefPtr<FrameNode> &preTopNavDestination,
647         const RefPtr<FrameNode> &newTopNavDestination, int32_t preLastStandardIndex = -1);
648     void UpdateNavPathList();
649     void RefreshNavDestination();
650     void DealTransitionVisibility(const RefPtr<FrameNode>& node, bool isVisible, bool isNavBarOrHomeDestination);
651     void NotifyNavDestinationSwitch(RefPtr<NavDestinationContext> from,
652         RefPtr<NavDestinationContext> to, NavigationOperation operation);
653 
654     void UpdateIsAnimation(const std::optional<std::pair<std::string, RefPtr<UINode>>>& preTopNavPath);
655     void StartTransition(const RefPtr<NavDestinationGroupNode>& preDestination,
656     const RefPtr<NavDestinationGroupNode>& topDestination,
657     bool isAnimated, bool isPopPage, bool isNeedVisible = false);
658     void ProcessAutoSave(const RefPtr<FrameNode>& node);
659 
660     void FireShowAndHideLifecycle(const RefPtr<NavDestinationGroupNode>& preDestination,
661         const RefPtr<NavDestinationGroupNode>& topDestination, bool isPopPage, bool isAnimated);
662     void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override;
663     void RefreshFocusToDestination();
664 
665     void PerformanceEventReport(int32_t nodeCount, int32_t depth, const std::string& navDestinationName);
666     void StartDefaultAnimation(const RefPtr<NavDestinationGroupNode>& preTopDestination,
667         const RefPtr<NavDestinationGroupNode>& topDestination,
668         bool isPopPage, bool isNeedInVisible = false);
669     bool ExecuteAddAnimation(RefPtr<NavDestinationGroupNode> preTopDestination,
670         RefPtr<NavDestinationGroupNode> topDestination,
671         bool isPopPage, const RefPtr<NavigationTransitionProxy>& proxy,
672         NavigationTransition navigationTransition);
673     bool GetIsFocusable(const RefPtr<FrameNode>& frameNode);
674     void GetOrCreateNavDestinationUINode();
675     void CloseLongPressDialog();
676 
677     void CreateDragBarNode(const RefPtr<NavigationGroupNode>& navigationGroupNode);
678     RefPtr<FrameNode> CreateDragBarItemNode();
679     void SetMouseStyle(MouseFormat format);
680 
681     void OnAvoidInfoChange(const ContainerModalAvoidInfo& info) override;
682     void RegisterAvoidInfoChangeListener(const RefPtr<FrameNode>& hostNode);
683     void UnregisterAvoidInfoChangeListener(const RefPtr<FrameNode>& hostNode);
684     virtual void MarkAllNavDestinationDirtyIfNeeded(const RefPtr<FrameNode>& hostNode, bool skipCheck = false);
685     void UpdateToobarFocusColor();
686     void GenerateLastStandardPage(NavPathList& navPathList);
687     RefPtr<UINode> FindNavDestinationNodeInPreList(const uint64_t navDestinationId) const;
688     bool IsStandardPage(const RefPtr<UINode>& uiNode) const;
689     void UpdateDividerBackgroundColor();
690     void SetNavigationWidthToolBarManager(float navBarWidth, float navDestWidth, float dividerWidth);
691     void NavigationModifyDoneToolBarManager();
692     void UpdateNavigationStatus();
693     void UpdateChildLayoutPolicy();
694 
695     void GetVisibleNodes(bool isPre, std::vector<WeakPtr<NavDestinationNodeBase>>& visibleNodes);
696     void UpdatePageViewportConfigIfNeeded(const RefPtr<NavDestinationGroupNode>& preTopDestination,
697         const RefPtr<NavDestinationGroupNode>& topDestination);
698     std::optional<int32_t> CalcRotateAngleWithDisplayOrientation(
699         DisplayOrientation curOri, DisplayOrientation targetOri);
700     void GetAllNodes(
701         std::vector<WeakPtr<NavDestinationNodeBase>>& invisibleNodes,
702         std::vector<WeakPtr<NavDestinationNodeBase>>& visibleNodes);
703     void OnAllTransitionAnimationFinish();
704     void UpdatePageLevelConfigForSizeChanged();
705     void UpdatePageLevelConfigForSizeChangedWhenNoAnimation();
706     RefPtr<NavDestinationNodeBase> GetLastStandardNodeOrNavBar();
707     void HideSystemBarIfNeeded();
708     void ShowOrRestoreSystemBarIfNeeded();
709     bool IsEquivalentToStackMode();
710     void ClearPageAndNavigationConfig();
711     bool CustomizeExpandSafeArea() override;
712 
IsEnableMatchParent()713     bool IsEnableMatchParent() override
714     {
715         return false;
716     }
717 
718     void RegisterForceSplitListener(PipelineContext* context, int32_t nodeId);
719     void UnregisterForceSplitListener(PipelineContext* context, int32_t nodeId);
720     void ProcessSameTopNavPath();
721     void GetNavDestinationsAndHomeIndex(
722         std::vector<RefPtr<NavDestinationGroupNode>>& destNodes, std::optional<int32_t>& homeIndex);
723     void AdjustPrimaryAndProxyNodePosition(
724         const RefPtr<FrameNode>& primaryContentNode, const RefPtr<FrameNode>& navContentNode,
725         const std::vector<RefPtr<NavDestinationGroupNode>>& destNodes, std::optional<int32_t> homeIndex);
726     void UpdatePrimaryContentIfNeeded(const RefPtr<FrameNode>& primaryContentNode,
727         const std::vector<WeakPtr<NavDestinationGroupNode>>& prePrimaryNodes);
728     void AdjustNodeForDestForceSplit(bool needTriggerLifecycle);
729     void AdjustNodeForNonDestForceSplit(bool needTriggerLifecycle);
730     void ClearSecondaryNodesIfNeeded(NavPathList&& preList);
731 
732     bool IsTopPrimaryNode(const RefPtr<NavDestinationGroupNode>& node);
733 
734     int32_t GetFirstNewDestinationIndex(const NavPathList& preList, const NavPathList& curList);
735 
736     void AppendFilterNodesFromHideNodes(std::set<RefPtr<NavDestinationGroupNode>>& filterNodes);
737     void AppendFilterNodesForWillHideLifecycle(std::set<RefPtr<NavDestinationGroupNode>>& filterNodes);
738     void NotifyPrePrimaryNodesOnWillHide(std::set<RefPtr<NavDestinationGroupNode>>&& filterNodes);
739     void AppendFilterNodesForWillShowLifecycle(std::set<RefPtr<NavDestinationGroupNode>>& filterNodes);
740     void NotifyCurPrimaryNodesOnWillShow(std::set<RefPtr<NavDestinationGroupNode>>&& filterNodes);
741 
742     void FirePreTopPrimaryNodeInactiveIfNeeded();
743     void FirePrePrimaryNodesOnHide();
744     void FirePrePrimaryNodesOnWillDisappear(std::set<RefPtr<NavDestinationGroupNode>>&& filterNodes);
745     void FirePrimaryNodesOnShowAndActive();
746     void RemoveRedundantPrimaryNavDestination();
747     static bool CheckIfNeedHideOrShowPrimaryNodes(const RefPtr<NavigationPattern>& pattern, int32_t lastStandardIndex);
748     bool CheckIfNoNeedAnimationForForceSplit(const RefPtr<NavDestinationGroupNode>& preDestination,
749         const RefPtr<NavDestinationGroupNode>& topDestination);
750     bool ShouldFireHomeDestiationLifecycle(NavDestinationLifecycle lifecycle,
751         const RefPtr<NavDestinationPattern>& destPattern, int32_t lastStandardIndex,
752         int32_t curStackSize, bool isModeChange);
753     void FireHomeDestinationLifecycleForTransition(NavDestinationLifecycle lifecycle);
754     RefPtr<NavDestinationContext> GetHomeDestinationContext();
755     bool GetHomeDestinationName(const RefPtr<FrameNode>& hostNode, std::string& name);
756 
757     //-------for force split------- begin------
758     bool IsNavBarValid();
759     bool IsHideNavBarInForceSplitModeNeeded();
760     void ReplaceNodeWithProxyNodeIfNeeded(
761         const RefPtr<FrameNode>& navContentNode, const RefPtr<NavDestinationGroupNode>& node);
762     void RestoreNodeFromProxyNodeIfNeeded(const RefPtr<FrameNode>& primaryContentNode,
763         const RefPtr<FrameNode>& navContentNode, const RefPtr<NavDestinationGroupNode>& node);
764     void ReorderPrimaryNodes(const RefPtr<FrameNode>& primaryContentNode,
765         const std::vector<WeakPtr<NavDestinationGroupNode>>& nodes);
766     //-------for force split------- end  ------
767 
768     NavigationMode navigationMode_ = NavigationMode::AUTO;
769     std::function<void(std::string)> builder_;
770     RefPtr<NavigationStack> navigationStack_;
771     RefPtr<InputEvent> hoverEvent_;
772     RefPtr<PanEvent> panEvent_;
773     RefPtr<PanEvent> dragBarPanEvent_;
774     RefPtr<ToolbarManager> toolbarManager_;
775     std::vector<RefPtr<NavigationTransitionProxy>> proxyList_;
776     RectF dragRect_;
777     RectF dragBarRect_;
778     WeakPtr<FrameNode> pageNode_;
779     bool isFullPageNavigation_ = false;
780     std::optional<RefPtr<SystemBarStyle>> backupStyle_;
781     std::optional<RefPtr<SystemBarStyle>> currStyle_;
782     bool addByNavRouter_ = false;
783     bool ifNeedInit_ = true;
784     float preNavBarWidth_ = 0.0f;
785     float realNavBarWidth_ = DEFAULT_NAV_BAR_WIDTH.ConvertToPx();
786     float initNavBarWidth_ = DEFAULT_NAV_BAR_WIDTH.ConvertToPx();
787     float realDividerWidth_ = 2.0f;
788     bool navigationStackProvided_ = false;
789     bool navBarVisibilityChange_ = false;
790     bool userSetNavBarRangeFlag_ = false;
791     bool userSetMinContentFlag_ = false;
792     bool userSetNavBarWidthFlag_ = false;
793     bool isChanged_ = false; // check navigation top page is change
794     Dimension initNavBarWidthValue_ = DEFAULT_NAV_BAR_WIDTH;
795     Dimension minNavBarWidthValue_ = 0.0_vp;
796     Dimension maxNavBarWidthValue_ = 0.0_vp;
797     Dimension minContentWidthValue_ = 0.0_vp;
798     NavigationTitleMode titleMode_ = NavigationTitleMode::FREE;
799     bool navigationModeChange_ = false;
800     bool isCustomAnimation_ = false; // custom animation
801     bool isInDividerDrag_ = false;
802     bool isDividerDraggable_ = true;
803     bool isAnimated_ = false;
804 #if defined(ENABLE_NAV_SPLIT_MODE)
805     bool isBackPage_ = false;
806 #endif
807     FoldStatus currentFoldStatus_ = FoldStatus::UNKNOWN;  // only used for mode-switch animation
808     bool isReplace_ = false;
809     bool isFinishInteractiveAnimation_ = true;
810     int32_t lastPreIndex_ = false;
811     std::shared_ptr<NavigationController> navigationController_;
812     std::map<int32_t, std::function<void(bool)>> onStateChangeMap_;
813     OnNavigationAnimation onTransition_;
814     bool needSyncWithJsStack_ = false;
815     std::optional<std::pair<std::string, RefPtr<UINode>>> preTopNavPath_;
816     RefPtr<NavDestinationContext> preContext_;
817     WeakPtr<UINode> parentNode_;
818     int32_t preStackSize_ = 0;
819     bool isRightToLeft_ = false;
820     bool isCurTopNewInstance_ = false;
821     RefPtr<TouchEventImpl> touchEvent_;
822     bool enableDragBar_ = false;
823     SizeF navigationSize_;
824     std::optional<NavBarPosition> preNavBarPosition_;
825     bool topFromSingletonMoved_ = false;
826 
827     std::vector<WeakPtr<NavDestinationNodeBase>> preVisibleNodes_;
828     int32_t runningTransitionCount_ = 0;
829     bool isTransitionAnimationAborted_ = false;
830 
831     //-------for force split------- begin------
832     bool forceSplitSuccess_ = false;
833     bool forceSplitUseNavBar_ = false;
834     bool homeNodeTouched_ = false;
835     bool navBarIsHome_ = false;
836     bool isTargetForceSplitNav_ = false;
837     WeakPtr<NavDestinationGroupNode> homeNode_;
838     std::vector<WeakPtr<NavDestinationGroupNode>> prePrimaryNodes_;
839     std::vector<WeakPtr<NavDestinationGroupNode>> primaryNodes_;
840     std::vector<RefPtr<NavDestinationGroupNode>> primaryNodesToBeRemoved_;
841     //-------for force split------- end  ------
842 };
843 
844 } // namespace OHOS::Ace::NG
845 
846 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_PATTERN_H
847