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