• 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_OPTIONS_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_OPTIONS_H
18 
19 #include <optional>
20 
21 #include "core/components/common/properties/color.h"
22 #include "core/components/common/properties/decoration.h"
23 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
24 
25 namespace OHOS::Ace::NG {
26 struct NavigationBackgroundOptions {
27     std::optional<Color> color;
28     std::optional<BlurStyleOption> blurStyleOption;
29     std::optional<EffectOption> effectOption;
30 
31     bool operator== (const NavigationBackgroundOptions& other) const
32     {
33         return color == other.color && blurStyleOption == other.blurStyleOption && effectOption == other.effectOption;
34     }
35 
36     bool operator!= (const NavigationBackgroundOptions& other) const
37     {
38         return !(*this == other);
39     }
40 };
41 
42 struct NavigationBarOptions {
43     std::optional<BarStyle> barStyle;
44     std::optional<CalcDimension> paddingStart;
45     std::optional<CalcDimension> paddingEnd;
46     bool textHideOptions = false;
47 
48     bool operator== (const NavigationBarOptions& other) const
49     {
50         return barStyle == other.barStyle && paddingStart == other.paddingStart
51             && paddingEnd == other.paddingEnd;
52     }
53 
54     bool operator!= (const NavigationBarOptions& other) const
55     {
56         return !(*this == other);
57     }
58 };
59 
60 struct MoreButtonOptions {
61     NavigationBackgroundOptions bgOptions;
62 
63     bool operator== (const MoreButtonOptions& other) const
64     {
65         return bgOptions == other.bgOptions;
66     }
67 
68     bool operator!= (const MoreButtonOptions& other) const
69     {
70         return !(*this == other);
71     }
72 };
73 
74 using TextStyleApplyFunc = std::function<void(WeakPtr<FrameNode>)>;
75 struct NavigationTextOptions {
76     TextStyleApplyFunc mainTitleApplyFunc;
77     TextStyleApplyFunc subTitleApplyFunc;
78 
ResetNavigationTextOptions79     void Reset()
80     {
81         mainTitleApplyFunc = nullptr;
82         subTitleApplyFunc = nullptr;
83     }
84 };
85 
86 struct NavigationTitlebarOptions {
87     NavigationBackgroundOptions bgOptions;
88     NavigationBarOptions brOptions;
89     NavigationTextOptions textOptions;
90     bool enableHoverMode = false;
91 
92     bool operator== (const NavigationTitlebarOptions& other) const
93     {
94         return bgOptions == other.bgOptions && brOptions == other.brOptions
95             && enableHoverMode == other.enableHoverMode;
96     }
97 
98     bool operator!= (const NavigationTitlebarOptions& other) const
99     {
100         return !(*this == other);
101     }
102 };
103 
104 struct NavigationToolbarOptions {
105     NavigationBackgroundOptions bgOptions;
106     // toolBar not support paddingStart and paddingEnd of NavigationBarOptions now
107     NavigationBarOptions brOptions;
108     MoreButtonOptions mbOptions;
109 
110     bool operator== (const NavigationToolbarOptions& other) const
111     {
112         return bgOptions == other.bgOptions && brOptions == other.brOptions && mbOptions == other.mbOptions;
113     }
114 
115     bool operator!= (const NavigationToolbarOptions& other) const
116     {
117         return !(*this == other);
118     }
119 };
120 
121 struct ImageOption {
122     bool noPixMap;
123     bool isValidImage;
124 };
125 
126 struct NavigationMenuOptions {
127     MoreButtonOptions mbOptions;
128 
129     bool operator== (const NavigationMenuOptions& other) const
130     {
131         return mbOptions == other.mbOptions;
132     }
133 
134     bool operator!= (const NavigationMenuOptions& other) const
135     {
136         return !(*this == other);
137     }
138 };
139 
140 } // namespace OHOS::Ace::NG
141 
142 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATION_NAVIGATION_OPTIONS_H
143