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 bool ParseCommonTitle(bool hasSubTitle, bool hasMainTitle, const std::string& subtitle, 33 const std::string& title, bool ignoreMainTitle = false) override; 34 void SetTitle(const std::string& title, bool hasSubTitle = false) override; 35 void SetTitlebarOptions(NavigationTitlebarOptions&& opt) override; 36 void SetCustomTitle(const RefPtr<AceType>& customNode) override; 37 void SetTitleHeight(const Dimension& height, bool isValid = true) override; 38 void SetTitleMode(NG::NavigationTitleMode mode) override; 39 void SetSubtitle(const std::string& subtitle) override; 40 void SetHideTitleBar(bool hideTitleBar) override; 41 void SetHideNavBar(bool hideNavBar) override; 42 void SetBackButtonIcon(const std::string& src, bool noPixMap, RefPtr<PixelMap>& pixMap, 43 const std::string& bundleName, const std::string& moduleName) override; 44 void SetHideBackButton(bool hideBackButton) override; 45 void SetHideToolBar(bool hideToolBar) override; 46 void SetCustomToolBar(const RefPtr<AceType>& customNode) override; 47 bool NeedSetItems() override; 48 49 void SetToolBarItems(std::vector<NG::BarItem>&& toolBarItems) override; 50 void SetToolbarConfiguration(std::vector<NG::BarItem>&& toolBarItems) override; 51 void SetToolbarOptions(NavigationToolbarOptions&& opt) override; 52 void SetMenuItems(std::vector<NG::BarItem>&& menuItems) override; 53 void SetCustomMenu(const RefPtr<AceType>& customNode) override; 54 void SetOnTitleModeChange(std::function<void(NG::NavigationTitleMode)>&& onTitleModeChange, 55 std::function<void(const BaseEventInfo* baseInfo)>&& eventInfo) override; 56 void SetUsrNavigationMode(NG::NavigationMode mode) override; 57 void SetNavBarPosition(NG::NavBarPosition mode) override; 58 void SetNavBarWidth(const Dimension& value) override; 59 void SetMinNavBarWidth(const Dimension& value) override; 60 void SetMaxNavBarWidth(const Dimension& value) override; 61 void SetMinContentWidth(const Dimension& value) override; 62 void SetOnNavBarStateChange(std::function<void(bool)>&& onNavBarStateChange) override; 63 void SetNavigationMode(NG::NavigationMode mode) override; 64 void SetNavDestination(std::function<void(std::string)>&& builder) override; 65 RefPtr<NG::NavigationStack> GetNavigationStack() override; 66 void SetMenuCount(int32_t menuCount) override; 67 void SetOnNavigationModeChange(std::function<void(NG::NavigationMode)>&& onModeChange) override; 68 void SetCustomTransition(NavigationTransitionEvent&& animationTransition) override; 69 void SetIsCustomAnimation(bool isCustom) override; 70 static void SetHideToolBar(FrameNode* frameNode, bool hideToolBar); 71 static void SetMinContentWidth(FrameNode* frameNode, const Dimension& value); 72 static void SetMinNavBarWidth(FrameNode* frameNode, const Dimension& value); 73 static void SetMaxNavBarWidth(FrameNode* frameNode, const Dimension& value); 74 static void SetNavBarWidth(FrameNode* frameNode, const Dimension& value); 75 static void SetNavBarPosition(FrameNode* frameNode, NG::NavBarPosition mode); 76 static void SetUsrNavigationMode(FrameNode* frameNode, NavigationMode mode); 77 static void SetBackButtonIcon( 78 FrameNode* frameNode, const std::string& src, bool noPixMap, RefPtr<PixelMap>& pixMap); 79 static void SetHideNavBar(FrameNode* frameNode, bool hideNavBar); 80 static void SetHideTitleBar(FrameNode* frameNode, bool hideTitleBar); 81 static void SetSubtitle(FrameNode* frameNode, const std::string& subtitle); 82 static void SetHideBackButton(FrameNode* frameNode, bool hideBackButton); 83 static void SetTitleMode(FrameNode* frameNode, NG::NavigationTitleMode mode); 84 85 private: 86 bool CreateNavBarNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode); 87 bool CreateNavBarNodeChildsIfNeeded(const RefPtr<NavBarNode>& navBarNode); 88 bool CreateContentNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode); 89 bool CreateDividerNodeIfNeeded(const RefPtr<NavigationGroupNode>& navigationGroupNode); 90 }; 91 } // namespace OHOS::Ace::NG 92 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_MODEL_NG_H 93