• 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/inner_navigation_controller.h"
23 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
24 #include "core/components_ng/pattern/navigation/navigation_event_hub.h"
25 #include "core/components_ng/pattern/navigation/navigation_group_node.h"
26 #include "core/components_ng/pattern/navigation/navigation_layout_algorithm.h"
27 #include "core/components_ng/pattern/navigation/navigation_layout_property.h"
28 #include "core/components_ng/pattern/navigation/navigation_stack.h"
29 #include "core/components_ng/pattern/navigation/title_bar_layout_property.h"
30 #include "core/components_ng/pattern/navigation/title_bar_node.h"
31 #include "core/components_ng/pattern/navigation/navigation_transition_proxy.h"
32 #include "core/components_ng/pattern/navrouter/navdestination_group_node.h"
33 #include "core/components_ng/pattern/pattern.h"
34 
35 namespace OHOS::Ace::NG {
36 
37 using namespace Framework;
38 using OnNavigationAnimation = std::function<NavigationTransition(RefPtr<NavDestinationContext>,
39         RefPtr<NavDestinationContext>, NavigationOperation)>;
40 class NavigationPattern : public Pattern, public IAvoidInfoListener {
41     DECLARE_ACE_TYPE(NavigationPattern, Pattern, IAvoidInfoListener);
42 
43 public:
44     NavigationPattern();
45     ~NavigationPattern() override = default;
46 
IsAtomicNode()47     bool IsAtomicNode() const override
48     {
49         return false;
50     }
51 
CreateLayoutProperty()52     RefPtr<LayoutProperty> CreateLayoutProperty() override
53     {
54         return MakeRefPtr<NavigationLayoutProperty>();
55     }
56 
CreateEventHub()57     RefPtr<EventHub> CreateEventHub() override
58     {
59         return MakeRefPtr<NavigationEventHub>();
60     }
61 
CreateLayoutAlgorithm()62     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
63     {
64         auto layoutAlgorithm = MakeRefPtr<NavigationLayoutAlgorithm>();
65         layoutAlgorithm->SetRealNavBarWidth(realNavBarWidth_);
66         layoutAlgorithm->SetIfNeedInit(ifNeedInit_);
67         return layoutAlgorithm;
68     }
69 
70     void OnAttachToFrameNode() override;
71     void OnDetachFromFrameNode(FrameNode* frameNode) override;
72     void OnModifyDone() override;
73     void OnWindowHide() override;
74     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
75     void BeforeSyncGeometryProperties(const DirtySwapConfig& /* config */) override;
76 
77     void OnLanguageConfigurationUpdate() override;
78 
GetFocusPattern()79     FocusPattern GetFocusPattern() const override
80     {
81         return { FocusType::SCOPE, true };
82     }
83 
GetScopeFocusAlgorithm()84     ScopeFocusAlgorithm GetScopeFocusAlgorithm() override
85     {
86         return { false, true, ScopeType::FLEX };
87     }
88 
SetNavDestination(std::function<void (std::string)> && builder)89     void SetNavDestination(std::function<void(std::string)>&& builder)
90     {
91         builder_ = std::move(builder);
92     }
93 
GetNavigationMode()94     NavigationMode GetNavigationMode() const
95     {
96         return navigationMode_;
97     }
98 
SetNavigationMode(NavigationMode navigationMode)99     void SetNavigationMode(NavigationMode navigationMode)
100     {
101         navigationMode_ = navigationMode;
102     }
103 
104     bool JudgeFoldStateChangeAndUpdateState();
105 
106     void SetNavigationStack(const RefPtr<NavigationStack>& navigationStack);
107 
GetNavigationStack()108     const RefPtr<NavigationStack>& GetNavigationStack()
109     {
110         return navigationStack_;
111     }
112 
113     // use for navRouter case
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode)114     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode)
115     {
116         addByNavRouter_ = true;
117         navigationStack_->Add(name, navDestinationNode);
118     }
119 
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode,NavRouteMode mode)120     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode, NavRouteMode mode)
121     {
122         addByNavRouter_ = true;
123         navigationStack_->Add(name, navDestinationNode, mode);
124     }
125 
AddNavDestinationNode(const std::string & name,const RefPtr<UINode> & navDestinationNode,NavRouteMode mode,const RefPtr<RouteInfo> & routeInfo)126     void AddNavDestinationNode(const std::string& name, const RefPtr<UINode>& navDestinationNode, NavRouteMode mode,
127         const RefPtr<RouteInfo>& routeInfo)
128     {
129         addByNavRouter_ = true;
130         navigationStack_->Add(name, navDestinationNode, mode, routeInfo);
131     }
132 
GetNavDestinationNode(const std::string & name)133     RefPtr<UINode> GetNavDestinationNode(const std::string& name)
134     {
135         RefPtr<UINode> uiNode;
136         int32_t index;
137         navigationStack_->Get(name, uiNode, index);
138         return uiNode;
139     }
140 
GetNavDestinationNode()141     RefPtr<UINode> GetNavDestinationNode()
142     {
143         // get NavDestinationNode from the stack top
144         return navigationStack_->Get();
145     }
146 
GetPreNavDestination(const std::string & name,const RefPtr<UINode> & navDestinationNode)147     RefPtr<UINode> GetPreNavDestination(const std::string& name, const RefPtr<UINode>& navDestinationNode)
148     {
149         return navigationStack_->GetPre(name, navDestinationNode);
150     }
151 
GetAllNavDestinationNodes()152     const std::vector<std::pair<std::string, RefPtr<UINode>>>& GetAllNavDestinationNodes()
153     {
154         return navigationStack_->GetAllNavDestinationNodes();
155     }
156 
RemoveIfNeeded(const std::string & name,const RefPtr<UINode> & navDestinationNode)157     void RemoveIfNeeded(const std::string& name, const RefPtr<UINode>& navDestinationNode)
158     {
159         navigationStack_->Remove(name, navDestinationNode);
160     }
161 
RemoveNavDestination()162     void RemoveNavDestination()
163     {
164         navigationStack_->Remove();
165     }
166 
167     void InitDividerMouseEvent(const RefPtr<InputEventHub>& inputHub);
168 
CleanStack()169     void CleanStack()
170     {
171         navigationStack_->RemoveAll();
172     }
173 
UpdateAnimatedValue(bool animated)174     void UpdateAnimatedValue(bool animated)
175     {
176         navigationStack_->UpdateAnimatedValue(animated);
177     }
178 
SetNavigationStackProvided(bool provided)179     void SetNavigationStackProvided(bool provided)
180     {
181         navigationStackProvided_ = provided;
182     }
183 
GetNavigationStackProvided()184     bool GetNavigationStackProvided() const
185     {
186         return navigationStackProvided_;
187     }
188 
SetNavBarVisibilityChange(bool isChange)189     void SetNavBarVisibilityChange(bool isChange)
190     {
191         navBarVisibilityChange_ = isChange;
192     }
193 
GetNavBarVisibilityChange()194     bool GetNavBarVisibilityChange() const
195     {
196         return navBarVisibilityChange_;
197     }
198 
199     void OnVisibleChange(bool isVisible) override;
200 
201     void OnColorConfigurationUpdate() override;
202 
203     bool OnThemeScopeUpdate(int32_t themeScopeId) override;
204 
205     void AddDragBarHotZoneRect();
206 
GetMinNavBarWidthValue()207     Dimension GetMinNavBarWidthValue() const
208     {
209         return minNavBarWidthValue_;
210     }
SetMinNavBarWidthValue(Dimension minNavBarWidthValue)211     void SetMinNavBarWidthValue(Dimension minNavBarWidthValue)
212     {
213         minNavBarWidthValue_ = minNavBarWidthValue;
214     }
215 
GetMaxNavBarWidthValue()216     Dimension GetMaxNavBarWidthValue() const
217     {
218         return maxNavBarWidthValue_;
219     }
SetMaxNavBarWidthValue(Dimension maxNavBarWidthValue)220     void SetMaxNavBarWidthValue(Dimension maxNavBarWidthValue)
221     {
222         maxNavBarWidthValue_ = maxNavBarWidthValue;
223     }
224 
GetMinContentWidthValue()225     Dimension GetMinContentWidthValue() const
226     {
227         return minContentWidthValue_;
228     }
229 
SetMinContentWidthValue(Dimension minContentWidthValue)230     void SetMinContentWidthValue(Dimension minContentWidthValue)
231     {
232         minContentWidthValue_ = minContentWidthValue;
233     }
234 
GetUserSetNavBarRangeFlag()235     bool GetUserSetNavBarRangeFlag() const
236     {
237         return userSetNavBarRangeFlag_;
238     }
239 
SetUserSetNavBarRangeFlag(bool userSetNavBarRangeFlag)240     void SetUserSetNavBarRangeFlag(bool userSetNavBarRangeFlag)
241     {
242         userSetNavBarRangeFlag_ = userSetNavBarRangeFlag;
243     }
244 
GetUserSetMinContentFlag()245     bool GetUserSetMinContentFlag() const
246     {
247         return userSetMinContentFlag_;
248     }
249 
SetUserSetMinContentFlag(bool userSetMinContentFlag)250     void SetUserSetMinContentFlag(bool userSetMinContentFlag)
251     {
252         userSetMinContentFlag_ = userSetMinContentFlag;
253     }
254 
GetUserSetNavBarWidthFlag()255     bool GetUserSetNavBarWidthFlag() const
256     {
257         return userSetNavBarWidthFlag_;
258     }
259 
SetUserSetNavBarWidthFlag(bool userSetNavBarWidthFlag)260     void SetUserSetNavBarWidthFlag(bool userSetNavBarWidthFlag)
261     {
262         userSetNavBarWidthFlag_ = userSetNavBarWidthFlag;
263     }
264 
SetInitNavBarWidth(const Dimension & initNavBarWidth)265     void SetInitNavBarWidth(const Dimension& initNavBarWidth)
266     {
267         realNavBarWidth_ = static_cast<float>(initNavBarWidth.ConvertToPx());
268         initNavBarWidthValue_ = initNavBarWidth;
269     }
270 
GetInitNavBarWidth()271     Dimension GetInitNavBarWidth() const
272     {
273         return initNavBarWidthValue_;
274     }
275 
SetIfNeedInit(bool ifNeedInit)276     void SetIfNeedInit(bool ifNeedInit)
277     {
278         ifNeedInit_ = ifNeedInit;
279     }
280 
281     void UpdateContextRect(
282         const RefPtr<NavDestinationGroupNode>& curDestination, const RefPtr<NavigationGroupNode>& navigation);
283 
GetNavigationModeChange()284     bool GetNavigationModeChange() const
285     {
286         return navigationModeChange_;
287     }
288 
SetNavigationModeChange(bool modeChange)289     void SetNavigationModeChange(bool modeChange)
290     {
291         navigationModeChange_ = modeChange;
292     }
293 
AddOnStateChangeItem(int32_t nodeId,std::function<void (bool)> callback)294     void AddOnStateChangeItem(int32_t nodeId, std::function<void(bool)> callback)
295     {
296         onStateChangeMap_.emplace(nodeId, callback);
297     }
298 
DeleteOnStateChangeItem(int32_t nodeId)299     void DeleteOnStateChangeItem(int32_t nodeId)
300     {
301         onStateChangeMap_.erase(nodeId);
302     }
303 
GetNavigationController()304     const std::shared_ptr<NavigationController>& GetNavigationController() const
305     {
306         return navigationController_;
307     }
308 
GetOnStateChangeMap()309     const std::map<int32_t, std::function<void(bool)>>& GetOnStateChangeMap()
310     {
311         return onStateChangeMap_;
312     }
313 
314     void OnNavigationModeChange(bool modeChange);
315 
316     void OnNavBarStateChange(bool modeChange);
317 
318     static void FireNavigationChange(const RefPtr<UINode>& node, bool isShow, bool isFirst);
319 
320     static void FireNavigationLifecycle(const RefPtr<UINode>& node, NavDestinationLifecycle lifecycle,
321         NavDestinationActiveReason reason = NavDestinationActiveReason::TRANSITION);
322 
323     static void FireNavigationInner(const RefPtr<UINode>& node, bool isShow);
324 
325     static void FireNavigationStateChange(const RefPtr<UINode>& node, bool isShow);
326 
327     static void FireNavigationLifecycleChange(const RefPtr<UINode>& node, NavDestinationLifecycle lifecycle);
328 
329     static bool CheckParentDestinationIsOnhide(const RefPtr<NavDestinationGroupNode>& destinationNode);
330     static bool CheckDestinationIsPush(const RefPtr<NavDestinationGroupNode>& destinationNode);
331     static void NotifyPerfMonitorPageMsg(const std::string& pageName);
332 
333     bool CheckParentDestinationInactive();
334 
335     void FireOnActiveLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination,
336         NavDestinationActiveReason reason);
337 
338     void FireOnInactiveLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination,
339         NavDestinationActiveReason reason);
340 
341     void FireOnShowLifecycle(const RefPtr<NavDestinationGroupNode>& curDestination);
342 
343     // type: will_show + on_show, will_hide + on_hide, hide, show, willShow, willHide
344     void NotifyDialogChange(NavDestinationLifecycle lifecycle, bool isFromStandard);
345     void NotifyPageHide(const std::string& pageName);
346     void CheckContentNeedMeasure(const RefPtr<FrameNode>& node);
347     void DumpInfo() override;
348     void DumpInfo(std::unique_ptr<JsonValue>& json) override;
DumpSimplifyInfo(std::unique_ptr<JsonValue> & json)349     void DumpSimplifyInfo(std::unique_ptr<JsonValue>& json) override {}
SetIsCustomAnimation(bool isCustom)350     void SetIsCustomAnimation(bool isCustom)
351     {
352         isCustomAnimation_ = isCustom;
353     }
354 
SetNavigationTransition(const OnNavigationAnimation navigationAnimation)355     void SetNavigationTransition(const OnNavigationAnimation navigationAnimation)
356     {
357         auto currentProxy = GetTopNavigationProxy();
358         if (currentProxy && !currentProxy->GetIsFinished()) {
359             TAG_LOGI(AceLogTag::ACE_NAVIGATION, "not support to update callback during animation");
360             return;
361         }
362         onTransition_ = std::move(navigationAnimation);
363     }
364 
NeedSyncWithJsStackMarked()365     bool NeedSyncWithJsStackMarked() const
366     {
367         return needSyncWithJsStack_;
368     }
369 
MarkNeedSyncWithJsStack()370     void MarkNeedSyncWithJsStack()
371     {
372         needSyncWithJsStack_ = true;
373     }
374 
375     void SyncWithJsStackIfNeeded();
376 
377     void AttachNavigationStackToParent();
378     void DetachNavigationStackFromParent();
379 
380     void AddToDumpManager();
381     void RemoveFromDumpManager();
382 
383     void NotifyDestinationLifecycle(const RefPtr<UINode>& destinationNode, NavDestinationLifecycle lifecycle,
384         NavDestinationActiveReason reason = NavDestinationActiveReason::TRANSITION);
385     void AbortAnimation(RefPtr<NavigationGroupNode>& hostNode);
386 
SetParentCustomNode(const RefPtr<UINode> & parentNode)387     void SetParentCustomNode(const RefPtr<UINode>& parentNode)
388     {
389         parentNode_ = parentNode;
390     }
391 
GetParentCustomNode()392     WeakPtr<UINode> GetParentCustomNode() const
393     {
394         return parentNode_;
395     }
396 
397     void SetSystemBarStyle(const RefPtr<SystemBarStyle>& style);
398 
399     void OnAttachToMainTree() override;
400     void OnDetachFromMainTree() override;
401 
IsFullPageNavigation()402     bool IsFullPageNavigation() const
403     {
404         return isFullPageNavigation_;
405     }
406 
407     bool IsTopNavDestination(const RefPtr<UINode>& node) const;
408     void TryRestoreSystemBarStyle(const RefPtr<WindowManager>& windowManager);
409 
IsFinishInteractiveAnimation()410     bool IsFinishInteractiveAnimation() const
411     {
412         return isFinishInteractiveAnimation_;
413     }
414 
GetTopNavigationProxy()415     const RefPtr<NavigationTransitionProxy> GetTopNavigationProxy() const
416     {
417         return proxyList_.empty() ? nullptr : proxyList_.back();
418     }
419 
420     RefPtr<NavigationTransitionProxy> GetProxyById(uint64_t id) const;
421 
422     void RemoveProxyById(uint64_t id);
423 
IsCurTopNewInstance()424     bool IsCurTopNewInstance() const
425     {
426         return isCurTopNewInstance_;
427     }
428 
GetAllNavDestinationNodesPrev()429     const std::vector<std::pair<std::string, WeakPtr<UINode>>>& GetAllNavDestinationNodesPrev()
430     {
431         return navigationStack_->GetAllNavDestinationNodesPrev();
432     }
433 
GetIsPreForceSetList()434     bool GetIsPreForceSetList()
435     {
436         return navigationStack_->GetIsPreForceSetList();
437     }
438 
439     void DialogAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
440         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage, bool isNeedVisible);
441 
442     bool IsLastStdChange();
443     void ReplaceAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
444         const RefPtr<NavDestinationGroupNode>& newTopNavDestination);
445     void TransitionWithDialogAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
446         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
447     void FollowStdNavdestinationAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
448     const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
449     bool FindInCurStack(const RefPtr<FrameNode>& navDestinationNode);
450 
451     std::unique_ptr<JsonValue> GetNavdestinationJsonArray();
452     RefPtr<NavigationPattern> GetParentNavigationPattern();
453     void RestoreJsStackIfNeeded();
454 
GetNavBasePageNode()455     RefPtr<FrameNode> GetNavBasePageNode() const
456     {
457         return pageNode_.Upgrade();
458     }
459 
460     RefPtr<FrameNode> GetDragBarNode() const;
461     void BuildDragBar();
462     void InitDragBarEvent();
463     void ClearDragBarEvent();
464     void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub);
465     void HandleTouchEvent(const TouchEventInfo& info);
466     void HandleTouchDown();
467     void HandleTouchUp();
468     void ClearRecoveryList();
469 
SetEnableDragBar(bool enabled)470     void SetEnableDragBar(bool enabled)
471     {
472         enableDragBar_ = enabled;
473     }
474 
GetEnableDragBar()475     bool GetEnableDragBar() const
476     {
477         return enableDragBar_;
478     }
479 
SetNavigationSize(const SizeF & size)480     void SetNavigationSize(const SizeF& size)
481     {
482         navigationSize_ = size;
483     }
GetNavigationSize()484     const SizeF& GetNavigationSize() const
485     {
486         return navigationSize_;
487     }
488 
GetIsInDividerDrag()489     bool GetIsInDividerDrag() const
490     {
491         return isInDividerDrag_;
492     }
493 
494 private:
495     void FireOnNewParam(const RefPtr<UINode>& uiNode);
496     void UpdateIsFullPageNavigation(const RefPtr<FrameNode>& host);
497     void UpdateSystemBarStyleOnFullPageStateChange(const RefPtr<WindowManager>& windowManager);
498     void UpdateSystemBarStyleOnTopNavPathChange(
499         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath);
500     void UpdateSystemBarStyleWithTopNavPath(const RefPtr<WindowManager>& windowManager,
501         const std::optional<std::pair<std::string, RefPtr<UINode>>>& topNavPath);
502     void UpdateSystemBarStyleOnPageVisibilityChange(bool show);
503     void RegisterPageVisibilityChangeCallback();
504     bool ApplyTopNavPathSystemBarStyleOrRestore(const RefPtr<WindowManager>& windowManager,
505         const std::optional<std::pair<std::string, RefPtr<UINode>>>& topNavPath);
506     void InitPageNode(const RefPtr<FrameNode>& host);
507     void InitFoldState();
508 
509     void CheckTopNavPathChange(const std::optional<std::pair<std::string, RefPtr<UINode>>>& preTopNavPath,
510         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath,
511         int32_t preLastStandardIndex = -1);
512     void TransitionWithAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
513         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage, bool isNeedVisible = false);
514     bool TriggerCustomAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
515         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
516 
517     void OnCustomAnimationFinish(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
518         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
519     void TransitionWithOutAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,
520         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage, bool needVisible = false);
521     NavigationTransition ExecuteTransition(const RefPtr<NavDestinationGroupNode>& preTopDestination,
522         const RefPtr<NavDestinationGroupNode>& newTopNavDestination, bool isPopPage);
523     RefPtr<RenderContext> GetTitleBarRenderContext();
524     void DoAnimation(NavigationMode usrNavigationMode);
525     void RecoveryToLastStack(const RefPtr<NavDestinationGroupNode>& preTopDestination,
526         const RefPtr<NavDestinationGroupNode>& newTopDestination);
527     bool GenerateUINodeByIndex(int32_t index, RefPtr<UINode>& node);
528     int32_t GenerateUINodeFromRecovery(int32_t lastStandardIndex, NavPathList& navPathList);
529     void DoNavbarHideAnimation(const RefPtr<NavigationGroupNode>& hostNode);
530     RefPtr<FrameNode> GetDividerNode() const;
531     void FireInterceptionEvent(bool isBefore,
532         const std::optional<std::pair<std::string, RefPtr<UINode>>>& newTopNavPath);
533     void InitDividerPanEvent(const RefPtr<GestureEventHub>& gestureHub);
534     void InitDragBarPanEvent(const RefPtr<GestureEventHub>& gestureHub);
535     void HandleDragStart();
536     void HandleDragUpdate(float xOffset);
537     void HandleDragEnd();
538     void OnHover(bool isHover);
GetPaintRectHeight(const RefPtr<FrameNode> & node)539     float GetPaintRectHeight(const RefPtr<FrameNode>& node)
540     {
541         auto renderContext = node->GetRenderContext();
542         CHECK_NULL_RETURN(renderContext, 0.0f);
543         return renderContext->GetPaintRectWithoutTransform().Height();
544     }
545     void AddDividerHotZoneRect();
546     void RangeCalculation(
547         const RefPtr<NavigationGroupNode>& hostNode, const RefPtr<NavigationLayoutProperty>& navigationLayoutProperty);
548     bool UpdateTitleModeChangeEventHub(const RefPtr<NavigationGroupNode>& hostNode);
549     void FireNavBarWidthChangeEvent(const RefPtr<LayoutWrapper>& layoutWrapper);
550     void NotifyPageShow(const std::string& pageName);
551     void ProcessPageShowEvent();
552     int32_t FireNavDestinationStateChange(NavDestinationLifecycle lifecycle);
553     void UpdatePreNavDesZIndex(const RefPtr<FrameNode> &preTopNavDestination,
554         const RefPtr<FrameNode> &newTopNavDestination, int32_t preLastStandardIndex = -1);
555     void UpdateNavPathList();
556     void RefreshNavDestination();
557     void DealTransitionVisibility(const RefPtr<FrameNode>& node, bool isVisible, bool isNavBar);
558     void NotifyNavDestinationSwitch(const RefPtr<NavDestinationContext>& from,
559         const RefPtr<NavDestinationContext>& to, NavigationOperation operation);
560 
561     void UpdateIsAnimation(const std::optional<std::pair<std::string, RefPtr<UINode>>>& preTopNavPath);
562     void StartTransition(const RefPtr<NavDestinationGroupNode>& preDestination,
563     const RefPtr<NavDestinationGroupNode>& topDestination,
564     bool isAnimated, bool isPopPage, bool isNeedVisible = false);
565     void ProcessAutoSave(const RefPtr<FrameNode>& node);
566 
567     void FireShowAndHideLifecycle(const RefPtr<NavDestinationGroupNode>& preDestination,
568         const RefPtr<NavDestinationGroupNode>& topDestination, bool isPopPage, bool isAnimated);
569     void OnWindowSizeChanged(int32_t width, int32_t height, WindowSizeChangeReason type) override;
570     void RefreshFocusToDestination();
571 
572     void PerformanceEventReport(int32_t nodeCount, int32_t depth, const std::string& navDestinationName);
573     void StartDefaultAnimation(const RefPtr<NavDestinationGroupNode>& preTopDestination,
574         const RefPtr<NavDestinationGroupNode>& topDestination,
575         bool isPopPage, bool isNeedInVisible = false);
576     bool ExecuteAddAnimation(const RefPtr<NavDestinationGroupNode>& preTopDestination,
577         const RefPtr<NavDestinationGroupNode>& topDestination,
578         bool isPopPage, const RefPtr<NavigationTransitionProxy>& proxy,
579         NavigationTransition navigationTransition);
580     bool GetIsFocusable(const RefPtr<FrameNode>& frameNode);
581     void GetOrCreateNavDestinationUINode();
582     void CloseLongPressDialog();
583 
584     void CreateDragBarNode(const RefPtr<NavigationGroupNode>& navigationGroupNode);
585     RefPtr<FrameNode> CreateDragBarItemNode();
586     void SetMouseStyle(MouseFormat format);
587 
588     void OnAvoidInfoChange(const ContainerModalAvoidInfo& info) override;
589     void RegisterAvoidInfoChangeListener(const RefPtr<FrameNode>& hostNode);
590     void UnregisterAvoidInfoChangeListener(const RefPtr<FrameNode>& hostNode);
591     virtual void MarkAllNavDestinationDirtyIfNeeded(const RefPtr<FrameNode>& hostNode, bool skipCheck = false);
592     void UpdateToobarFocusColor();
593     void GenerateLastStandardPage(NavPathList& navPathList);
594     RefPtr<UINode> FindNavDestinationNodeInPreList(const uint64_t navDestinationId) const;
595     bool IsStandardPage(const RefPtr<UINode>& uiNode) const;
596     void UpdateDividerBackgroundColor();
597 
598     NavigationMode navigationMode_ = NavigationMode::AUTO;
599     std::function<void(std::string)> builder_;
600     RefPtr<NavigationStack> navigationStack_;
601     RefPtr<InputEvent> hoverEvent_;
602     RefPtr<PanEvent> panEvent_;
603     RefPtr<PanEvent> dragBarPanEvent_;
604     std::vector<RefPtr<NavigationTransitionProxy>> proxyList_;
605     RectF dragRect_;
606     RectF dragBarRect_;
607     WeakPtr<FrameNode> pageNode_;
608     bool isFullPageNavigation_ = false;
609     std::optional<RefPtr<SystemBarStyle>> backupStyle_;
610     std::optional<RefPtr<SystemBarStyle>> currStyle_;
611     bool addByNavRouter_ = false;
612     bool ifNeedInit_ = true;
613     float preNavBarWidth_ = 0.0f;
614     float realNavBarWidth_ = DEFAULT_NAV_BAR_WIDTH.ConvertToPx();
615     float realDividerWidth_ = 2.0f;
616     bool navigationStackProvided_ = false;
617     bool navBarVisibilityChange_ = false;
618     bool userSetNavBarRangeFlag_ = false;
619     bool userSetMinContentFlag_ = false;
620     bool userSetNavBarWidthFlag_ = false;
621     bool isChanged_ = false; // check navigation top page is change
622     Dimension initNavBarWidthValue_ = DEFAULT_NAV_BAR_WIDTH;
623     Dimension minNavBarWidthValue_ = 0.0_vp;
624     Dimension maxNavBarWidthValue_ = 0.0_vp;
625     Dimension minContentWidthValue_ = 0.0_vp;
626     NavigationTitleMode titleMode_ = NavigationTitleMode::FREE;
627     bool navigationModeChange_ = false;
628     bool isCustomAnimation_ = false; // custom animation
629     bool isInDividerDrag_ = false;
630     bool isDividerDraggable_ = true;
631     bool isAnimated_ = false;
632 #if defined(ENABLE_NAV_SPLIT_MODE)
633     bool isBackPage_ = false;
634 #endif
635     FoldStatus currentFoldStatus_ = FoldStatus::UNKNOWN;  // only used for mode-switch animation
636     bool isReplace_ = false;
637     bool isFinishInteractiveAnimation_ = true;
638     int32_t lastPreIndex_ = false;
639     std::shared_ptr<NavigationController> navigationController_;
640     std::map<int32_t, std::function<void(bool)>> onStateChangeMap_;
641     OnNavigationAnimation onTransition_;
642     bool needSyncWithJsStack_ = false;
643     std::optional<std::pair<std::string, RefPtr<UINode>>> preTopNavPath_;
644     RefPtr<NavDestinationContext> preContext_;
645     WeakPtr<UINode> parentNode_;
646     int32_t preStackSize_ = 0;
647     bool isRightToLeft_ = false;
648     bool isCurTopNewInstance_ = false;
649     RefPtr<TouchEventImpl> touchEvent_;
650     bool enableDragBar_ = false;
651     SizeF navigationSize_;
652     std::optional<NavBarPosition> preNavBarPosition_;
653     bool topFromSingletonMoved_ = false;
654 };
655 
656 } // namespace OHOS::Ace::NG
657 
658 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_PATTERN_H
659