• 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 FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVDESTINATION_NAVDESTINATION_MODEL_NG_H
17 #define FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVDESTINATION_NAVDESTINATION_MODEL_NG_H
18 
19 #include "core/components_ng/pattern/navrouter/navdestination_group_node.h"
20 #include "core/components_ng/pattern/navrouter/navdestination_model.h"
21 
22 namespace OHOS::Ace::NG {
23 class ACE_EXPORT NavDestinationModelNG : public OHOS::Ace::NavDestinationModel {
24 public:
25     void Create() override;
26     void Create(std::function<void()>&& deepRenderFunc, RefPtr<NG::NavDestinationContext> context = nullptr) override;
27     void SetHideTitleBar(bool hideTitleBar, bool animated) override;
28     void SetHideBackButton(bool hideBackButton) override;
29     void SetTitle(const std::string& title, bool hasSubTitle) override;
30     void SetTitlebarOptions(NG::NavigationTitlebarOptions&& opt) override;
31     void SetBackButtonIcon(const std::function<void(WeakPtr<NG::FrameNode>)>& iconSymbol, const std::string& src,
32         const ImageOption& imageOption, RefPtr<PixelMap>& pixMap, const std::vector<std::string>& nameList) override;
33     void SetSubtitle(const std::string& subtitle) override;
34     void SetCustomTitle(const RefPtr<AceType>& customNode) override;
35     void SetTitleHeight(const Dimension& titleHeight, bool isValid = true) override;
36     void SetOnShown(std::function<void()>&& onShow) override;
37     void SetOnHidden(std::function<void()>&& onHidden) override;
38     void SetOnWillAppear(std::function<void()>&& willAppear) override;
39     void SetOnWillShow(std::function<void()>&& willShow) override;
40     void SetOnWillHide(std::function<void()>&& willHide) override;
41     void SetOnWillDisAppear(std::function<void()>&& willDisAppear) override;
42     void SetOnPop(std::function<void(const RefPtr<NavPathInfo>&)>&& popCallback) override;
43     void SetOnBackPressed(std::function<bool()>&& onBackPressed) override;
44     void SetHideToolBar(bool hideToolBar, bool animated) override;
45     static void SetHideToolBar(FrameNode* frameNode, bool hideToolBar, bool animated);
46     void SetToolbarConfiguration(std::vector<NG::BarItem>&& toolBarItems) override;
47     void SetCustomToolBar(const RefPtr<AceType>& customNode) override;
48     void SetToolBarOptions(NavigationToolbarOptions&& opt) override;
49     void SetOnReady(std::function<void(RefPtr<NavDestinationContext>)>&& onReady) override;
50     RefPtr<AceType> CreateEmpty() override;
51     static void SetHideTitleBar(FrameNode* frameNode, bool hideTitleBar, bool animated);
52     static void SetHideBackButton(FrameNode* frameNode, bool hideBackButton);
53     static void SetBackgroundColor(FrameNode* frameNode, const Color& color, bool isVaild = true);
54     static void SetBackButtonIcon(FrameNode* frameNode, const std::string& src,
55         bool noPixMap, RefPtr<PixelMap>& pixMap);
56     static void SetNavDestinationMode(FrameNode* frameNode, NavDestinationMode mode);
57     static void SetRecoverable(FrameNode* frameNode, bool recoverable);
58 
59     void SetNavDestinationMode(NavDestinationMode mode) override;
60     void SetRecoverable(bool recoverable) override;
61     bool ParseCommonTitle(
62         bool hasSubTitle, bool hasMainTitle, const std::string& subtitle, const std::string& title) override;
63     void SetMenuItems(std::vector<NG::BarItem>&& menuItems) override;
64     void SetCustomMenu(const RefPtr<AceType>& customNode) override;
65     void SetBackgroundColor(const Color& color, bool isVaild = true) override;
66     void SetIgnoreLayoutSafeArea(const SafeAreaExpandOpts& opts) override;
67     static void SetIgnoreLayoutSafeArea(FrameNode* frameNode, const SafeAreaExpandOpts& opts);
68     void SetNavDestinationPathInfo(const std::string& moduleName, const std::string& pagePath) override;
69     void SetSystemBarStyle(const RefPtr<SystemBarStyle>& style) override;
70     static void ParseCommonTitle(FrameNode* frameNode, const NG::NavigationTitleInfo& titleInfo);
71     static void SetTitlebarOptions(FrameNode* frameNode, NavigationTitlebarOptions&& opt);
72     static void SetMenuItems(FrameNode* frameNode, std::vector<NG::BarItem>&& menuItems);
73     static void SetMenuItemAction(FrameNode* frameNode, std::function<void()>&& action, uint32_t index);
74     static void SetMenuItemSymbol(FrameNode* frameNode,
75         std::function<void(WeakPtr<NG::FrameNode>)>&& symbol, uint32_t index);
76     void SetSystemTransitionType(NG::NavigationSystemTransitionType type) override;
77     static void SetSystemTransitionType(FrameNode* frameNode, NG::NavigationSystemTransitionType type);
78     void SetCustomTransition(NG::NavDestinationTransitionDelegate&& transitionDelegate) override;
79     void SetScrollableProcessor(
80         const std::function<RefPtr<NG::NavDestinationScrollableProcessor>()>& creator) override;
81     void UpdateBindingWithScrollable(
82         std::function<void(const RefPtr<NG::NavDestinationScrollableProcessor>& processor)>&& callback) override;
83 
84 private:
85     void CreateBackButton(const RefPtr<NavDestinationGroupNode>& navDestinationNode);
86     void CreateImageButton(const RefPtr<NavDestinationGroupNode>& navDestinationNode);
87 };
88 } // namespace OHOS::Ace::NG
89 
90 #endif // FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_NAVDESTINATION_NAVDESTINATION_MODEL_NG_H
91