• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_MODEL_NG_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_MODEL_NG_H
18 
19 #include "core/components_ng/pattern/navigation/navigation_model.h"
20 #include "core/components_ng/pattern/navigation/nav_bar_node.h"
21 #include "core/components_ng/pattern/navigation/navigation_group_node.h"
22 
23 namespace OHOS::Ace::NG {
24 class ACE_EXPORT NavigationModelNG : public OHOS::Ace::NavigationModel {
25 public:
26     void Create() override;
27     void SetNavigationStack() override;
28     void SetNavigationStack(const RefPtr<NG::NavigationStack>& navigationStack) override;
29     void SetNavigationStackWithCreatorAndUpdater(std::function<RefPtr<NG::NavigationStack>()> creator,
30         std::function<void(RefPtr<NG::NavigationStack>)> updater) override;
31     void SetNavigationStackProvided(bool provided) override;
32     void SetNavigationPathInfo(const std::string& moduleName, const std::string& pagePath) override;
33     bool ParseCommonTitle(bool hasSubTitle, bool hasMainTitle, const std::string& subtitle,
34         const std::string& title, bool ignoreMainTitle = false) override;
35     void SetTitle(const std::string& title, bool hasSubTitle = false) override;
36     void SetTitlebarOptions(NavigationTitlebarOptions&& opt) override;
37     void SetCustomTitle(const RefPtr<AceType>& customNode) override;
38     void SetTitleHeight(const Dimension& height, bool isValid = true) override;
39     void SetTitleMode(NG::NavigationTitleMode mode) override;
40     void SetSubtitle(const std::string& subtitle) override;
41     void SetHideTitleBar(bool hideTitleBar, bool animated = false) override;
42     void SetHideNavBar(bool hideNavBar) override;
43     void SetBackButtonIcon(const std::function<void(WeakPtr<NG::FrameNode>)>& symbolApply, const std::string& src,
44         const ImageOption& imageOption, RefPtr<PixelMap>& pixMap, const std::vector<std::string>& nameList) override;
45     void SetHideBackButton(bool hideBackButton) override;
46     void SetHideToolBar(bool hideToolBar, bool animated = false) override;
47     void SetCustomToolBar(const RefPtr<AceType>& customNode) override;
48     bool NeedSetItems() override;
49 
50     void SetToolBarItems(std::vector<NG::BarItem>&& toolBarItems) override;
51     void SetToolbarConfiguration(std::vector<NG::BarItem>&& toolBarItems) override;
52     void SetToolbarOptions(NavigationToolbarOptions&& opt) override;
53     void SetMenuItems(std::vector<NG::BarItem>&& menuItems) override;
54     void SetCustomMenu(const RefPtr<AceType>& customNode) override;
55     void SetOnTitleModeChange(std::function<void(NG::NavigationTitleMode)>&& onTitleModeChange,
56         std::function<void(const BaseEventInfo* baseInfo)>&& eventInfo) override;
57     void SetUsrNavigationMode(NG::NavigationMode mode) override;
58     void SetNavBarPosition(NG::NavBarPosition mode) override;
59     void SetNavBarWidth(const Dimension& value) override;
60     void SetMinNavBarWidth(const Dimension& value) override;
61     void SetMaxNavBarWidth(const Dimension& value) override;
62     void SetMinContentWidth(const Dimension& value) override;
63     void SetOnNavBarStateChange(std::function<void(bool)>&& onNavBarStateChange) override;
64     void SetNavigationMode(NG::NavigationMode mode) override;
65     void SetNavDestination(std::function<void(std::string)>&& builder) override;
66     RefPtr<NG::NavigationStack> GetNavigationStack() override;
67     void SetMenuCount(int32_t menuCount) override;
68     void SetOnNavigationModeChange(std::function<void(NG::NavigationMode)>&& onModeChange) override;
69     void SetCustomTransition(NavigationTransitionEvent&& animationTransition) override;
70     void SetIsCustomAnimation(bool isCustom) override;
71     static RefPtr<FrameNode> CreateFrameNode(int32_t nodeId);
72     static void SetNavigationStack(FrameNode* frameNode);
73     static void SetHideToolBar(FrameNode* frameNode, bool hideToolBar, bool animated);
74     static void SetMinContentWidth(FrameNode* frameNode, const Dimension& value);
75     static void SetMinNavBarWidth(FrameNode* frameNode, const Dimension& value);
76     static void SetMaxNavBarWidth(FrameNode* frameNode, const Dimension& value);
77     static void SetNavBarWidth(FrameNode* frameNode, const Dimension& value);
78     static void SetNavBarPosition(FrameNode* frameNode, NG::NavBarPosition mode);
79     static void SetUsrNavigationMode(FrameNode* frameNode, NavigationMode mode);
80     static void SetBackButtonIcon(FrameNode* frameNode, const std::function<void(WeakPtr<NG::FrameNode>)>& symbolApply,
81         const std::string& src, const ImageOption& imageOption, RefPtr<PixelMap>& pixMap);
82     static void SetHideNavBar(FrameNode* frameNode, bool hideNavBar);
83     static void SetHideTitleBar(FrameNode* frameNode, bool hideTitleBar, bool animated);
84     static void SetSubtitle(FrameNode* frameNode, const std::string& subtitle);
85     static void SetHideBackButton(FrameNode* frameNode, bool hideBackButton);
86     static void SetTitleMode(FrameNode* frameNode, NG::NavigationTitleMode mode);
87 
88     void SetIgnoreLayoutSafeArea(const NG::SafeAreaExpandOpts& opts) override;
89     static void SetIgnoreLayoutSafeArea(FrameNode* frameNode, const NG::SafeAreaExpandOpts& opts);
90     void SetSystemBarStyle(const RefPtr<SystemBarStyle>& style) override;
91     static void ParseCommonTitle(FrameNode* frameNode, const NG::NavigationTitleInfo& titleInfo,
92         bool ignoreMainTitle = false);
93     static void SetTitlebarOptions(FrameNode* frameNode, NavigationTitlebarOptions&& opt);
94 
95 private:
96     bool CreateNavBarNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode);
97     bool CreateNavBarNodeChildsIfNeeded(const RefPtr<NavBarNode>& navBarNode);
98     bool CreateContentNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode);
99     bool CreateDividerNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode);
100     static void SetHideNavBarInner(const RefPtr<NavigationGroupNode>& navigationGroupNode, bool hideNavBar);
101 };
102 } // namespace OHOS::Ace::NG
103 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_MODEL_NG_H
104