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_PICKER_PICKER_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_THEME_H 18 19 #include "base/geometry/dimension.h" 20 #include "base/utils/system_properties.h" 21 #include "core/components/common/layout/constants.h" 22 #include "core/components/common/properties/border.h" 23 #include "core/components/common/properties/color.h" 24 #include "core/components/common/properties/decoration.h" 25 #include "core/components/common/properties/edge.h" 26 #include "core/components/common/properties/text_style.h" 27 #include "core/components/picker/picker_data.h" 28 #include "core/components/theme/theme.h" 29 #include "core/components/theme/theme_constants.h" 30 #include "core/components/theme/theme_constants_defines.h" 31 32 namespace OHOS::Ace { 33 namespace { 34 constexpr Dimension DIVIDER_THICKNESS = 1.0_px; 35 } // namespace 36 37 class PickerTheme final : public virtual Theme { 38 DECLARE_ACE_TYPE(PickerTheme, Theme); 39 40 public: 41 class Builder final { 42 public: 43 Builder() = default; 44 ~Builder() = default; 45 Build(const RefPtr<ThemeConstants> & themeConstants)46 RefPtr<PickerTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 47 { 48 RefPtr<PickerTheme> theme = AceType::Claim(new PickerTheme()); 49 if (!themeConstants) { 50 return theme; 51 } 52 53 auto themeStyle = themeConstants->GetThemeStyle(); 54 if (!themeStyle) { 55 return theme; 56 } 57 58 InitializeTextStyles(theme, themeStyle); 59 theme->optionSizeUnit_ = DimensionUnit::VP; 60 theme->lunarWidth_ = Dimension(36.0, DimensionUnit::VP); // this width do not need setting by outer. 61 theme->lunarHeight_ = Dimension(18.0, DimensionUnit::VP); // this height do not need setting by outer. 62 theme->rotateInterval_ = 15.0; // when rotate 15.0 angle handle scroll of picker column. 63 theme->dividerThickness_ = DIVIDER_THICKNESS; 64 Parse(themeStyle, theme); 65 return theme; 66 } 67 Parse(const RefPtr<ThemeStyle> & style,const RefPtr<PickerTheme> & theme)68 void Parse(const RefPtr<ThemeStyle>& style, const RefPtr<PickerTheme>& theme) const 69 { 70 if (!style || !theme) { 71 return; 72 } 73 auto pattern = style->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 74 if (!pattern) { 75 LOGE("Pattern of picker is null, please check!"); 76 return; 77 } 78 79 theme->popupDecoration_ = AceType::MakeRefPtr<Decoration>(); 80 if (!theme->popupDecoration_) { 81 return; 82 } 83 theme->popupDecoration_->SetBackgroundColor(pattern->GetAttr<Color>("popup_bg_color", Color())); 84 theme->popupDecoration_->SetBorderRadius( 85 Radius(pattern->GetAttr<Dimension>("picker_popup_radius", 0.0_vp))); 86 theme->popupEdge_.SetLeft(pattern->GetAttr<Dimension>("picker_popup_padding", 0.0_vp)); 87 theme->popupEdge_.SetTop(pattern->GetAttr<Dimension>("picker_popup_padding", 0.0_vp)); 88 theme->popupEdge_.SetRight(pattern->GetAttr<Dimension>("picker_popup_padding", 0.0_vp)); 89 theme->popupEdge_.SetBottom(pattern->GetAttr<Dimension>("picker_popup_padding_bottom", 0.0_vp)); 90 auto showOptionCount = static_cast<int32_t>(pattern->GetAttr<double>("picker_show_option_count", 0.0)); 91 theme->showOptionCount_ = 92 showOptionCount < 0 ? theme->showOptionCount_ : static_cast<uint32_t>(showOptionCount); 93 theme->showButtons_ = static_cast<bool>(pattern->GetAttr<double>("picker_show_buttons", 0.0)); 94 theme->focusColor_ = pattern->GetAttr<Color>("picker_focus_color", Color()); 95 theme->focusRadius_ = Radius(pattern->GetAttr<Dimension>("picker_focus_radius", 0.0_vp)); 96 theme->selectedOptionSize_ = Size(pattern->GetAttr<double>("picker_option_width", 0.0), 97 pattern->GetAttr<double>("picker_select_option_height", 0.0)); 98 theme->normalOptionSize_ = Size(pattern->GetAttr<double>("picker_option_width", 0.0), 99 pattern->GetAttr<double>("picker_normal_option_height", 0.0)); 100 theme->optionPadding_ = pattern->GetAttr<double>("picker_option_padding", 0.0); 101 theme->jumpInterval_ = pattern->GetAttr<Dimension>("picker_jump_interval", 0.0_vp); 102 theme->columnIntervalMargin_ = pattern->GetAttr<Dimension>("picker_column_margin", 0.0_vp); 103 theme->selectedOptionDecoration_ = AceType::MakeRefPtr<Decoration>(); 104 if (!theme->selectedOptionDecoration_) { 105 return; 106 } 107 theme->selectedOptionDecoration_->SetBackgroundColor( 108 pattern->GetAttr<Color>("picker_select_option_back_color", Color())); 109 theme->selectedOptionDecoration_->SetBorderRadius( 110 Radius(pattern->GetAttr<Dimension>("picker_select_option_radius", 0.0_vp))); 111 theme->focusOptionDecoration_ = AceType::MakeRefPtr<Decoration>(); 112 if (!theme->focusOptionDecoration_) { 113 return; 114 } 115 theme->focusOptionDecoration_->SetBackgroundColor( 116 pattern->GetAttr<Color>("picker_focus_option_back_color", Color())); 117 theme->focusOptionDecoration_->SetBorderRadius( 118 Radius(pattern->GetAttr<Dimension>("picker_focus_option_radius", 0.0_vp))); 119 theme->buttonWidth_ = pattern->GetAttr<Dimension>("picker_button_width", 0.0_vp); 120 theme->buttonHeight_ = pattern->GetAttr<Dimension>("picker_button_height", 0.0_vp); 121 theme->buttonTopPadding_ = pattern->GetAttr<Dimension>("picker_button_top_padding", 0.0_vp); 122 theme->titleBottomPadding_ = pattern->GetAttr<Dimension>("picker_title_bottom_padding", 0.0_vp); 123 theme->popupOutDecoration_ = AceType::MakeRefPtr<Decoration>(); 124 if (!theme->popupOutDecoration_) { 125 return; 126 } 127 theme->popupOutDecoration_->SetBackgroundColor( 128 pattern->GetAttr<Color>("picker_dialog_mask_color", Color())); 129 auto timeSplitter = static_cast<int32_t>(pattern->GetAttr<double>("picker_time_splitter", 0.0)); 130 theme->timeSplitter_ = timeSplitter < 0 ? theme->timeSplitter_ : static_cast<uint32_t>(timeSplitter); 131 theme->dividerSpacing_ = pattern->GetAttr<Dimension>("picker_select_divider_spacing", 0.0_vp); 132 theme->dividerColor_ = pattern->GetAttr<Color>("picker_select_divider_color", Color()); 133 theme->gradientHeight_ = pattern->GetAttr<Dimension>("picker_select_gradient_height", 0.0_vp); 134 theme->columnFixedWidth_ = pattern->GetAttr<Dimension>("picker_column_fixed_width", 0.0_vp); 135 theme->pressColor_ = pattern->GetAttr<Color>("picker_press_color", Color()); 136 theme->hoverColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_HOVERED, theme->hoverColor_); 137 theme->pressColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_PRESSED, theme->pressColor_); 138 theme->paddingHorizontal_ = pattern->GetAttr<Dimension>("padding_horizontal", 24.0_vp); 139 theme->popupDecoration_->SetBackgroundColor( 140 pattern->GetAttr<Color>("popup_bg_color", theme->popupDecoration_->GetBackgroundColor())); 141 theme->focusColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_FOCUSED, theme->focusColor_); 142 theme->selectedOptionStyle_.SetTextColor( 143 pattern->GetAttr<Color>("selected_text_color", theme->selectedOptionStyle_.GetTextColor())); 144 theme->focusOptionStyle_.SetTextColor(theme->selectedOptionStyle_.GetTextColor()); 145 theme->normalOptionStyle_.SetTextColor( 146 pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, theme->normalOptionStyle_.GetTextColor())); 147 theme->disappearOptionStyle_.SetTextColor(theme->normalOptionStyle_.GetTextColor()); 148 theme->titleStyle_.SetTextColor(theme->normalOptionStyle_.GetTextColor()); 149 theme->dividerColor_ = pattern->GetAttr<Color>("divider_color", theme->dividerColor_); 150 theme->dividerThickness_ = pattern->GetAttr<Dimension>("divider_thickness", 2.0_px); 151 theme->contentMarginVertical_ = pattern->GetAttr<Dimension>("content_margin_vertical", 8.0_vp); 152 theme->lunarswitchTextSize_ = 153 pattern->GetAttr<Dimension>("lunarswitch_text_size", theme->lunarswitchTextSize_); 154 theme->lunarswitchTextColor_ = 155 pattern->GetAttr<Color>("lunarswitch_text_color", theme->lunarswitchTextColor_); 156 } 157 158 private: InitializeButtonTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)159 void InitializeButtonTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 160 { 161 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 162 if (pattern) { 163 theme->buttonStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_button_font_size", 0.0_fp)); 164 theme->buttonStyle_.SetTextColor(pattern->GetAttr<Color>("picker_button_text_color", Color())); 165 } 166 } 167 InitializeTitleTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)168 void InitializeTitleTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 169 { 170 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 171 if (pattern) { 172 theme->titleStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_title_font_size", 0.0_fp)); 173 theme->titleStyle_.SetTextColor(pattern->GetAttr<Color>("picker_title_text_color", Color())); 174 } 175 theme->titleStyle_.SetFontWeight(FontWeight::W500); 176 theme->titleStyle_.SetMaxLines(1); 177 theme->titleStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 178 } 179 InitializeItemTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)180 void InitializeItemTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 181 { 182 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 183 if (pattern) { 184 theme->selectedOptionStyle_.SetTextColor( 185 pattern->GetAttr<Color>("selected_text_color", Color(0x007DFF))); 186 theme->selectedOptionStyle_.SetFontSize( 187 pattern->GetAttr<Dimension>("selected_text_size", 20.0_vp)); 188 theme->selectedOptionStyle_.SetFontWeight(FontWeight::MEDIUM); 189 theme->selectedOptionStyle_.SetAdaptTextSize(theme->selectedOptionStyle_.GetFontSize(), 190 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 191 theme->selectedOptionStyle_.SetMaxLines(1); 192 theme->selectedOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 193 194 theme->normalOptionStyle_.SetTextColor( 195 pattern->GetAttr<Color>("text_color", Color(0xff182431))); 196 theme->normalOptionStyle_.SetFontSize( 197 pattern->GetAttr<Dimension>("text_size", 16.0_fp)); 198 theme->normalOptionStyle_.SetFontWeight(FontWeight::REGULAR); 199 theme->normalOptionStyle_.SetAdaptTextSize(theme->normalOptionStyle_.GetFontSize(), 200 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 201 theme->normalOptionStyle_.SetMaxLines(1); 202 theme->normalOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 203 204 theme->disappearOptionStyle_.SetTextColor( 205 pattern->GetAttr<Color>("disappear_text_color", Color(0xff182431))); 206 theme->disappearOptionStyle_.SetFontSize( 207 pattern->GetAttr<Dimension>("disappear_text_size", 14.0_fp)); 208 theme->disappearOptionStyle_.SetFontWeight(FontWeight::REGULAR); 209 theme->disappearOptionStyle_.SetAdaptTextSize(theme->disappearOptionStyle_.GetFontSize(), 210 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 211 theme->disappearOptionStyle_.SetMaxLines(1); 212 theme->disappearOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 213 } 214 215 theme->focusOptionStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_focus_option_font_size", 0.0_fp)); 216 theme->focusOptionStyle_.SetTextColor(pattern->GetAttr<Color>("picker_focus_option_text_color", Color())); 217 theme->focusOptionStyle_.SetFontWeight( 218 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("picker_focus_option_weight", 0.0)))); 219 theme->focusOptionStyle_.SetAdaptTextSize(theme->focusOptionStyle_.GetFontSize(), 220 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 221 theme->focusOptionStyle_.SetMaxLines(1); 222 theme->focusOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 223 224 if (SystemProperties::GetDeviceType() == DeviceType::PHONE) { 225 theme->focusOptionStyle_ = theme->selectedOptionStyle_; // focus style the same with selected on phone 226 } 227 } 228 InitializeTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)229 void InitializeTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 230 { 231 InitializeItemTextStyles(theme, themeStyle); 232 InitializeTitleTextStyles(theme, themeStyle); 233 InitializeButtonTextStyles(theme, themeStyle); 234 } 235 }; 236 237 ~PickerTheme() override = default; 238 clone()239 RefPtr<PickerTheme> clone() const 240 { 241 auto theme = AceType::Claim(new PickerTheme()); 242 theme->selectedOptionSize_ = selectedOptionSize_; 243 theme->selectedOptionStyle_ = selectedOptionStyle_; 244 theme->normalOptionSize_ = normalOptionSize_; 245 theme->normalOptionStyle_ = normalOptionStyle_; 246 theme->disappearOptionStyle_ = disappearOptionStyle_; 247 theme->showOptionCount_ = showOptionCount_; 248 theme->optionSizeUnit_ = optionSizeUnit_; 249 theme->popupDecoration_ = popupDecoration_; 250 theme->focusColor_ = focusColor_; 251 theme->popupEdge_ = popupEdge_; 252 theme->focusOptionStyle_ = focusOptionStyle_; 253 theme->focusOptionDecoration_ = focusOptionDecoration_; 254 theme->selectedOptionDecoration_ = selectedOptionDecoration_; 255 theme->buttonStyle_ = buttonStyle_; 256 theme->showButtons_ = showButtons_; 257 theme->buttonWidth_ = buttonWidth_; 258 theme->buttonHeight_ = buttonHeight_; 259 theme->buttonTopPadding_ = buttonTopPadding_; 260 theme->jumpInterval_ = jumpInterval_; 261 theme->columnIntervalMargin_ = columnIntervalMargin_; 262 theme->focusRadius_ = focusRadius_; 263 theme->optionPadding_ = optionPadding_; 264 theme->titleStyle_ = titleStyle_; 265 theme->titleBottomPadding_ = titleBottomPadding_; 266 theme->popupOutDecoration_ = popupOutDecoration_; 267 theme->lunarWidth_ = lunarWidth_; 268 theme->lunarHeight_ = lunarHeight_; 269 theme->timeSplitter_ = timeSplitter_; 270 theme->rotateInterval_ = rotateInterval_; 271 theme->dividerThickness_ = dividerThickness_; 272 theme->dividerSpacing_ = dividerSpacing_; 273 theme->dividerColor_ = dividerColor_; 274 theme->gradientHeight_ = gradientHeight_; 275 theme->columnFixedWidth_ = columnFixedWidth_; 276 theme->disappearOptionStyle_ = disappearOptionStyle_; 277 theme->pressColor_ = pressColor_; 278 theme->hoverColor_ = hoverColor_; 279 theme->lunarswitchTextColor_ = lunarswitchTextColor_; 280 theme->lunarswitchTextSize_ = lunarswitchTextSize_; 281 theme->defaultStartDate_ = defaultStartDate_; 282 theme->defaultEndDate_ = defaultEndDate_; 283 return theme; 284 } 285 GetOptionStyle(bool selected,bool focus)286 const TextStyle& GetOptionStyle(bool selected, bool focus) const 287 { 288 if (!selected) { 289 return normalOptionStyle_; 290 } 291 292 if (focus) { 293 return focusOptionStyle_; 294 } 295 296 return selectedOptionStyle_; 297 } SetOptionStyle(bool selected,bool focus,const TextStyle & value)298 void SetOptionStyle(bool selected, bool focus, const TextStyle& value) 299 { 300 if (!selected) { 301 normalOptionStyle_ = value; 302 } else if (focus) { 303 focusOptionStyle_ = value; 304 } else { 305 selectedOptionStyle_ = value; 306 } 307 } 308 GetDisappearOptionStyle()309 const TextStyle& GetDisappearOptionStyle() const 310 { 311 return disappearOptionStyle_; 312 } SetDisappearOptionStyle(const TextStyle & value)313 void SetDisappearOptionStyle(const TextStyle& value) 314 { 315 disappearOptionStyle_ = value; 316 } 317 GetButtonStyle()318 const TextStyle& GetButtonStyle() const 319 { 320 return buttonStyle_; 321 } 322 GetOptionDecoration(bool focus)323 const RefPtr<Decoration>& GetOptionDecoration(bool focus) 324 { 325 if (focus) { 326 return focusOptionDecoration_; 327 } 328 329 return selectedOptionDecoration_; 330 } SetOptionDecoration(bool focus,const RefPtr<Decoration> & value)331 void SetOptionDecoration(bool focus, const RefPtr<Decoration>& value) 332 { 333 if (focus) { 334 focusOptionDecoration_ = value; 335 } else { 336 selectedOptionDecoration_ = value; 337 } 338 } 339 GetOptionSize(bool selected)340 const Size& GetOptionSize(bool selected) const 341 { 342 if (selected) { 343 return selectedOptionSize_; 344 } 345 346 return normalOptionSize_; 347 } 348 GetShowOptionCount()349 uint32_t GetShowOptionCount() const 350 { 351 return showOptionCount_; 352 } 353 GetOptionSizeUnit()354 DimensionUnit GetOptionSizeUnit() const 355 { 356 return optionSizeUnit_; 357 } 358 GetPopupDecoration(bool isOutBox)359 const RefPtr<Decoration>& GetPopupDecoration(bool isOutBox) const 360 { 361 if (!isOutBox) { 362 return popupDecoration_; 363 } 364 return popupOutDecoration_; 365 } 366 GetFocusColor()367 const Color& GetFocusColor() const 368 { 369 return focusColor_; 370 } 371 GetPopupEdge()372 const Edge& GetPopupEdge() const 373 { 374 return popupEdge_; 375 } 376 GetShowButtons()377 bool GetShowButtons() const 378 { 379 return showButtons_; 380 } 381 GetButtonWidth()382 const Dimension& GetButtonWidth() const 383 { 384 return buttonWidth_; 385 } 386 GetButtonHeight()387 const Dimension& GetButtonHeight() const 388 { 389 return buttonHeight_; 390 } 391 GetButtonTopPadding()392 const Dimension& GetButtonTopPadding() const 393 { 394 return buttonTopPadding_; 395 } 396 GetJumpInterval()397 const Dimension& GetJumpInterval() const 398 { 399 return jumpInterval_; 400 } 401 GetColumnIntervalMargin()402 const Dimension& GetColumnIntervalMargin() const 403 { 404 return columnIntervalMargin_; 405 } 406 GetFocusRadius()407 const Radius& GetFocusRadius() const 408 { 409 return focusRadius_; 410 } 411 GetOptionPadding()412 double GetOptionPadding() const 413 { 414 return optionPadding_; 415 } SetOptionPadding(double value)416 void SetOptionPadding(double value) 417 { 418 optionPadding_ = value; 419 } 420 GetTitleStyle()421 const TextStyle& GetTitleStyle() const 422 { 423 return titleStyle_; 424 } 425 GetTitleBottomPadding()426 const Dimension& GetTitleBottomPadding() const 427 { 428 return titleBottomPadding_; 429 } 430 GetLunarWidth()431 const Dimension& GetLunarWidth() const 432 { 433 return lunarWidth_; 434 } 435 GetLunarHeight()436 const Dimension& GetLunarHeight() const 437 { 438 return lunarHeight_; 439 } 440 HasTimeSplitter()441 bool HasTimeSplitter() const 442 { 443 return (timeSplitter_ > 0); 444 } 445 GetRotateInterval()446 double GetRotateInterval() const 447 { 448 return rotateInterval_; 449 } 450 GetDividerThickness()451 const Dimension& GetDividerThickness() const 452 { 453 return dividerThickness_; 454 } 455 GetDividerSpacing()456 const Dimension& GetDividerSpacing() const 457 { 458 return dividerSpacing_; 459 } 460 GetDividerColor()461 const Color& GetDividerColor() const 462 { 463 return dividerColor_; 464 } 465 GetGradientHeight()466 const Dimension& GetGradientHeight() const 467 { 468 return gradientHeight_; 469 } 470 GetColumnFixedWidth()471 const Dimension& GetColumnFixedWidth() const 472 { 473 return columnFixedWidth_; 474 } 475 GetColumnBottomTotalHeight(bool hasLunar)476 Dimension GetColumnBottomTotalHeight(bool hasLunar) const 477 { 478 if (hasLunar) { 479 return buttonHeight_ + lunarHeight_ + buttonTopPadding_ * 2 + popupEdge_.Bottom(); 480 } else { 481 return buttonHeight_ + buttonTopPadding_ + popupEdge_.Bottom(); 482 } 483 } 484 GetPressColor()485 const Color& GetPressColor() const 486 { 487 return pressColor_; 488 } 489 GetHoverColor()490 const Color& GetHoverColor() const 491 { 492 return hoverColor_; 493 } 494 GetPaddingHorizontal()495 const Dimension& GetPaddingHorizontal() const 496 { 497 return paddingHorizontal_; 498 } 499 GetContentMarginVertical()500 const Dimension& GetContentMarginVertical() const 501 { 502 return contentMarginVertical_; 503 } 504 GetLunarSwitchTextSize()505 const Dimension& GetLunarSwitchTextSize() const 506 { 507 return lunarswitchTextSize_; 508 } 509 GetLunarSwitchTextColor()510 const Color& GetLunarSwitchTextColor() const 511 { 512 return lunarswitchTextColor_; 513 } 514 GetDefaultStartDate()515 const PickerDate& GetDefaultStartDate() const 516 { 517 return defaultStartDate_; 518 } 519 GetDefaultEndDate()520 const PickerDate& GetDefaultEndDate() const 521 { 522 return defaultEndDate_; 523 } 524 525 private: 526 PickerTheme() = default; 527 528 Color focusColor_; 529 Color hoverColor_; 530 Color pressColor_; 531 Color lunarswitchTextColor_; 532 533 Radius focusRadius_; 534 uint32_t showOptionCount_ = 0; 535 bool showButtons_ = false; 536 Dimension jumpInterval_; 537 538 // popup style 539 RefPtr<Decoration> popupDecoration_; 540 RefPtr<Decoration> popupOutDecoration_; 541 Edge popupEdge_; 542 543 // column 544 Dimension columnIntervalMargin_; 545 546 // text style 547 TextStyle focusOptionStyle_; 548 TextStyle selectedOptionStyle_; 549 TextStyle normalOptionStyle_; 550 TextStyle disappearOptionStyle_; 551 TextStyle buttonStyle_; 552 TextStyle titleStyle_; 553 554 // text around decoration 555 RefPtr<Decoration> selectedOptionDecoration_; 556 RefPtr<Decoration> focusOptionDecoration_; 557 558 // option size 559 Size selectedOptionSize_; 560 Size normalOptionSize_; 561 double optionPadding_ = 0.0; 562 DimensionUnit optionSizeUnit_ = DimensionUnit::PX; 563 564 // buttons size 565 Dimension buttonWidth_; 566 Dimension buttonHeight_; 567 Dimension buttonTopPadding_; 568 Dimension titleBottomPadding_; 569 570 // lunar size 571 Dimension lunarWidth_; 572 Dimension lunarHeight_; 573 574 uint32_t timeSplitter_ = 0; 575 576 double rotateInterval_ = 0.0; 577 Dimension dividerThickness_; 578 Dimension dividerSpacing_; 579 Color dividerColor_; 580 Dimension gradientHeight_; 581 Dimension columnFixedWidth_; 582 583 Dimension paddingHorizontal_; 584 Dimension contentMarginVertical_; 585 Dimension lunarswitchTextSize_; 586 587 PickerDate defaultStartDate_ = PickerDate(1970, 1, 1); 588 PickerDate defaultEndDate_ = PickerDate(2100, 12, 31); 589 }; 590 591 } // namespace OHOS::Ace 592 593 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_THEME_H 594