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