• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_CALENDAR_CALENDAR_THEME_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_CALENDAR_THEME_H
18 
19 #include "base/geometry/dimension.h"
20 #include "core/components/common/properties/color.h"
21 #include "core/components/theme/theme.h"
22 #include "core/components/theme/theme_constants.h"
23 #include "core/components/theme/theme_constants_defines.h"
24 
25 namespace OHOS::Ace {
26 namespace {
27 
28 constexpr Color DEFAULT_DAY_COLOR = Color(0xE1181819);
29 constexpr Color DEFAULT_NON_CURRENT_MONTH_DAY_COLOR = Color(0x4B181819);
30 constexpr Color DEFAULT_WEEKEND_DAY_COLOR = Color(0x7D181819);
31 constexpr Color DEFAULT_WEEKEND_LUNAR_COLOR = Color(0x7D181819);
32 constexpr Color DEFAULT_NON_CURRENT_MONTH_LUNAR_COLOR = Color(0x75181819);
33 constexpr Color DEFAULT_LUNAR_COLOR = Color(0x96181819);
34 constexpr Color DEFAULT_CALENDAR_WEEK_COLOR = Color(0xffa0a1a5);
35 constexpr Color DEFAULT_CALENDAR_DAY_COLOR = Color(0xffeaebed);
36 constexpr Color DEFAULT_CALENDAR_LUNAR_COLOR = Color(0xffa0a1a5);
37 constexpr Color DEFAULT_CALENDAR_WEEKEND_DAY_COLOR = Color(0xff808080);
38 constexpr Color DEFAULT_CALENDAR_WEEKEND_LUNAR_COLOR = Color(0xff808080);
39 constexpr Color DEFAULT_CALENDAR_TODAY_DAY_FOCUS_COLOR = Color(0xffffffff);
40 constexpr Color DEFAULT_CALENDAR_TODAY_LUNAR_FOCUS_COLOR = Color(0xffffffff);
41 constexpr Color DEFAULT_CALENDAR_TODAY_DAY_UNFOCUS_COLOR = Color(0xff0a59f7);
42 constexpr Color DEFAULT_CALENDAR_TODAY_LUNAR_UNFOCUS_COLOR = Color(0xff0a59f7);
43 constexpr Color DEFAULT_CALENDAR_WORK_MARK_COLOR = Color(0xffe84026);
44 constexpr Color DEFAULT_CALENDAR_OFF_MARK_COLOR = Color(0xff0a59f7);
45 constexpr Color DEFAULT_CALENDAR_NONCURRENT_MONTH_WORK_MARK_COLOR = Color(0x33e84026);
46 constexpr Color DEFAULT_CALENDAR_NONCURRENT_MONTH_OFF_MARK_COLOR = Color(0x330a59f7);
47 constexpr Color DEFAULT_CALENDAR_NONCURRENT_MONTH_DAY_COLOR = Color(0xff555e6b);
48 constexpr Color DEFAULT_CALENDAR_NONCURRENT_MONTH_LUNAR_COLOR = Color(0xff555e6b);
49 constexpr Color DEFAULT_CALENDAR_FOCUS_AREA_BACKGROUND_COLOR = Color(0xff5ea1ff);
50 constexpr Color DEFAULT_CALENDAR_BLUR_AREA_BACKGROUND_COLOR = Color(0xffffffff);
51 } // namespace
52 
53 struct CalendarThemeStructure {
54     std::string dayFontWeight = "500";
55     std::string lunarDayFontWeight = "500";
56     std::string workStateFontWeight = "500";
57     Color weekColor;
58     Color dayColor;
59     Color lunarColor;
60     Color weekendDayColor;
61     Color weekendLunarColor;
62     Color todayColor;
63     Color todayLunarColor;
64     Color nonCurrentMonthDayColor;
65     Color nonCurrentMonthLunarColor;
66     Color workDayMarkColor;
67     Color offDayMarkColor;
68     Color nonCurrentMonthWorkDayMarkColor;
69     Color nonCurrentMonthOffDayMarkColor;
70     Color focusedDayColor;
71     Color focusedLunarColor;
72     Color focusedAreaBackgroundColor;
73     Color blurAreaBackgroundColor;
74     Color titleTextColor;
75     Color touchColor;
76     Color markLunarColor;
77     Color clickEffectColor;
78     Color simpleWorkTextColor;
79     Color simpleOffTextColor;
80     Dimension weekFontSize;
81     Dimension dayFontSize;
82     Dimension lunarDayFontSize;
83     Dimension workDayMarkSize;
84     Dimension offDayMarkSize;
85     Dimension focusedAreaRadius;
86     Dimension topPadding;
87     Dimension workStateWidth;
88     Dimension workStateHorizontalMovingDistance;
89     Dimension workStateVerticalMovingDistance;
90     Dimension colSpace;
91     Dimension weekHeight;
92     Dimension dayHeight;
93     Dimension weekWidth;
94     Dimension dayWidth;
95     Dimension weekAndDayRowSpace;
96     Dimension dailyFiveRowSpace;
97     Dimension dailySixRowSpace;
98     Dimension gregorianCalendarHeight;
99     Dimension lunarHeight;
100     Dimension arrowHeight;
101     Dimension arrowWidth;
102     Dimension buttonWidth;
103     Dimension buttonHeight;
104     Dimension titleFontSize;
105     Dimension workStateOffset;
106     Dimension dayYAxisOffset;
107     Dimension lunarDayYAxisOffset;
108     Dimension underscoreXAxisOffset;
109     Dimension underscoreYAxisOffset;
110     Dimension scheduleMarkerXAxisOffset;
111     Dimension scheduleMarkerYAxisOffset;
112     Dimension underscoreWidth;
113     Dimension underscoreLength;
114     Dimension scheduleMarkerRadius;
115     Dimension touchCircleStrokeWidth;
116     Dimension boundaryRowOffset;
117     Dimension boundaryColOffset;
118 };
119 
120 class CalendarTheme : public virtual Theme {
121     DECLARE_ACE_TYPE(CalendarTheme, Theme);
122 
123 public:
124     ~CalendarTheme() override = default;
125     class Builder {
126     public:
127         Builder() = default;
128         ~Builder() = default;
129 
Build(const RefPtr<ThemeConstants> & themeConstants)130         RefPtr<CalendarTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const
131         {
132             RefPtr<CalendarTheme> theme = AceType::Claim(new CalendarTheme());
133             if (!themeConstants) {
134                 return theme;
135             }
136             theme = AceType::Claim(new CalendarTheme());
137             theme->calendarTheme_.weekFontSize = themeConstants->GetDimension(THEME_CALENDAR_WEEK_FONT_SIZE);
138             theme->calendarTheme_.dayFontSize = themeConstants->GetDimension(THEME_CALENDAR_DAY_FONT_SIZE);
139             theme->calendarTheme_.lunarDayFontSize = themeConstants->GetDimension(THEME_CALENDAR_LUNAR_FONT_SIZE);
140             theme->calendarTheme_.weekColor = themeConstants->GetColor(THEME_CALENDAR_WEEK_COLOR);
141             theme->calendarTheme_.dayColor = themeConstants->GetColor(THEME_CALENDAR_DAY_COLOR);
142             theme->calendarTheme_.lunarColor = themeConstants->GetColor(THEME_CALENDAR_LUNAR_COLOR);
143             theme->calendarTheme_.weekendDayColor = themeConstants->GetColor(THEME_CALENDAR_WEEKEND_DAY_COLOR);
144             theme->calendarTheme_.weekendLunarColor = themeConstants->GetColor(THEME_CALENDAR_WEEKEND_LUNAR_COLOR);
145             theme->calendarTheme_.todayColor = themeConstants->GetColor(THEME_CALENDAR_TODAY_DAY_COLOR);
146             theme->calendarTheme_.todayLunarColor = themeConstants->GetColor(THEME_CALENDAR_TODAY_LUNAR_COLOR);
147             theme->calendarTheme_.nonCurrentMonthDayColor =
148                 themeConstants->GetColor(THEME_CALENDAR_NON_CURRENT_MONTH_DAY_COLOR);
149             theme->calendarTheme_.nonCurrentMonthLunarColor =
150                 themeConstants->GetColor(THEME_CALENDAR_NON_CURRENT_MONTH_LUNAR_COLOR);
151             theme->calendarTheme_.workDayMarkSize =
152                 themeConstants->GetDimension(THEME_CALENDAR_WORK_DAY_MARK_FONT_SIZE);
153             theme->calendarTheme_.offDayMarkSize = themeConstants->GetDimension(THEME_CALENDAR_OFF_DAY_MARK_FONT_SIZE);
154             theme->calendarTheme_.workDayMarkColor = themeConstants->GetColor(THEME_CALENDAR_WORK_DAY_MARK_COLOR);
155             theme->calendarTheme_.offDayMarkColor = themeConstants->GetColor(THEME_CALENDAR_OFF_DAY_MARK_COLOR);
156             theme->calendarTheme_.nonCurrentMonthWorkDayMarkColor =
157                 themeConstants->GetColor(THEME_CALENDAR_NOT_CURRENT_MONTH_WORK_DAY_MARK_COLOR);
158             theme->calendarTheme_.nonCurrentMonthOffDayMarkColor =
159                 themeConstants->GetColor(THEME_CALENDAR_NOT_CURRENT_MONTH_OFF_DAY_MARK_COLOR);
160             theme->calendarTheme_.focusedDayColor = themeConstants->GetColor(THEME_CALENDAR_FOCUSED_DAY_COLOR);
161             theme->calendarTheme_.focusedLunarColor = themeConstants->GetColor(THEME_CALENDAR_FOCUSED_LUNAR_COLOR);
162             theme->calendarTheme_.focusedAreaRadius = themeConstants->GetDimension(THEME_CALENDAR_FOCUSED_AREA_RADIUS);
163             theme->calendarTheme_.focusedAreaBackgroundColor =
164                 themeConstants->GetColor(THEME_CALENDAR_FOCUSED_AREA_BACKGROUND_COLOR);
165             theme->calendarTheme_.topPadding = themeConstants->GetDimension(THEME_CALENDAR_TOP_PADDING);
166             theme->calendarTheme_.workStateWidth = themeConstants->GetDimension(THEME_CALENDAR_WORK_STATE_WIDTH);
167             theme->calendarTheme_.workStateHorizontalMovingDistance =
168                 themeConstants->GetDimension(THEME_CALENDAR_WORK_STATE_HORIZONTAL_MOVING_DISTANCE);
169             theme->calendarTheme_.workStateVerticalMovingDistance =
170                 themeConstants->GetDimension(THEME_CALENDAR_WORK_STATE_VERTICAL_MOVING_DISTANCE);
171             theme->calendarTheme_.colSpace = themeConstants->GetDimension(THEME_CALENDAR_COL_SPACE);
172             theme->calendarTheme_.weekHeight = themeConstants->GetDimension(THEME_CALENDAR_WEEK_HEIGHT);
173             theme->calendarTheme_.dayHeight = themeConstants->GetDimension(THEME_CALENDAR_DAY_HEIGHT);
174             theme->calendarTheme_.weekWidth = themeConstants->GetDimension(THEME_CALENDAR_WEEK_WIDTH);
175             theme->calendarTheme_.dayWidth = themeConstants->GetDimension(THEME_CALENDAR_DAY_WIDTH);
176             theme->calendarTheme_.weekAndDayRowSpace =
177                 themeConstants->GetDimension(THEME_CALENDAR_WEEK_AND_DAY_ROW_SPACE);
178             theme->calendarTheme_.dailyFiveRowSpace = themeConstants->GetDimension(THEME_CALENDAR_DAILY_FIVE_ROW_SPACE);
179             theme->calendarTheme_.dailySixRowSpace = themeConstants->GetDimension(THEME_CALENDAR_DAILY_SIX_ROW_SPACE);
180             theme->calendarTheme_.gregorianCalendarHeight =
181                 themeConstants->GetDimension(THEME_CALENDAR_GREGORIAN_CALENDAR_HEIGHT);
182             theme->calendarTheme_.blurAreaBackgroundColor =
183                 themeConstants->GetColor(THEME_CALENDAR_BLUR_AREA_BACKGROUND_COLOR);
184             theme->calendarTheme_.dayFontWeight = themeConstants->GetString(THEME_CALENDAR_DAY_FONT_WIGHT);
185             theme->calendarTheme_.lunarDayFontWeight = themeConstants->GetString(THEME_CALENDAR_LUNAR_DAY_FONT_WIGHT);
186             theme->calendarTheme_.workStateFontWeight = themeConstants->GetString(THEME_CALENDAR_WORK_STATE_FONT_WIGHT);
187             theme->calendarTheme_.workStateOffset =
188                 themeConstants->GetDimension(THEME_CALENDAR_WORK_STATE_CENTER_ADJUSTMENT);
189             theme->calendarTheme_.dayYAxisOffset = themeConstants->GetDimension(THEME_CALENDAR_DAY_YAXIS_OFFSET);
190             theme->calendarTheme_.lunarDayYAxisOffset =
191                 themeConstants->GetDimension(THEME_CALENDAR_LUNAR_DAY_YAXIS_OFFSET);
192             theme->calendarTheme_.underscoreXAxisOffset =
193                 themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_XAXIS_OFFSET);
194             theme->calendarTheme_.underscoreYAxisOffset =
195                 themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_YAXIS_OFFSET);
196             theme->calendarTheme_.scheduleMarkerXAxisOffset =
197                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_XAXIS_OFFSET);
198             theme->calendarTheme_.scheduleMarkerYAxisOffset =
199                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_YAXIS_OFFSET);
200             theme->calendarTheme_.touchCircleStrokeWidth =
201                 themeConstants->GetDimension(THEME_CALENDAR_TOUCH_CIRCLE_STROKE_WIDTH);
202             theme->calendarTheme_.lunarHeight = themeConstants->GetDimension(THEME_CALENDAR_LUNAR_HEIGHT);
203             theme->calendarTheme_.underscoreWidth = themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_WIDTH);
204             theme->calendarTheme_.underscoreLength = themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_LENGTH);
205             theme->calendarTheme_.scheduleMarkerRadius =
206                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_RADIUS);
207 
208             theme->cardCalendarTheme_.titleTextColor = themeConstants->GetColor(THEME_CARD_CALENDAR_TITLE_TEXT_COLOR);
209             theme->cardCalendarTheme_.arrowHeight = themeConstants->GetDimension(THEME_CARD_CALENDAR_ARROW_HEIGHT);
210             theme->cardCalendarTheme_.arrowWidth = themeConstants->GetDimension(THEME_CARD_CALENDAR_ARROW_WIDTH);
211             theme->cardCalendarTheme_.buttonHeight = themeConstants->GetDimension(THEME_CARD_CALENDAR_BUTTON_HEIGHT);
212             theme->cardCalendarTheme_.buttonWidth = themeConstants->GetDimension(THEME_CARD_CALENDAR_BUTTON_WIDTH);
213             theme->cardCalendarTheme_.titleFontSize = themeConstants->GetDimension(THEME_CARD_CALENDAR_TITLE_FONT_SIZE);
214             theme->cardCalendarTheme_.weekColor = themeConstants->GetColor(THEME_CARD_CALENDAR_WEEK_COLOR);
215             theme->cardCalendarTheme_.dayColor = themeConstants->GetColor(THEME_CARD_CALENDAR_DAY_COLOR);
216             theme->cardCalendarTheme_.weekendDayColor = themeConstants->GetColor(THEME_CARD_CALENDAR_WEEKEND_DAY_COLOR);
217             theme->cardCalendarTheme_.nonCurrentMonthDayColor =
218                 themeConstants->GetColor(THEME_CARD_CALENDAR_NON_CURRENT_MONTH_DAY_COLOR);
219             theme->cardCalendarTheme_.focusedAreaBackgroundColor =
220                 themeConstants->GetColor(THEME_CARD_CALENDAR_FOCUS_AREA_BACKGROUND_COLOR);
221             theme->cardCalendarTheme_.focusedDayColor = themeConstants->GetColor(THEME_CARD_CALENDAR_FOCUS_DAY_COLOR);
222             theme->cardCalendarTheme_.touchColor = themeConstants->GetColor(THEME_CARD_CALENDAR_TOUCH_COLOR);
223             theme->cardCalendarTheme_.topPadding = themeConstants->GetDimension(THEME_CARD_CALENDAR_TOP_PADDING);
224             theme->cardCalendarTheme_.weekHeight = themeConstants->GetDimension(THEME_CARD_CALENDAR_WEEK_HEIGHT);
225             theme->cardCalendarTheme_.dayHeight = themeConstants->GetDimension(THEME_CARD_CALENDAR_DAY_HEIGHT);
226             theme->cardCalendarTheme_.weekWidth = themeConstants->GetDimension(THEME_CARD_CALENDAR_WEEK_WIDTH);
227             theme->cardCalendarTheme_.dayWidth = themeConstants->GetDimension(THEME_CARD_CALENDAR_DAY_WIDTH);
228             theme->cardCalendarTheme_.focusedAreaRadius =
229                 themeConstants->GetDimension(THEME_CARD_CALENDAR_FOCUS_AREA_RADIUS);
230             theme->cardCalendarTheme_.weekFontSize = themeConstants->GetDimension(THEME_CARD_CALENDAR_WEEK_FONT_SIZE);
231             theme->cardCalendarTheme_.dayFontSize = themeConstants->GetDimension(THEME_CARD_CALENDAR_DAY_FONT_SIZE);
232             theme->cardCalendarTheme_.lunarColor = themeConstants->GetColor(THEME_CARD_CALENDAR_LUNAR_COLOR);
233             theme->cardCalendarTheme_.weekendLunarColor =
234                 themeConstants->GetColor(THEME_CARD_CALENDAR_WEEKEND_LUNAR_COLOR);
235             theme->cardCalendarTheme_.nonCurrentMonthLunarColor =
236                 themeConstants->GetColor(THEME_CARD_CALENDAR_NON_CURRENT_MONTH_LUNAR_COLOR);
237             theme->cardCalendarTheme_.gregorianCalendarHeight =
238                 themeConstants->GetDimension(THEME_CARD_CALENDAR_GREGORIAN_CALENDAR_HEIGHT);
239             theme->cardCalendarTheme_.lunarDayFontSize =
240                 themeConstants->GetDimension(THEME_CARD_CALENDAR_LUNAR_FONT_SIZE);
241             theme->cardCalendarTheme_.workDayMarkColor =
242                 themeConstants->GetColor(THEME_CARD_CALENDAR_WORK_DAY_MARK_COLOR);
243             theme->cardCalendarTheme_.weekAndDayRowSpace =
244                 themeConstants->GetDimension(THEME_CARD_CALENDAR_WEEK_AND_DAY_ROW_SPACE);
245             theme->cardCalendarTheme_.dailyFiveRowSpace =
246                 themeConstants->GetDimension(THEME_CARD_CALENDAR_DAILY_FIVE_ROW_SPACE);
247             theme->cardCalendarTheme_.dayYAxisOffset = themeConstants->GetDimension(THEME_CALENDAR_DAY_YAXIS_OFFSET);
248             theme->cardCalendarTheme_.lunarDayYAxisOffset =
249                 themeConstants->GetDimension(THEME_CALENDAR_LUNAR_DAY_YAXIS_OFFSET);
250             theme->cardCalendarTheme_.underscoreXAxisOffset =
251                 themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_XAXIS_OFFSET);
252             theme->cardCalendarTheme_.underscoreYAxisOffset =
253                 themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_YAXIS_OFFSET);
254             theme->cardCalendarTheme_.scheduleMarkerXAxisOffset =
255                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_XAXIS_OFFSET);
256             theme->cardCalendarTheme_.scheduleMarkerYAxisOffset =
257                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_YAXIS_OFFSET);
258             theme->cardCalendarTheme_.lunarHeight = themeConstants->GetDimension(THEME_CALENDAR_LUNAR_HEIGHT);
259             theme->cardCalendarTheme_.underscoreWidth = themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_WIDTH);
260             theme->cardCalendarTheme_.underscoreLength = themeConstants->GetDimension(THEME_CALENDAR_UNDERSCORE_LENGTH);
261             theme->cardCalendarTheme_.scheduleMarkerRadius =
262                 themeConstants->GetDimension(THEME_CALENDAR_SCHEDULE_MARKER_RADIUS);
263             theme->cardCalendarTheme_.boundaryColOffset =
264                 themeConstants->GetDimension(THEME_CARD_CALENDAR_BOUNDARY_COL_OFFSET);
265             ParsePattern(themeConstants->GetThemeStyle(), theme);
266             return theme;
267         }
268     private:
ParsePattern(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<CalendarTheme> & theme)269         void ParsePattern(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<CalendarTheme>& theme) const
270         {
271             if (!themeStyle) {
272                 LOGW("Calendar parse pattern failed, themeStyle is invalid.");
273                 return;
274             }
275             auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>(THEME_PATTERN_CALENDAR, nullptr);
276             if (!pattern) {
277                 LOGW("find pattern of calendar fail");
278                 return;
279             }
280             // Card theme
281             theme->cardCalendarTheme_.focusedAreaBackgroundColor =
282                 pattern->GetAttr<Color>("card_area_bg_color_focused", Color::BLUE);
283             theme->cardCalendarTheme_.dayColor =
284                 pattern->GetAttr<Color>("card_day_color", DEFAULT_DAY_COLOR);
285             theme->cardCalendarTheme_.weekColor =
286                 pattern->GetAttr<Color>("card_week_color", Color::BLACK);
287             theme->cardCalendarTheme_.nonCurrentMonthDayColor =
288                 pattern->GetAttr<Color>("card_uncurrent_month_day_color", DEFAULT_NON_CURRENT_MONTH_DAY_COLOR);
289             theme->cardCalendarTheme_.weekendDayColor =
290                 pattern->GetAttr<Color>("card_weekend_color", DEFAULT_WEEKEND_DAY_COLOR);
291             theme->cardCalendarTheme_.weekendLunarColor =
292                 pattern->GetAttr<Color>("card_weekend_lunar_color", DEFAULT_WEEKEND_LUNAR_COLOR);
293             theme->cardCalendarTheme_.nonCurrentMonthLunarColor =
294                 pattern->GetAttr<Color>("card_uncurrent_month_lunar_color", DEFAULT_NON_CURRENT_MONTH_LUNAR_COLOR);
295             theme->cardCalendarTheme_.todayColor =
296                 pattern->GetAttr<Color>("card_today_color", Color::WHITE);
297             theme->cardCalendarTheme_.todayLunarColor =
298                 pattern->GetAttr<Color>("card_today_lunar_color", Color::WHITE);
299             theme->cardCalendarTheme_.lunarColor =
300                 pattern->GetAttr<Color>("card_lunar_color", DEFAULT_LUNAR_COLOR);
301             theme->cardCalendarTheme_.markLunarColor =
302                 pattern->GetAttr<Color>("card_mark_lunar_color", Color::BLUE);
303             theme->cardCalendarTheme_.titleTextColor =
304                 pattern->GetAttr<Color>("card_title_text_color", Color::BLACK);
305             theme->cardCalendarTheme_.clickEffectColor =
306                 pattern->GetAttr<Color>("card_switch_button_bg_color_clicked", Color::TRANSPARENT);
307 
308             // Normal theme
309             theme->calendarTheme_.dayColor =
310                 pattern->GetAttr<Color>(CALENDAR_DAY_COLOR, DEFAULT_CALENDAR_DAY_COLOR);
311             theme->calendarTheme_.weekColor =
312                 pattern->GetAttr<Color>(CALENDAR_WEEK_COLOR, DEFAULT_CALENDAR_WEEK_COLOR);
313             theme->calendarTheme_.lunarColor =
314                 pattern->GetAttr<Color>(CALENDAR_LUNAR_COLOR, DEFAULT_CALENDAR_LUNAR_COLOR);
315             theme->calendarTheme_.weekendDayColor =
316                 pattern->GetAttr<Color>(CALENDAR_WEEKEND_DAY_COLOR, DEFAULT_CALENDAR_WEEKEND_DAY_COLOR);
317             theme->calendarTheme_.weekendLunarColor =
318                 pattern->GetAttr<Color>(CALENDAR_WEEKEND_LUNAR_COLOR, DEFAULT_CALENDAR_WEEKEND_LUNAR_COLOR);
319             theme->calendarTheme_.focusedDayColor =
320                 pattern->GetAttr<Color>(CALENDAR_TODAY_DAY_FOCUS_COLOR, DEFAULT_CALENDAR_TODAY_DAY_FOCUS_COLOR);
321             theme->calendarTheme_.focusedLunarColor =
322                 pattern->GetAttr<Color>(CALENDAR_TODAY_LUNAR_FOCUS_COLOR, DEFAULT_CALENDAR_TODAY_LUNAR_FOCUS_COLOR);
323             theme->calendarTheme_.todayColor =
324                 pattern->GetAttr<Color>(CALENDAR_TODAY_DAY_UNFOCUS_COLOR, DEFAULT_CALENDAR_TODAY_DAY_UNFOCUS_COLOR);
325             theme->calendarTheme_.todayLunarColor =
326                 pattern->GetAttr<Color>(CALENDAR_TODAY_LUNAR_UNFOCUS_COLOR, DEFAULT_CALENDAR_TODAY_LUNAR_UNFOCUS_COLOR);
327             theme->calendarTheme_.workDayMarkColor =
328                 pattern->GetAttr<Color>(CALENDAR_WORK_MARK_COLOR, DEFAULT_CALENDAR_WORK_MARK_COLOR);
329             theme->calendarTheme_.offDayMarkColor =
330                 pattern->GetAttr<Color>(CALENDAR_OFF_MARK_COLOR, DEFAULT_CALENDAR_OFF_MARK_COLOR);
331             theme->calendarTheme_.nonCurrentMonthWorkDayMarkColor = pattern->GetAttr<Color>(
332                 CALENDAR_NONCURRENT_MONTH_WORK_MARK_COLOR, DEFAULT_CALENDAR_NONCURRENT_MONTH_WORK_MARK_COLOR);
333             theme->calendarTheme_.nonCurrentMonthOffDayMarkColor = pattern->GetAttr<Color>(
334                 CALENDAR_NONCURRENT_MONTH_OFF_MARK_COLOR, DEFAULT_CALENDAR_NONCURRENT_MONTH_OFF_MARK_COLOR);
335             theme->calendarTheme_.nonCurrentMonthDayColor = pattern->GetAttr<Color>(
336                 CALENDAR_NONCURRENT_MONTH_DAY_COLOR, DEFAULT_CALENDAR_NONCURRENT_MONTH_DAY_COLOR);
337             theme->calendarTheme_.nonCurrentMonthLunarColor = pattern->GetAttr<Color>(
338                 CALENDAR_NONCURRENT_MONTH_LUNAR_COLOR, DEFAULT_CALENDAR_NONCURRENT_MONTH_LUNAR_COLOR);
339             theme->calendarTheme_.focusedAreaBackgroundColor = pattern->GetAttr<Color>(
340                 CALENDAR_FOCUS_AREA_BACKGROUND_COLOR, DEFAULT_CALENDAR_FOCUS_AREA_BACKGROUND_COLOR);
341             theme->calendarTheme_.blurAreaBackgroundColor = pattern->GetAttr<Color>(
342                 CALENDAR_BLUR_AREA_BACKGROUND_COLOR, DEFAULT_CALENDAR_BLUR_AREA_BACKGROUND_COLOR);
343             // calendar picker
344             theme->entryBorderColor_ = pattern->GetAttr<Color>("calendar_picker_entry_border_color", Color());
345             theme->entryArrowColor_ = pattern->GetAttr<Color>("calendar_picker_entry_arrow_color", Color());
346             theme->selectBackgroundColor_ = pattern->GetAttr<Color>(
347                 "calendar_picker_select_background_color", Color());
348             theme->dialogBackgroundColor_ = pattern->GetAttr<Color>(
349                 "calendar_picker_dialog_background_color", Color());
350             theme->calendarTitleFontColor_ = pattern->GetAttr<Color>("calendar_picker_title_font_color", Color());
351             Color currentMonthColor = pattern->GetAttr<Color>("calendar_picker_title_font_color", Color());
352             theme->textCurrentMonthColor_ = currentMonthColor.BlendOpacity(
353                 pattern->GetAttr<double>("calendar_picker_attribute_alpha_content_primary", 0.0));
354             theme->textNonCurrentMonthColor_ = currentMonthColor.BlendOpacity(
355                 pattern->GetAttr<double>("calendar_picker_attribute_alpha_content_tertiary", 0.0));
356             theme->textSelectedDayColor_ = pattern->GetAttr<Color>(
357                 "calendar_picker_text_selected_day_color", Color());
358             theme->textCurrentDayColor_ = pattern->GetAttr<Color>("calendar_picker_text_current_day_color", Color());
359             theme->backgroundKeyFocusedColor_ = pattern->GetAttr<Color>(
360                 "calendar_picker_background_key_focused_color", Color());
361             Color backgroundSelectedTodayColor = pattern->GetAttr<Color>(
362                 "calendar_picker_background_selected_focused_color", Color());
363             theme->dialogButtonBackgroundColor_ = pattern->GetAttr<Color>(
364                 "calendar_picker_dialog_button_bg_color", Color());
365             theme->backgroundSelectedTodayColor_ = backgroundSelectedTodayColor;
366             theme->backgroundSelectedNotTodayColor_ = backgroundSelectedTodayColor.BlendOpacity(
367                 pattern->GetAttr<double>("calendar_picker_attribute_alpha_highlight_bg", 0.0));
368             theme->backgroundHoverColor_ = pattern->GetAttr<Color>("calendar_picker_background_hover_color", Color());
369             theme->backgroundPressColor_ = pattern->GetAttr<Color>("calendar_picker_background_press_color", Color());
370             theme->entryFontColor_ = pattern->GetAttr<Color>("calendar_picker_entry_font_color", Color());
371             theme->dialogDividerColor_ = pattern->GetAttr<Color>("calendar_picker_dialog_divider_color", Color());
372             theme->entryHeight_ = pattern->GetAttr<Dimension>("calendar_picker_entry_height", 0.0_vp);
373             theme->entryBorderWidth_ = pattern->GetAttr<Dimension>("calendar_picker_entry_border_width", 0.0_vp);
374             theme->entryBorderRadius_ = pattern->GetAttr<Dimension>("calendar_picker_entry_border_radius", 0.0_vp);
375             theme->entryButtonWidth_ = pattern->GetAttr<Dimension>("calendar_picker_entry_button_width", 0.0_vp);
376             theme->entryArrowHeight_ = pattern->GetAttr<Dimension>("calendar_picker_entry_arrow_height", 0.0_vp);
377             theme->entryArrowwidth_ = pattern->GetAttr<Dimension>("calendar_picker_entry_arrow_width", 0.0_vp);
378             theme->entryDateLeftRightMargin_ = pattern->GetAttr<Dimension>(
379                 "calendar_picker_entry_date_left_right_margin", 0.0_vp);
380             theme->entryDateTopBottomMargin_ = pattern->GetAttr<Dimension>(
381                 "calendar_picker_entry_date_top_bottom_margin", 0.0_vp);
382             theme->dialogMargin_ = pattern->GetAttr<Dimension>("calendar_picker_dialog_margin", 0.0_vp);
383             theme->calendarPickerDayWidthOrHeight_ = pattern->GetAttr<Dimension>(
384                 "calendar_picker_day_width_height", 0.0_vp);
385             theme->calendarDayFontSize_ = pattern->GetAttr<Dimension>("calendar_picker_day_font_size", 0.0_vp);
386             theme->distanceBetweenContainterAndDate_ = pattern->GetAttr<Dimension>(
387                 "calendar_picker_distance_between_container_and_date", 0.0_vp);
388             theme->distanceBetweenTitleAndDate_ = pattern->GetAttr<Dimension>(
389                 "calendar_picker_distance_between_title_and_date", 0.0_vp);
390             theme->dalendarContainerHeight_ = pattern->GetAttr<Dimension>("calendar_picker_container_height", 0.0_vp);
391             theme->calendarTitleFontSize_ = pattern->GetAttr<Dimension>("calendar_picker_title_font_size", 0.0_vp);
392             theme->calendarTitleRowHeight_ = pattern->GetAttr<Dimension>("calendar_picker_title_row_height", 0.0_vp);
393             theme->calendarTitleRowTopPadding_ = pattern->GetAttr<Dimension>(
394                 "calendar_picker_title_row_top_padding", 0.0_vp);
395             theme->calendarTitleRowLeftRightPadding_ = pattern->GetAttr<Dimension>(
396                 "calendar_picker_title_row_left_right_padding", 0.0_vp);
397             theme->calendarTitleTextPadding_ = pattern->GetAttr<Dimension>(
398                 "calendar_picker_title_text_padding", 0.0_vp);
399             theme->calendarTitleImagePadding_ = pattern->GetAttr<Dimension>(
400                 "calendar_picker_title_image_padding", 0.0_vp);
401             theme->calendarImageWidthHeight_ = pattern->GetAttr<Dimension>(
402                 "calendar_picker_image_width_height", 0.0_vp);
403             theme->calendarActionRowTopPadding_ = pattern->GetAttr<Dimension>(
404                 "calendar_picker_action_row_top_padding", 0.0_vp);
405             theme->calendarActionRowBottomLeftRightPadding_ = pattern->GetAttr<Dimension>(
406                 "calendar_picker_action_row_bottom_left_right_padding", 0.0_vp);
407             theme->calendarActionRowHeight_ = pattern->GetAttr<Dimension>("calendar_picker_action_row_height", 0.0_vp);
408             theme->calendarDayRadius_ = pattern->GetAttr<Dimension>("calendar_picker_day_radius", 0.0_vp);
409             theme->calendarDayKeyFocusedWidth_ = pattern->GetAttr<Dimension>("calendar_day_key_focused_width", 0.0_vp);
410             theme->calendarDayKeyFocusedPenWidth_ = pattern->GetAttr<Dimension>(
411                 "calendar_day_key_focused_pen_width", 0.0_vp);
412             theme->entryFontSize_ = pattern->GetAttr<Dimension>("calendar_picker_entry_font_size", 0.0_fp);
413             theme->dialogBorderRadius_ = pattern->GetAttr<Dimension>("calendar_picker_dialog_border_radius", 0.0_vp);
414         }
415     };
416 
GetCalendarTheme()417     CalendarThemeStructure& GetCalendarTheme()
418     {
419         return calendarTheme_;
420     }
421 
GetCardCalendarTheme()422     CalendarThemeStructure& GetCardCalendarTheme()
423     {
424         return cardCalendarTheme_;
425     }
426 
GetEntryHeight()427     const Dimension& GetEntryHeight() const
428     {
429         return entryHeight_;
430     }
431 
GetEntryBorderWidth()432     const Dimension& GetEntryBorderWidth() const
433     {
434         return entryBorderWidth_;
435     }
436 
GetEntryBorderColor()437     const Color& GetEntryBorderColor() const
438     {
439         return entryBorderColor_;
440     }
441 
GetEntryBorderRadius()442     const Dimension& GetEntryBorderRadius() const
443     {
444         return entryBorderRadius_;
445     }
446 
GetEntryButtonWidth()447     const Dimension& GetEntryButtonWidth() const
448     {
449         return entryButtonWidth_;
450     }
451 
GetEntryDateTopBottomMargin()452     const Dimension& GetEntryDateTopBottomMargin() const
453     {
454         return entryDateTopBottomMargin_;
455     }
456 
GetEntryDateLeftRightMargin()457     const Dimension& GetEntryDateLeftRightMargin() const
458     {
459         return entryDateLeftRightMargin_;
460     }
461 
GetEntryArrowWidth()462     const Dimension& GetEntryArrowWidth() const
463     {
464         return entryArrowwidth_;
465     }
466 
GetEntryArrowHeight()467     const Dimension& GetEntryArrowHeight() const
468     {
469         return entryArrowHeight_;
470     }
471 
GetEntryArrowColor()472     const Color& GetEntryArrowColor() const
473     {
474         return entryArrowColor_;
475     }
476 
GetDialogMargin()477     const Dimension& GetDialogMargin() const
478     {
479         return dialogMargin_;
480     }
481 
GetSelectBackgroundColor()482     const Color& GetSelectBackgroundColor() const
483     {
484         return selectBackgroundColor_;
485     }
486 
GetCalendarPickerDayWidthOrHeight()487     const Dimension& GetCalendarPickerDayWidthOrHeight() const
488     {
489         return calendarPickerDayWidthOrHeight_;
490     }
491 
GetCalendarDayFontSize()492     const Dimension& GetCalendarDayFontSize() const
493     {
494         return calendarDayFontSize_;
495     }
496 
GetDistanceBetweenContainterAndDate()497     const Dimension& GetDistanceBetweenContainterAndDate() const
498     {
499         return distanceBetweenContainterAndDate_;
500     }
501 
GetDistanceBetweenTitleAndDate()502     const Dimension& GetDistanceBetweenTitleAndDate() const
503     {
504         return distanceBetweenTitleAndDate_;
505     }
506 
GetCalendarContainerHeight()507     const Dimension& GetCalendarContainerHeight() const
508     {
509         return dalendarContainerHeight_;
510     }
511 
GetCalendarTitleFontSize()512     const Dimension& GetCalendarTitleFontSize() const
513     {
514         return calendarTitleFontSize_;
515     }
516 
GetCalendarTitleRowHeight()517     const Dimension& GetCalendarTitleRowHeight() const
518     {
519         return calendarTitleRowHeight_;
520     }
521 
GetCalendarTitleRowTopPadding()522     const Dimension& GetCalendarTitleRowTopPadding() const
523     {
524         return calendarTitleRowTopPadding_;
525     }
526 
GetCalendarTitleRowLeftRightPadding()527     const Dimension& GetCalendarTitleRowLeftRightPadding() const
528     {
529         return calendarTitleRowLeftRightPadding_;
530     }
531 
GetCalendarTitleTextPadding()532     const Dimension& GetCalendarTitleTextPadding() const
533     {
534         return calendarTitleTextPadding_;
535     }
536 
GetCalendarTitleImagePadding()537     const Dimension& GetCalendarTitleImagePadding() const
538     {
539         return calendarTitleImagePadding_;
540     }
541 
GetCalendarImageWidthHeight()542     const Dimension& GetCalendarImageWidthHeight() const
543     {
544         return calendarImageWidthHeight_;
545     }
546 
GetCalendarActionRowTopPadding()547     const Dimension& GetCalendarActionRowTopPadding() const
548     {
549         return calendarActionRowTopPadding_;
550     }
551 
GetCalendarActionRowBottomLeftRightPadding()552     const Dimension& GetCalendarActionRowBottomLeftRightPadding() const
553     {
554         return calendarActionRowBottomLeftRightPadding_;
555     }
556 
GetCalendarActionRowHeight()557     const Dimension& GetCalendarActionRowHeight() const
558     {
559         return calendarActionRowHeight_;
560     }
561 
GetCalendarDayRadius()562     const Dimension& GetCalendarDayRadius() const
563     {
564         return calendarDayRadius_;
565     }
566 
GetCalendarDayKeyFocusedWidth()567     const Dimension& GetCalendarDayKeyFocusedWidth() const
568     {
569         return calendarDayKeyFocusedWidth_;
570     }
571 
GetCalendarDayKeyFocusedPenWidth()572     const Dimension& GetCalendarDayKeyFocusedPenWidth() const
573     {
574         return calendarDayKeyFocusedPenWidth_;
575     }
576 
GetEntryFontSize()577     const Dimension& GetEntryFontSize() const
578     {
579         return entryFontSize_;
580     }
581 
GetDialogBorderRadius()582     const Dimension& GetDialogBorderRadius() const
583     {
584         return dialogBorderRadius_;
585     }
586 
GetDialogBackgroundColor()587     const Color& GetDialogBackgroundColor() const
588     {
589         return dialogBackgroundColor_;
590     }
591 
GetCalendarTitleFontColor()592     const Color& GetCalendarTitleFontColor() const
593     {
594         return calendarTitleFontColor_;
595     }
596 
GetTextCurrentMonthColor()597     const Color& GetTextCurrentMonthColor() const
598     {
599         return textCurrentMonthColor_;
600     }
601 
GetTextNonCurrentMonthColor()602     const Color& GetTextNonCurrentMonthColor() const
603     {
604         return textNonCurrentMonthColor_;
605     }
606 
GetTextSelectedDayColor()607     const Color& GetTextSelectedDayColor() const
608     {
609         return textSelectedDayColor_;
610     }
611 
GetTextCurrentDayColor()612     const Color& GetTextCurrentDayColor() const
613     {
614         return textCurrentDayColor_;
615     }
616 
GetBackgroundKeyFocusedColor()617     const Color& GetBackgroundKeyFocusedColor() const
618     {
619         return backgroundKeyFocusedColor_;
620     }
621 
GetBackgroundSelectedTodayColor()622     const Color& GetBackgroundSelectedTodayColor() const
623     {
624         return backgroundSelectedTodayColor_;
625     }
626 
GetBackgroundSelectedNotTodayColor()627     const Color& GetBackgroundSelectedNotTodayColor() const
628     {
629         return backgroundSelectedNotTodayColor_;
630     }
631 
GetBackgroundHoverColor()632     const Color& GetBackgroundHoverColor() const
633     {
634         return backgroundHoverColor_;
635     }
636 
GetBackgroundPressColor()637     const Color& GetBackgroundPressColor() const
638     {
639         return backgroundPressColor_;
640     }
641 
GetEntryFontColor()642     const Color& GetEntryFontColor() const
643     {
644         return entryFontColor_;
645     }
646 
GetDialogDividerColor()647     const Color& GetDialogDividerColor() const
648     {
649         return dialogDividerColor_;
650     }
651 
GetDialogButtonBackgroundColor()652     const Color& GetDialogButtonBackgroundColor() const
653     {
654         return dialogButtonBackgroundColor_;
655     }
656 protected:
657     CalendarTheme() = default;
658 
659 private:
660     CalendarThemeStructure calendarTheme_;
661     CalendarThemeStructure cardCalendarTheme_;
662     Color entryBorderColor_;
663     Color entryArrowColor_;
664     Color selectBackgroundColor_;
665     Color dialogBackgroundColor_;
666     Color calendarTitleFontColor_;
667     Color textCurrentMonthColor_;
668     Color textNonCurrentMonthColor_;
669     Color textSelectedDayColor_;
670     Color textCurrentDayColor_;
671     Color backgroundKeyFocusedColor_;
672     Color backgroundSelectedTodayColor_;
673     Color backgroundSelectedNotTodayColor_;
674     Color backgroundHoverColor_;
675     Color backgroundPressColor_;
676     Color entryFontColor_;
677     Color dialogDividerColor_;
678     Color dialogButtonBackgroundColor_;
679     Dimension entryHeight_;
680     Dimension entryBorderWidth_;
681     Dimension entryBorderRadius_;
682     Dimension entryButtonWidth_;
683     Dimension entryArrowHeight_;
684     Dimension entryArrowwidth_;
685     Dimension entryDateLeftRightMargin_;
686     Dimension entryDateTopBottomMargin_;
687     Dimension dialogMargin_;
688     Dimension calendarPickerDayWidthOrHeight_;
689     Dimension calendarDayFontSize_;
690     Dimension distanceBetweenContainterAndDate_;
691     Dimension distanceBetweenTitleAndDate_;
692     Dimension dalendarContainerHeight_;
693     Dimension calendarTitleFontSize_;
694     Dimension calendarTitleRowHeight_;
695     Dimension calendarTitleRowTopPadding_;
696     Dimension calendarTitleRowLeftRightPadding_;
697     Dimension calendarTitleTextPadding_;
698     Dimension calendarTitleImagePadding_;
699     Dimension calendarImageWidthHeight_;
700     Dimension calendarActionRowTopPadding_;
701     Dimension calendarActionRowBottomLeftRightPadding_;
702     Dimension calendarActionRowHeight_;
703     Dimension calendarDayRadius_;
704     Dimension calendarDayKeyFocusedWidth_;
705     Dimension calendarDayKeyFocusedPenWidth_;
706     Dimension entryFontSize_;
707     Dimension dialogBorderRadius_;
708 };
709 
710 } // namespace OHOS::Ace
711 
712 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_CALENDAR_THEME_H
713