• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_TOOLBAR_UTIL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_TOOLBAR_UTIL_H
18 
19 #include "base/memory/ace_type.h"
20 #include "base/memory/referenced.h"
21 #include "core/components_ng/base/ui_node.h"
22 #include "core/components_ng/pattern/navigation/navdestination_node_base.h"
23 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
24 #include "core/components_ng/pattern/navigation/navigation_options.h"
25 
26 namespace OHOS::Ace::NG {
27 struct FieldProperty {
28     std::string parentId;
29     std::string field;
30 };
31 struct ToolBarItemParam {
32     bool needMoreButton;
33     bool enableStatus;
34     bool hideItemText;
35 };
36 struct BarItemNodeParam {
37     bool enabled;
38     bool hideText;
39 };
40 
41 struct BarNode {
42     RefPtr<FrameNode> barMenuNode;
43     RefPtr<NavDestinationNodeBase> nodeBase;
44 };
45 class NavigationToolbarUtil {
46 public:
47     static void CreateToolBarDividerNodeIfNeeded(const RefPtr<NavDestinationNodeBase>& nodeBase);
48     static void SetToolbarConfiguration(const RefPtr<NavDestinationNodeBase>& nodeBase,
49         std::vector<NG::BarItem>&& toolBarItems, bool enabled, const FieldProperty& fieldProperty);
50     static void SetCustomToolBar(const RefPtr<NavDestinationNodeBase>& nodeBase, const RefPtr<AceType>& customNode);
51     static void SetHideItemText(const RefPtr<NavDestinationNodeBase>& nodeBase, bool isHideItemText);
52     static void SetToolbarOptions(const RefPtr<NavDestinationNodeBase>& nodeBase, NavigationToolbarOptions&& opt);
53     static void SetToolbarMoreButtonOptions(const RefPtr<NavDestinationNodeBase>& nodeBase, MoreButtonOptions&& opt);
54     static void MountToolBar(
55         const RefPtr<NavDestinationNodeBase>& nodeBase, bool& needRunToolBarAnimation);
56 };
57 
58 } // namespace OHOS::Ace::NG
59 
60 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_TOOLBAR_UTIL_H