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 #ifdef SUPPORT_DIGITAL_CROWN 32 #include "core/event/crown_event.h" 33 #endif 34 #include "core/components_ng/pattern/picker/picker_type_define.h" 35 36 namespace OHOS::Ace { 37 namespace { 38 constexpr Dimension DIVIDER_THICKNESS = 1.0_px; 39 constexpr Dimension PICKER_FOCUS_PADDING = 2.0_vp; 40 constexpr uint32_t FOCUS_AREA_TYPE_IMPL = 1; 41 } // namespace 42 43 class PickerTheme : public virtual Theme { 44 DECLARE_ACE_TYPE(PickerTheme, Theme); 45 46 public: 47 class Builder { 48 public: 49 Builder() = default; 50 ~Builder() = default; 51 SetDigitalCrownSensitivity(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)52 void SetDigitalCrownSensitivity(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 53 { 54 #ifdef SUPPORT_DIGITAL_CROWN 55 CHECK_NULL_VOID(themeStyle); 56 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 57 if (pattern) { 58 auto sensitivity = pattern->GetAttr<int>("picker_crown_sensitivity", 59 OHOS::Ace::NG::DEFAULT_CROWNSENSITIVITY); 60 if (sensitivity >= static_cast<int32_t>(OHOS::Ace::CrownSensitivity::LOW) 61 && sensitivity <= static_cast<int32_t>(OHOS::Ace::CrownSensitivity::HIGH)) { 62 theme->crownSensitivity_ = sensitivity; 63 } 64 } 65 #endif 66 } 67 Build(const RefPtr<ThemeConstants> & themeConstants)68 RefPtr<PickerTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 69 { 70 RefPtr<PickerTheme> theme = AceType::MakeRefPtr<PickerTheme>(); 71 InitTheme(theme, themeConstants); 72 return theme; 73 } 74 75 protected: InitTheme(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeConstants> & themeConstants)76 void InitTheme(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeConstants>& themeConstants) const 77 { 78 CHECK_NULL_VOID(themeConstants); 79 auto themeStyle = themeConstants->GetThemeStyle(); 80 CHECK_NULL_VOID(themeStyle); 81 InitializeTextStyles(theme, themeStyle); 82 theme->optionSizeUnit_ = DimensionUnit::VP; 83 theme->lunarWidth_ = 84 Dimension(36.0, DimensionUnit::VP); // 36.0: lunarWidth, this width do not need setting by outer. 85 theme->lunarHeight_ = 86 Dimension(18.0, DimensionUnit::VP); // 18.0: lunarHeight, this height do not need setting by outer. 87 theme->rotateInterval_ = 15.0; // when rotate 15.0 angle handle scroll of picker column. 88 theme->dividerThickness_ = DIVIDER_THICKNESS; 89 Parse(themeStyle, theme); 90 InitializeSelectorItemStyles(theme, themeStyle); 91 InitializeSelectedBackgroundStyle(theme, themeStyle); 92 } 93 94 private: 95 void Parse(const RefPtr<ThemeStyle>& style, const RefPtr<PickerTheme>& theme) const; 96 InitializeButtonTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)97 void InitializeButtonTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 98 { 99 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 100 if (pattern) { 101 theme->buttonStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_button_font_size", 0.0_fp)); 102 theme->buttonStyle_.SetTextColor(pattern->GetAttr<Color>("picker_button_text_color", Color())); 103 } 104 } 105 InitializeTitleTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)106 void InitializeTitleTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 107 { 108 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 109 if (pattern) { 110 theme->titleStyle_.SetFontSize(pattern->GetAttr<Dimension>("picker_title_font_size", 0.0_fp)); 111 theme->titleStyle_.SetTextColor(pattern->GetAttr<Color>("picker_title_text_color", Color())); 112 } 113 theme->titleStyle_.SetFontWeight(FontWeight::W500); 114 theme->titleStyle_.SetMaxLines(1); 115 theme->titleStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 116 } 117 InitializeItemTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)118 void InitializeItemTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 119 { 120 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 121 if (pattern) { 122 theme->selectedOptionStyle_.SetTextColor( 123 pattern->GetAttr<Color>("selected_text_color", Color(0x007DFF))); 124 theme->selectedOptionStyle_.SetFontSize( 125 pattern->GetAttr<Dimension>("selected_text_size", 20.0_fp)); 126 theme->selectedOptionStyle_.SetFontWeight(FontWeight::MEDIUM); 127 theme->selectedOptionStyle_.SetAdaptTextSize(theme->selectedOptionStyle_.GetFontSize(), 128 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 129 theme->selectedOptionStyle_.SetMaxLines(1); 130 theme->selectedOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 131 132 theme->normalOptionStyle_.SetTextColor( 133 pattern->GetAttr<Color>("text_color", Color(0xff182431))); 134 theme->normalOptionStyle_.SetFontSize( 135 pattern->GetAttr<Dimension>("text_size", 16.0_fp)); 136 theme->normalOptionStyle_.SetFontWeight(FontWeight::REGULAR); 137 theme->normalOptionStyle_.SetAdaptTextSize(theme->normalOptionStyle_.GetFontSize(), 138 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 139 theme->normalOptionStyle_.SetMaxLines(1); 140 theme->normalOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 141 142 theme->disappearOptionStyle_.SetTextColor( 143 pattern->GetAttr<Color>("disappear_text_color", Color(0xff182431))); 144 theme->disappearOptionStyle_.SetFontSize( 145 pattern->GetAttr<Dimension>("disappear_text_size", 14.0_fp)); 146 theme->disappearOptionStyle_.SetFontWeight(FontWeight::REGULAR); 147 theme->disappearOptionStyle_.SetAdaptTextSize(theme->disappearOptionStyle_.GetFontSize(), 148 pattern->GetAttr<Dimension>("picker_normal_option_min_font_size", 0.0_fp)); 149 theme->disappearOptionStyle_.SetMaxLines(1); 150 theme->disappearOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 151 theme->focusOptionStyle_.SetFontSize( 152 pattern->GetAttr<Dimension>("picker_focus_option_font_size", 0.0_fp)); 153 theme->focusOptionStyle_.SetTextColor( 154 pattern->GetAttr<Color>("picker_focus_option_text_color", Color())); 155 theme->focusOptionStyle_.SetFontWeight( 156 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("picker_focus_option_weight", 0.0)))); 157 theme->focusOptionStyle_.SetAdaptTextSize(theme->focusOptionStyle_.GetFontSize(), 158 pattern->GetAttr<Dimension>("picker_select_option_min_font_size", 0.0_fp)); 159 theme->backgroundColor_ = pattern->GetAttr<Color>("picker_background_color", Color(0xffffffff)); 160 theme->showCircleDial_= static_cast<bool>(pattern->GetAttr<int>("picker_digital_circle", 0)); 161 SetDigitalCrownSensitivity(theme, themeStyle); 162 } 163 theme->focusOptionStyle_.SetMaxLines(1); 164 theme->focusOptionStyle_.SetTextOverflow(TextOverflow::ELLIPSIS); 165 166 if (SystemProperties::GetDeviceType() == DeviceType::PHONE) { 167 theme->focusOptionStyle_ = theme->selectedOptionStyle_; // focus style the same with selected on phone 168 } 169 } 170 InitializeSelectorItemStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)171 void InitializeSelectorItemStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 172 { 173 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 174 if (!pattern) { 175 return; 176 } 177 theme->focusImplType_ = static_cast<uint32_t>(pattern->GetAttr<int>("picker_focus_area_type", 0)); 178 theme->selectorItemRadius_ = pattern->GetAttr<Dimension>("picker_selector_item_radius", 8.0_vp); 179 theme->selectorItemSpace_ = pattern->GetAttr<Dimension>("picker_selector_item_space", 4.0_vp); 180 theme->selectorItemBorderWidth_ = pattern->GetAttr<Dimension>("picker_selector_item_border_width", 0.0_vp); 181 theme->selectorItemFocusBorderWidth_ = 182 pattern->GetAttr<Dimension>("picker_selector_item_focus_border_width", 0.0_vp); 183 theme->selectorItemBorderColor_ = 184 pattern->GetAttr<Color>("picker_selector_item_border_color", Color::TRANSPARENT); 185 theme->selectorItemFocusBorderColor_ = 186 pattern->GetAttr<Color>("picker_selector_item_focus_border_color", Color::TRANSPARENT); 187 theme->selectorItemFocusBgColor_ = 188 pattern->GetAttr<Color>("picker_selector_item_focus_bg_color", Color::TRANSPARENT); 189 theme->selectorItemNormalBgColor_ = 190 pattern->GetAttr<Color>("picker_selector_item_normal_bg_color", Color::TRANSPARENT); 191 192 if (FOCUS_AREA_TYPE_IMPL == theme->focusImplType_) { 193 theme->focusOptionStyle_.SetFontSize(pattern->GetAttr<Dimension>( 194 "picker_focus_option_font_size", theme->selectedOptionStyle_.GetFontSize())); 195 theme->focusOptionStyle_.SetTextColor(pattern->GetAttr<Color>( 196 "picker_focus_option_text_color", theme->selectedOptionStyle_.GetTextColor())); 197 theme->dividerColor_ = pattern->GetAttr<Color>("picker_select_divider_color", Color::TRANSPARENT); 198 theme->focusColor_ = pattern->GetAttr<Color>("picker_focus_color", Color(0xff0a59f7)); 199 theme->focusPadding_ = pattern->GetAttr<Dimension>("picker_focus_padding", PICKER_FOCUS_PADDING); 200 } 201 } 202 InitializeSelectedBackgroundStyle(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)203 void InitializeSelectedBackgroundStyle( 204 const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 205 { 206 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("picker_pattern", nullptr); 207 if (!pattern) { 208 return; 209 } 210 theme->selectedBackgroundColor_ = pattern->GetAttr<Color>( 211 "picker_selected_background_color", Color(0x0c182431)); 212 theme->selectedBorderRadius_ = NG::BorderRadiusProperty( 213 pattern->GetAttr<Dimension>("picker_selected_border_radius", 24.0_vp)); 214 } 215 InitializeTextStyles(const RefPtr<PickerTheme> & theme,const RefPtr<ThemeStyle> & themeStyle)216 void InitializeTextStyles(const RefPtr<PickerTheme>& theme, const RefPtr<ThemeStyle>& themeStyle) const 217 { 218 InitializeItemTextStyles(theme, themeStyle); 219 InitializeTitleTextStyles(theme, themeStyle); 220 InitializeButtonTextStyles(theme, themeStyle); 221 } 222 }; 223 224 ~PickerTheme() override = default; 225 PickerTheme() = default; clone()226 RefPtr<PickerTheme> clone() const 227 { 228 auto theme = AceType::MakeRefPtr<PickerTheme>(); 229 theme->selectedOptionSize_ = selectedOptionSize_; 230 theme->selectedOptionStyle_ = selectedOptionStyle_; 231 theme->normalOptionSize_ = normalOptionSize_; 232 theme->normalOptionStyle_ = normalOptionStyle_; 233 theme->disappearOptionStyle_ = disappearOptionStyle_; 234 theme->showOptionCount_ = showOptionCount_; 235 theme->optionSizeUnit_ = optionSizeUnit_; 236 theme->popupDecoration_ = popupDecoration_; 237 theme->focusColor_ = focusColor_; 238 theme->popupEdge_ = popupEdge_; 239 theme->focusOptionStyle_ = focusOptionStyle_; 240 theme->focusOptionDecoration_ = focusOptionDecoration_; 241 theme->selectedOptionDecoration_ = selectedOptionDecoration_; 242 theme->buttonStyle_ = buttonStyle_; 243 theme->showButtons_ = showButtons_; 244 theme->buttonWidth_ = buttonWidth_; 245 theme->buttonHeight_ = buttonHeight_; 246 theme->buttonTopPadding_ = buttonTopPadding_; 247 theme->jumpInterval_ = jumpInterval_; 248 theme->columnIntervalMargin_ = columnIntervalMargin_; 249 theme->focusRadius_ = focusRadius_; 250 theme->optionPadding_ = optionPadding_; 251 theme->titleStyle_ = titleStyle_; 252 theme->titleBottomPadding_ = titleBottomPadding_; 253 theme->popupOutDecoration_ = popupOutDecoration_; 254 theme->lunarWidth_ = lunarWidth_; 255 theme->lunarHeight_ = lunarHeight_; 256 theme->timeSplitter_ = timeSplitter_; 257 theme->rotateInterval_ = rotateInterval_; 258 theme->deviceHeightLimit_ = deviceHeightLimit_; 259 theme->dividerThickness_ = dividerThickness_; 260 theme->dividerSpacing_ = dividerSpacing_; 261 theme->dividerColor_ = dividerColor_; 262 theme->gradientHeight_ = gradientHeight_; 263 theme->columnFixedWidth_ = columnFixedWidth_; 264 theme->disappearOptionStyle_ = disappearOptionStyle_; 265 theme->pressColor_ = pressColor_; 266 theme->hoverColor_ = hoverColor_; 267 theme->lunarswitchTextColor_ = lunarswitchTextColor_; 268 theme->lunarswitchTextSize_ = lunarswitchTextSize_; 269 theme->defaultStartDate_ = defaultStartDate_; 270 theme->defaultEndDate_ = defaultEndDate_; 271 cloneSelectorProps(theme); 272 cloneSelectedBackgroundStyle(theme); 273 return theme; 274 } 275 cloneSelectorProps(RefPtr<PickerTheme> theme)276 void cloneSelectorProps(RefPtr<PickerTheme> theme) const 277 { 278 theme->focusImplType_ = focusImplType_; 279 theme->selectorItemRadius_ = selectorItemRadius_; 280 theme->selectorItemSpace_ = selectorItemSpace_; 281 theme->selectorItemBorderWidth_ = selectorItemBorderWidth_; 282 theme->selectorItemFocusBorderWidth_ = selectorItemFocusBorderWidth_; 283 theme->selectorItemBorderColor_ = selectorItemBorderColor_; 284 theme->selectorItemFocusBorderColor_ = selectorItemFocusBorderColor_; 285 theme->selectorItemFocusBgColor_ = selectorItemFocusBgColor_; 286 theme->selectorItemNormalBgColor_ = selectorItemNormalBgColor_; 287 theme->focusPadding_ = focusPadding_; 288 } 289 cloneSelectedBackgroundStyle(RefPtr<PickerTheme> theme)290 void cloneSelectedBackgroundStyle(RefPtr<PickerTheme> theme) const 291 { 292 theme->selectedBackgroundColor_ = selectedBackgroundColor_; 293 theme->selectedBorderRadius_ = selectedBorderRadius_; 294 } 295 GetOptionStyle(bool selected,bool focus)296 const TextStyle& GetOptionStyle(bool selected, bool focus) const 297 { 298 if (!selected) { 299 return normalOptionStyle_; 300 } 301 302 if (focus) { 303 return focusOptionStyle_; 304 } 305 306 return selectedOptionStyle_; 307 } SetOptionStyle(bool selected,bool focus,const TextStyle & value)308 void SetOptionStyle(bool selected, bool focus, const TextStyle& value) 309 { 310 if (!selected) { 311 normalOptionStyle_ = value; 312 } else if (focus) { 313 focusOptionStyle_ = value; 314 } else { 315 selectedOptionStyle_ = value; 316 } 317 } 318 GetDisappearOptionStyle()319 const TextStyle& GetDisappearOptionStyle() const 320 { 321 return disappearOptionStyle_; 322 } SetDisappearOptionStyle(const TextStyle & value)323 void SetDisappearOptionStyle(const TextStyle& value) 324 { 325 disappearOptionStyle_ = value; 326 } 327 GetButtonStyle()328 const TextStyle& GetButtonStyle() const 329 { 330 return buttonStyle_; 331 } 332 GetOptionDecoration(bool focus)333 const RefPtr<Decoration>& GetOptionDecoration(bool focus) 334 { 335 if (focus) { 336 return focusOptionDecoration_; 337 } 338 339 return selectedOptionDecoration_; 340 } SetOptionDecoration(bool focus,const RefPtr<Decoration> & value)341 void SetOptionDecoration(bool focus, const RefPtr<Decoration>& value) 342 { 343 if (focus) { 344 focusOptionDecoration_ = value; 345 } else { 346 selectedOptionDecoration_ = value; 347 } 348 } 349 GetOptionSize(bool selected)350 const Size& GetOptionSize(bool selected) const 351 { 352 if (selected) { 353 return selectedOptionSize_; 354 } 355 356 return normalOptionSize_; 357 } 358 GetShowOptionCount()359 uint32_t GetShowOptionCount() const 360 { 361 return showOptionCount_; 362 } 363 GetOptionSizeUnit()364 DimensionUnit GetOptionSizeUnit() const 365 { 366 return optionSizeUnit_; 367 } 368 GetPopupDecoration(bool isOutBox)369 const RefPtr<Decoration>& GetPopupDecoration(bool isOutBox) const 370 { 371 if (!isOutBox) { 372 return popupDecoration_; 373 } 374 return popupOutDecoration_; 375 } 376 GetFocusColor()377 const Color& GetFocusColor() const 378 { 379 return focusColor_; 380 } 381 GetPopupEdge()382 const Edge& GetPopupEdge() const 383 { 384 return popupEdge_; 385 } 386 GetShowButtons()387 bool GetShowButtons() const 388 { 389 return showButtons_; 390 } 391 GetButtonWidth()392 const Dimension& GetButtonWidth() const 393 { 394 return buttonWidth_; 395 } 396 GetButtonHeight()397 const Dimension& GetButtonHeight() const 398 { 399 return buttonHeight_; 400 } 401 GetButtonTopPadding()402 const Dimension& GetButtonTopPadding() const 403 { 404 return buttonTopPadding_; 405 } 406 GetJumpInterval()407 const Dimension& GetJumpInterval() const 408 { 409 return jumpInterval_; 410 } 411 GetColumnIntervalMargin()412 const Dimension& GetColumnIntervalMargin() const 413 { 414 return columnIntervalMargin_; 415 } 416 GetFocusRadius()417 const Radius& GetFocusRadius() const 418 { 419 return focusRadius_; 420 } 421 GetOptionPadding()422 double GetOptionPadding() const 423 { 424 return optionPadding_; 425 } SetOptionPadding(double value)426 void SetOptionPadding(double value) 427 { 428 optionPadding_ = value; 429 } 430 GetTitleStyle()431 const TextStyle& GetTitleStyle() const 432 { 433 return titleStyle_; 434 } 435 GetTitleBottomPadding()436 const Dimension& GetTitleBottomPadding() const 437 { 438 return titleBottomPadding_; 439 } 440 GetLunarWidth()441 const Dimension& GetLunarWidth() const 442 { 443 return lunarWidth_; 444 } 445 GetLunarHeight()446 const Dimension& GetLunarHeight() const 447 { 448 return lunarHeight_; 449 } 450 HasTimeSplitter()451 bool HasTimeSplitter() const 452 { 453 return (timeSplitter_ > 0); 454 } 455 GetRotateInterval()456 double GetRotateInterval() const 457 { 458 return rotateInterval_; 459 } 460 GetDeviceHeightLimit()461 double GetDeviceHeightLimit() const 462 { 463 return deviceHeightLimit_; 464 } 465 GetDividerThickness()466 const Dimension& GetDividerThickness() const 467 { 468 return dividerThickness_; 469 } 470 GetDividerSpacing()471 const Dimension& GetDividerSpacing() const 472 { 473 return dividerSpacing_; 474 } 475 GetDividerColor()476 const Color& GetDividerColor() const 477 { 478 return dividerColor_; 479 } 480 GetGradientHeight()481 const Dimension& GetGradientHeight() const 482 { 483 return gradientHeight_; 484 } 485 GetColumnFixedWidth()486 const Dimension& GetColumnFixedWidth() const 487 { 488 return columnFixedWidth_; 489 } 490 GetColumnBottomTotalHeight(bool hasLunar)491 Dimension GetColumnBottomTotalHeight(bool hasLunar) const 492 { 493 if (hasLunar) { 494 return buttonHeight_ + lunarHeight_ + buttonTopPadding_ * 2 + popupEdge_.Bottom(); //2: double padding 495 } else { 496 return buttonHeight_ + buttonTopPadding_ + popupEdge_.Bottom(); 497 } 498 } 499 GetPressColor()500 const Color& GetPressColor() const 501 { 502 return pressColor_; 503 } 504 GetHoverColor()505 const Color& GetHoverColor() const 506 { 507 return hoverColor_; 508 } 509 GetPaddingHorizontal()510 const Dimension& GetPaddingHorizontal() const 511 { 512 return paddingHorizontal_; 513 } 514 GetContentMarginVertical()515 const Dimension& GetContentMarginVertical() const 516 { 517 return contentMarginVertical_; 518 } 519 GetLunarSwitchTextSize()520 const Dimension& GetLunarSwitchTextSize() const 521 { 522 return lunarswitchTextSize_; 523 } 524 GetLunarSwitchTextColor()525 const Color& GetLunarSwitchTextColor() const 526 { 527 return lunarswitchTextColor_; 528 } 529 GetDefaultStartDate()530 const PickerDate& GetDefaultStartDate() const 531 { 532 return defaultStartDate_; 533 } 534 GetDefaultEndDate()535 const PickerDate& GetDefaultEndDate() const 536 { 537 return defaultEndDate_; 538 } 539 GetDefaultStartTime()540 const PickerTime& GetDefaultStartTime() const 541 { 542 return defaultStartTime_; 543 } 544 GetDefaultEndTime()545 const PickerTime& GetDefaultEndTime() const 546 { 547 return defaultEndTime_; 548 } 549 GetShowCountLandscape()550 uint32_t GetShowCountLandscape() const 551 { 552 return showCountLandscape_; 553 } 554 GetShowCountPortrait()555 uint32_t GetShowCountPortrait() const 556 { 557 return showCountPortrait_; 558 } 559 GetTitleFontScaleLimit()560 double GetTitleFontScaleLimit() 561 { 562 return titleFontScaleLimit_; 563 } 564 GetGradientHeightLimit()565 const Dimension& GetGradientHeightLimit() const 566 { 567 return gradientHeightLimit_; 568 } 569 GetDividerSpacingLimit()570 const Dimension& GetDividerSpacingLimit() const 571 { 572 return dividerSpacingHeightLimit_; 573 } 574 GetPickerDialogFontPadding()575 const Dimension& GetPickerDialogFontPadding() const 576 { 577 return pickerDialogFontPadding_; 578 } 579 GetUseSetSelectedTextStyle()580 const Dimension& GetUseSetSelectedTextStyle() const 581 { 582 return selectedTextStyle_; 583 } 584 GetUserSetNormalTextStyle()585 const Dimension& GetUserSetNormalTextStyle() const 586 { 587 return normalTextStyle_; 588 } 589 GetUserSetDisappearTextStyle()590 const Dimension& GetUserSetDisappearTextStyle() const 591 { 592 return disappearTextStyle_; 593 } 594 GetNormalFontScale()595 double GetNormalFontScale() const 596 { 597 return pickerDialogNormalFontScale_; 598 } 599 GetMaxOneFontScale()600 double GetMaxOneFontScale() const 601 { 602 return pickerDialogMaxOneFontScale_; 603 } 604 GetMaxTwoFontScale()605 double GetMaxTwoFontScale() const 606 { 607 return pickerDialogMaxTwoFontScale_; 608 } 609 GetMaxThirdFontScale()610 double GetMaxThirdFontScale() const 611 { 612 return pickerDialogMaxThirdFontScale_; 613 } 614 NeedButtonFocusAreaType()615 bool NeedButtonFocusAreaType() const 616 { 617 return focusImplType_ == FOCUS_AREA_TYPE_IMPL; 618 } 619 GetSelectorItemRadius()620 const Dimension& GetSelectorItemRadius() const 621 { 622 return selectorItemRadius_; 623 } 624 GetSelectorItemSpace()625 const Dimension& GetSelectorItemSpace() const 626 { 627 return selectorItemSpace_; 628 } 629 GetSelectorItemBorderWidth()630 const Dimension& GetSelectorItemBorderWidth() const 631 { 632 return selectorItemBorderWidth_; 633 } 634 GetSelectorItemFocusBorderWidth()635 const Dimension& GetSelectorItemFocusBorderWidth() const 636 { 637 return selectorItemFocusBorderWidth_; 638 } 639 GetFocusPadding()640 const Dimension& GetFocusPadding() const 641 { 642 return focusPadding_; 643 } 644 GetSelectorItemBorderColor()645 const Color& GetSelectorItemBorderColor() const 646 { 647 return selectorItemBorderColor_; 648 } 649 GetSelectorItemFocusBorderColor()650 const Color& GetSelectorItemFocusBorderColor() const 651 { 652 return selectorItemFocusBorderColor_; 653 } 654 GetSelectorItemFocusBgColor()655 const Color& GetSelectorItemFocusBgColor() const 656 { 657 return selectorItemFocusBgColor_; 658 } 659 GetSelectorItemNormalBgColor()660 const Color& GetSelectorItemNormalBgColor() const 661 { 662 return selectorItemNormalBgColor_; 663 } 664 GetBackgroundColor()665 const Color& GetBackgroundColor() const 666 { 667 return backgroundColor_; 668 } 669 GetDigitalCrownSensitivity()670 int32_t GetDigitalCrownSensitivity() const 671 { 672 return crownSensitivity_; 673 } 674 GetSelectedBackgroundColor()675 const Color& GetSelectedBackgroundColor() const 676 { 677 return selectedBackgroundColor_; 678 } 679 GetSelectedBorderRadius()680 const NG::BorderRadiusProperty& GetSelectedBorderRadius() const 681 { 682 return selectedBorderRadius_; 683 } 684 IsCircleDial()685 bool IsCircleDial() const 686 { 687 return showCircleDial_; 688 } 689 GetLunarSwitchText()690 const std::string& GetLunarSwitchText() const 691 { 692 return lunarSwitch_; 693 } 694 GetPrevText()695 const std::string& GetPrevText() const 696 { 697 return prevText_; 698 } 699 GetNextText()700 const std::string& GetNextText() const 701 { 702 return nextText_; 703 } 704 705 private: 706 707 Color focusColor_; 708 Color hoverColor_; 709 Color pressColor_; 710 Color lunarswitchTextColor_; 711 Color backgroundColor_; 712 int32_t crownSensitivity_ = OHOS::Ace::NG::DEFAULT_CROWNSENSITIVITY; 713 bool showCircleDial_ = false; 714 715 Radius focusRadius_; 716 uint32_t showOptionCount_ = 0; 717 bool showButtons_ = false; 718 Dimension jumpInterval_; 719 720 // popup style 721 RefPtr<Decoration> popupDecoration_; 722 RefPtr<Decoration> popupOutDecoration_; 723 Edge popupEdge_; 724 725 // column 726 Dimension columnIntervalMargin_; 727 728 // text style 729 TextStyle focusOptionStyle_; 730 TextStyle selectedOptionStyle_; 731 TextStyle normalOptionStyle_; 732 TextStyle disappearOptionStyle_; 733 TextStyle buttonStyle_; 734 TextStyle titleStyle_; 735 736 // text around decoration 737 RefPtr<Decoration> selectedOptionDecoration_; 738 RefPtr<Decoration> focusOptionDecoration_; 739 740 // option size 741 Size selectedOptionSize_; 742 Size normalOptionSize_; 743 double optionPadding_ = 0.0; 744 DimensionUnit optionSizeUnit_ = DimensionUnit::PX; 745 746 // buttons size 747 Dimension buttonWidth_; 748 Dimension buttonHeight_; 749 Dimension buttonTopPadding_; 750 Dimension titleBottomPadding_; 751 752 // lunar size 753 Dimension lunarWidth_; 754 Dimension lunarHeight_; 755 756 uint32_t timeSplitter_ = 0; 757 758 double rotateInterval_ = 0.0; 759 Dimension dividerThickness_; 760 Dimension dividerSpacing_; 761 Color dividerColor_; 762 Dimension gradientHeight_; 763 Dimension columnFixedWidth_; 764 765 Dimension paddingHorizontal_; 766 Dimension contentMarginVertical_; 767 Dimension lunarswitchTextSize_; 768 769 PickerDate defaultStartDate_ = PickerDate(1970, 1, 1); 770 PickerDate defaultEndDate_ = PickerDate(2100, 12, 31); 771 PickerTime defaultStartTime_ = PickerTime(0, 0, 0); 772 PickerTime defaultEndTime_ = PickerTime(23, 59, 59); 773 774 uint32_t showCountLandscape_ = 3; 775 uint32_t showCountPortrait_ = 5; 776 double deviceHeightLimit_ = 640.0; 777 Dimension gradientHeightLimit_ = 54.0_vp; 778 Dimension dividerSpacingHeightLimit_ = 64.0_vp; 779 Dimension pickerDialogFontPadding_ = 8.0_vp; 780 Dimension selectedTextStyle_ = 40.0_vp; 781 Dimension normalTextStyle_ = 32.0_vp; 782 Dimension disappearTextStyle_ = 28.0_vp; 783 double pickerDialogNormalFontScale_ = 1.0f; 784 double pickerDialogMaxOneFontScale_ = 1.75f; 785 double pickerDialogMaxTwoFontScale_ = 2.0f; 786 double pickerDialogMaxThirdFontScale_ = 3.2f; 787 double titleFontScaleLimit_ = 1.45f; 788 789 uint32_t focusImplType_ = 0; 790 Dimension selectorItemRadius_; 791 Dimension selectorItemSpace_; 792 Dimension selectorItemBorderWidth_; 793 Dimension selectorItemFocusBorderWidth_; 794 Dimension focusPadding_; 795 Color selectorItemBorderColor_; 796 Color selectorItemFocusBorderColor_; 797 Color selectorItemFocusBgColor_; 798 Color selectorItemNormalBgColor_; 799 800 std::string lunarSwitch_; 801 std::string prevText_; 802 std::string nextText_; 803 804 Color selectedBackgroundColor_; 805 NG::BorderRadiusProperty selectedBorderRadius_; 806 }; 807 808 } // namespace OHOS::Ace 809 810 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_PICKER_PICKER_THEME_H 811