1 /* 2 * Copyright (c) 2021 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_TEXT_FIELD_TEXTFIELD_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXTFIELD_THEME_H 18 19 #include "base/geometry/dimension.h" 20 #include "core/components/common/properties/border.h" 21 #include "core/components/common/properties/color.h" 22 #include "core/components/common/properties/edge.h" 23 #include "core/components/common/properties/radius.h" 24 #include "core/components/swiper/render_swiper.h" 25 #include "core/components/theme/theme.h" 26 #include "core/components/theme/theme_constants.h" 27 #include "core/components/theme/theme_constants_defines.h" 28 #include "core/components_ng/pattern/text_field/text_field_model.h" 29 30 namespace OHOS::Ace { 31 32 /** 33 * TextFieldTheme defines color and styles of SliderComponent. TextFieldTheme should be built 34 * using TextFieldTheme::Builder. 35 */ 36 class TextFieldTheme : public virtual Theme { 37 DECLARE_ACE_TYPE(TextFieldTheme, Theme); 38 39 public: 40 class Builder { 41 public: 42 Builder() = default; 43 ~Builder() = default; 44 Build(const RefPtr<ThemeConstants> & themeConstants)45 RefPtr<TextFieldTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 46 { 47 RefPtr<TextFieldTheme> theme = AceType::Claim(new TextFieldTheme()); 48 if (!themeConstants) { 49 return theme; 50 } 51 theme->height_ = themeConstants->GetDimension(THEME_TEXTFIELD_HEIGHT); 52 ParsePattern(themeConstants->GetThemeStyle(), theme); 53 return theme; 54 } 55 56 private: ParsePattern(const RefPtr<ThemeStyle> & themeStyle,const RefPtr<TextFieldTheme> & theme)57 void ParsePattern(const RefPtr<ThemeStyle>& themeStyle, const RefPtr<TextFieldTheme>& theme) const 58 { 59 if (!themeStyle || !theme) { 60 return; 61 } 62 auto pattern = themeStyle->GetAttr<RefPtr<ThemeStyle>>("textfield_pattern", nullptr); 63 if (!pattern) { 64 LOGW("find pattern of textfield fail"); 65 return; 66 } 67 ParsePatternSubFirstPart(pattern, theme); 68 ParsePatternSubSecondPart(pattern, theme); 69 ParsePatternSubThirdPart(pattern, theme); 70 } 71 ParsePatternSubFirstPart(const RefPtr<ThemeStyle> & pattern,const RefPtr<TextFieldTheme> & theme)72 void ParsePatternSubFirstPart(const RefPtr<ThemeStyle>& pattern, const RefPtr<TextFieldTheme>& theme) const 73 { 74 theme->padding_ = Edge(pattern->GetAttr<Dimension>("textfield_padding_horizontal", 0.0_vp), 75 pattern->GetAttr<Dimension>("textfield_padding_vertical", 0.0_vp), 76 pattern->GetAttr<Dimension>("textfield_padding_horizontal", 0.0_vp), 77 pattern->GetAttr<Dimension>("textfield_padding_vertical", 0.0_vp)); 78 theme->underlinePadding_ = 79 Edge(pattern->GetAttr<Dimension>("textfield_underline_padding_horizontal", 0.0_vp), 80 pattern->GetAttr<Dimension>("textfield_underline_padding_vertical", 12.0_vp), 81 pattern->GetAttr<Dimension>("textfield_underline_padding_horizontal", 0.0_vp), 82 pattern->GetAttr<Dimension>("textfield_underline_padding_vertical", 12.0_vp)); 83 theme->fontWeight_ = 84 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_font_weight", 0.0))); 85 theme->borderRadius_ = Radius(pattern->GetAttr<Dimension>("textfield_border_radius", 0.0_vp)); 86 theme->disableOpacityRatio_ = pattern->GetAttr<double>("textfield_disable_opacity_ratio", 0.0); 87 theme->overHideLength_ = pattern->GetAttr<Dimension>("textfield_over_hide_length", 0.0_vp); 88 theme->cursorRadius_ = pattern->GetAttr<Dimension>("textfield_cursor_radius", 0.0_vp); 89 theme->needFade_ = static_cast<bool>(pattern->GetAttr<double>("textfield_need_fade", 0.0)); 90 theme->iconSize_ = pattern->GetAttr<Dimension>("textfield_icon_size", 0.0_vp); 91 theme->iconHotZoneSize_ = pattern->GetAttr<Dimension>("textfield_icon_hot_zone_size", 0.0_vp); 92 theme->showEllipsis_ = static_cast<bool>(pattern->GetAttr<double>("textfield_show_ellipsis", 0.0)); 93 theme->errorSpacing_ = pattern->GetAttr<Dimension>("textfield_error_spacing", 0.0_vp); 94 theme->errorIsInner_ = static_cast<bool>(pattern->GetAttr<double>("textfield_error_is_inner", 0.0)); 95 theme->errorBorderWidth_ = pattern->GetAttr<Dimension>("textfield_error_border_width", 0.0_vp); 96 theme->errorTextStyle_.SetFontWeight( 97 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_error_font_weight", 0.0)))); 98 theme->countTextStyle_.SetFontWeight( 99 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_count_font_weight", 0.0)))); 100 theme->overCountStyle_.SetFontWeight( 101 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_over_count_font_weight", 0.0)))); 102 theme->countTextStyleOuter_.SetFontWeight( 103 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_count_font_weight", 0.0)))); 104 theme->overCountStyleOuter_.SetFontWeight( 105 FontWeight(static_cast<int32_t>(pattern->GetAttr<double>("textfield_over_count_font_weight", 0.0)))); 106 theme->fontSize_ = pattern->GetAttr<Dimension>(PATTERN_TEXT_SIZE, 0.0_fp); 107 theme->textColor_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, Color()); 108 theme->focusTextColor_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR_FOCUSED, Color()); 109 theme->placeholderColor_ = pattern->GetAttr<Color>("tips_text_color", Color()); 110 theme->focusPlaceholderColor_ = pattern->GetAttr<Color>("tips_text_color_focused", Color()); 111 theme->bgColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR, Color()); 112 theme->focusBgColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_FOCUSED, Color()); 113 theme->glassOutlinePrimaryColor_ = 114 pattern->GetAttr<Color>("glass_material_outline_primary", Color(0xffffff)); 115 theme->glassOutlineSecondaryColor_ = 116 pattern->GetAttr<Color>("glass_material_outline_secondary", Color(0xf0f0f0)); 117 theme->glassMaskPrimaryColor_ = pattern->GetAttr<Color>("glass_material_mask_primary", Color(0x00808080)); 118 theme->glassMaskSecondaryColor_ = 119 pattern->GetAttr<Color>("glass_material_mask_secondary", Color(0x26808080)); 120 } 121 ParsePatternSubSecondPart(const RefPtr<ThemeStyle> & pattern,const RefPtr<TextFieldTheme> & theme)122 void ParsePatternSubSecondPart(const RefPtr<ThemeStyle>& pattern, const RefPtr<TextFieldTheme>& theme) const 123 { 124 const double defaultErrorAlpha = 0.6; 125 const double defaultUnderlineAlpha = 0.6; 126 const double defaultDisableUnderlineAlpha = 0.4; 127 const Color defaultUnderlineColor = Color(0x33182431); 128 const Color defaultUnderlineTextColor = Color(0x99182431); 129 const Color defaultCounterColor = Color(0x66182431); 130 const Color overCounterColor = Color(0x99FA2A2D); 131 // color of error border blend 60% opacity 132 theme->errorBorderColor_ = 133 pattern->GetAttr<Color>("error_text_border_color", Color()) 134 .BlendOpacity(pattern->GetAttr<double>("error_text_border_color_alpha", defaultErrorAlpha)); 135 theme->errorUnderlineColor_ = pattern->GetAttr<Color>(ERROR_UNDERLINE_COLOR, Color()); 136 theme->underlineColor_ = pattern->GetAttr<Color>(UNDERLINE_COLOR, defaultUnderlineColor); 137 theme->disableUnderlineColor_ = 138 pattern->GetAttr<Color>(UNDERLINE_COLOR, defaultUnderlineColor) 139 .BlendOpacity(pattern->GetAttr<double>(DISABLE_UNDERLINE_ALPHA, defaultDisableUnderlineAlpha)); 140 theme->underlineTextColor_ = pattern->GetAttr<Color>(UNDERLINE_TEXT_COLOR, defaultUnderlineTextColor); 141 theme->defaultCounterColor_ = pattern->GetAttr<Color>(DEFAULT_COUNTER_COLOR, defaultCounterColor); 142 theme->overCounterColor_ = pattern->GetAttr<Color>(OVER_COUNTER_COLOR, overCounterColor); 143 theme->underlineFontSize_ = pattern->GetAttr<Dimension>(UNDERLINE_FONT_SIZE, 0.0_fp); 144 theme->errorTextStyle_.SetTextColor(pattern->GetAttr<Color>(ERROR_UNDERLINE_TEXT_COLOR, Color())); 145 theme->errorTextStyle_.SetFontSize(pattern->GetAttr<Dimension>(ERROR_UNDERLINE_TEXT_SIZE, 0.0_fp)); 146 147 theme->countTextStyle_.SetTextColor(pattern->GetAttr<Color>("count_text_color", Color())); 148 theme->countTextStyle_.SetFontSize(pattern->GetAttr<Dimension>("count_text_font_size", 0.0_fp)); 149 theme->overCountStyle_.SetTextColor(pattern->GetAttr<Color>("over_text_color", Color())); 150 theme->overCountStyle_.SetFontSize(pattern->GetAttr<Dimension>("over_text_font_size", 0.0_fp)); 151 152 theme->countTextStyleOuter_.SetTextColor(pattern->GetAttr<Color>("count_outer_text_color", Color())); 153 theme->countTextStyleOuter_.SetFontSize(pattern->GetAttr<Dimension>("count_outer_text_font_size", 0.0_fp)); 154 theme->overCountStyleOuter_.SetTextColor(pattern->GetAttr<Color>("over_outer_text_color", Color())); 155 theme->overCountStyleOuter_.SetFontSize(pattern->GetAttr<Dimension>("over_outer_text_font_size", 0.0_fp)); 156 theme->overCountTextStyle_.SetTextColor(pattern->GetAttr<Color>(OVER_COUNT_TEXT_COLOR, Color())); 157 theme->overCountTextStyle_.SetFontSize(pattern->GetAttr<Dimension>(OVER_COUNT_TEXT_FONT_SIZE, 0.0_fp)); 158 theme->selectedColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_SELECTED, Color()); 159 theme->disableTextColor_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR_DISABLED, Color()); 160 theme->underlineActivedColor_ = 161 pattern->GetAttr<Color>(PATTERN_UNDERLINE_ACTIVED_COLOR, Color()) 162 .BlendOpacity(pattern->GetAttr<double>(UNDERLINE_COLOR_ALPHA, defaultUnderlineAlpha)); 163 theme->underlineTypingColor_ = 164 pattern->GetAttr<Color>(PATTERN_UNDERLINE_TYPING_COLOR, Color()) 165 .BlendOpacity(pattern->GetAttr<double>(UNDERLINE_COLOR_ALPHA, defaultUnderlineAlpha)); 166 } 167 ParsePatternSubThirdPart(const RefPtr<ThemeStyle> & pattern,const RefPtr<TextFieldTheme> & theme)168 void ParsePatternSubThirdPart(const RefPtr<ThemeStyle>& pattern, const RefPtr<TextFieldTheme>& theme) const 169 { 170 const double defaultErrorAlpha = 0.6; 171 theme->textColorDisable_ = pattern->GetAttr<Color>(PATTERN_DISABLED_TEXT_COLOR, Color()); 172 theme->cursorColor_ = pattern->GetAttr<Color>("cursor_color", Color()); 173 theme->cursorWidth_ = pattern->GetAttr<Dimension>("cursor_width", 2.0_vp); 174 theme->hoverColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_HOVERED, Color()); 175 theme->pressColor_ = pattern->GetAttr<Color>(PATTERN_BG_COLOR_PRESSED, Color()); 176 theme->borderRadiusSize_ = Radius(pattern->GetAttr<Dimension>(BORDER_RADIUS_SIZE, 20.0_vp)); 177 theme->disabledIconFillColor_ = theme->bgColor_.BlendOpacity(theme->disableOpacityRatio_); 178 theme->passwordErrorTextColor_ = pattern->GetAttr<Color>(PATTERN_TEXT_COLOR, Color()); 179 theme->passwordErrorInputColor_ = pattern->GetAttr<Color>(ERROR_PASSWORD_INPUT_COLOR, Color()); 180 theme->passwordErrorBorderColor_ = 181 pattern->GetAttr<Color>(ERROR_PASSWORD_BORDER_COLOR, Color()) 182 .BlendOpacity(pattern->GetAttr<double>(ERROR_PASSWORD_BORDER_ALPHA, defaultErrorAlpha)); 183 theme->passwordErrorLableColor_ = pattern->GetAttr<Color>(ERROR_PASSWORD_TEXT_COLOR, Color()); 184 theme->overCountBorderColor_ = 185 pattern->GetAttr<Color>(OVER_COUNT_BORDER_COLOR, Color()) 186 .BlendOpacity(pattern->GetAttr<double>(OVER_COUNT_BORDER_COLOR_ALPHA, defaultErrorAlpha)); 187 theme->inlineTextColor_ = pattern->GetAttr<Color>(INLINE_TEXT_COLOR, Color()); 188 theme->inlineRadiusSize_ = Radius(pattern->GetAttr<Dimension>(INLINE_RADIUS_SIZE, 4.0_vp)); 189 theme->inlineBgColor_ = pattern->GetAttr<Color>(INLINE_BG_COLOR, Color()); 190 theme->inlineBorderColor_ = pattern->GetAttr<Color>(INLINE_BORDER_COLOR, Color()); 191 auto draggable = pattern->GetAttr<std::string>("draggable", "0"); 192 theme->draggable_ = StringUtils::StringToInt(draggable); 193 theme->height_ = pattern->GetAttr<Dimension>("textinput_default_height", 24.0_vp); 194 theme->contentHeight_ = pattern->GetAttr<Dimension>("textfield_content_height", 0.0_vp); 195 auto showPasswordDirectly = pattern->GetAttr<std::string>("show_password_directly", "0"); 196 theme->showPasswordDirectly_ = StringUtils::StringToInt(showPasswordDirectly); 197 auto textfieldShowHandle = pattern->GetAttr<std::string>("textfield_show_handle", "0"); 198 theme->textfieldShowHandle_ = StringUtils::StringToInt(textfieldShowHandle); 199 200 theme->cancelButtonIconColor_ = pattern->GetAttr<Color>("textfield_symbol_color", Color()); 201 theme->previewUnderlineColor_ = pattern->GetAttr<Color>(PREVIEW_UNDERLINE_COLOR, Color()); 202 theme->previewBoardColor_ = pattern->GetAttr<Color>(PREVIEW_BOARD_COLOR, Color()); 203 204 theme->placeholderLineSpacing_ = pattern->GetAttr<Dimension>("text_field_placeholder_linespacing", 0.0_vp); 205 206 theme->cancelButton_ = pattern->GetAttr<std::string>("textfield_accessibility_clear", ""); 207 theme->cancelImageText_ = pattern->GetAttr<std::string>("textfield_accessibility_property_clear", ""); 208 theme->showPassword_ = pattern->GetAttr<std::string>("textfield_show_password_button", ""); 209 theme->hidePassword_ = pattern->GetAttr<std::string>("textfield_hide_password_button", ""); 210 theme->aiWriteBundleName_ = pattern->GetAttr<std::string>("textfield_writting_bundle_name", ""); 211 theme->aiWriteAbilityName_ = pattern->GetAttr<std::string>("textfield_writting_ability_name", ""); 212 theme->aiWriteIsSupport_ = pattern->GetAttr<std::string>("textfield_writting_is_support", ""); 213 theme->hasShowedPassword_ = pattern->GetAttr<std::string>("textfield_has_showed_password", ""); 214 theme->hasHiddenPassword_ = pattern->GetAttr<std::string>("textfield_has_hidden_password", ""); 215 auto supportTranslate = pattern->GetAttr<std::string>("menu_translate_is_support", "0"); 216 theme->translateIsSupport_ = StringUtils::StringToInt(supportTranslate); 217 } 218 }; 219 220 ~TextFieldTheme() override = default; 221 GetPadding()222 const Edge& GetPadding() const 223 { 224 return padding_; 225 } 226 GetUnderlinePadding()227 const Edge& GetUnderlinePadding() const 228 { 229 return underlinePadding_; 230 } 231 GetHeight()232 const Dimension& GetHeight() const 233 { 234 return height_; 235 } 236 GetContentHeight()237 const Dimension& GetContentHeight() const 238 { 239 return contentHeight_; 240 } 241 GetFontSize()242 const Dimension& GetFontSize() const 243 { 244 return fontSize_; 245 } 246 GetUnderlineFontSize()247 const Dimension& GetUnderlineFontSize() const 248 { 249 return underlineFontSize_; 250 } 251 GetFontWeight()252 const FontWeight& GetFontWeight() const 253 { 254 return fontWeight_; 255 } 256 GetBorderRadius()257 const Radius& GetBorderRadius() const 258 { 259 return borderRadius_; 260 } 261 GetBgColor()262 const Color& GetBgColor() const 263 { 264 return bgColor_; 265 } 266 GetPlaceholderColor()267 const Color& GetPlaceholderColor() const 268 { 269 return placeholderColor_; 270 } 271 GetFocusBgColor()272 const Color& GetFocusBgColor() const 273 { 274 return focusBgColor_; 275 } 276 GetFocusPlaceholderColor()277 const Color& GetFocusPlaceholderColor() const 278 { 279 return focusPlaceholderColor_; 280 } 281 GetFocusTextColor()282 const Color& GetFocusTextColor() const 283 { 284 return focusTextColor_; 285 } 286 GetTextColor()287 const Color& GetTextColor() const 288 { 289 return textColor_; 290 } 291 GetDisableTextColor()292 const Color& GetDisableTextColor() const 293 { 294 return disableTextColor_; 295 } 296 GetTextColorDisable()297 const Color& GetTextColorDisable() const 298 { 299 return textColorDisable_; 300 } 301 GetUnderlineActivedColor()302 const Color& GetUnderlineActivedColor() const 303 { 304 return underlineActivedColor_; 305 } 306 GetUnderlineTypingColor()307 const Color& GetUnderlineTypingColor() const 308 { 309 return underlineTypingColor_; 310 } 311 GetSelectedColor()312 const Color& GetSelectedColor() const 313 { 314 return selectedColor_; 315 } 316 GetHoverColor()317 const Color& GetHoverColor() const 318 { 319 return hoverColor_; 320 } 321 GetPressColor()322 const Color& GetPressColor() const 323 { 324 return pressColor_; 325 } 326 GetBorderRadiusSize()327 const Radius& GetBorderRadiusSize() const 328 { 329 return borderRadiusSize_; 330 } 331 GetDisableOpacityRatio()332 double GetDisableOpacityRatio() const 333 { 334 return disableOpacityRatio_; 335 } 336 GetDisabledIconFillColor()337 const Color& GetDisabledIconFillColor() const 338 { 339 return disabledIconFillColor_; 340 } 341 GetOverHideLength()342 const Dimension& GetOverHideLength() const 343 { 344 return overHideLength_; 345 } 346 GetCursorColor()347 const Color& GetCursorColor() const 348 { 349 return cursorColor_; 350 } 351 GetCursorRadius()352 const Dimension& GetCursorRadius() const 353 { 354 return cursorRadius_; 355 } 356 GetCursorWidth()357 const Dimension& GetCursorWidth() const 358 { 359 return cursorWidth_; 360 } 361 NeedFade()362 bool NeedFade() const 363 { 364 return needFade_; 365 } 366 GetIconSize()367 const Dimension& GetIconSize() const 368 { 369 return iconSize_; 370 } 371 GetIconHotZoneSize()372 const Dimension& GetIconHotZoneSize() const 373 { 374 return iconHotZoneSize_; 375 } 376 ShowEllipsis()377 bool ShowEllipsis() const 378 { 379 return showEllipsis_; 380 } 381 GetErrorSpacing()382 const Dimension& GetErrorSpacing() const 383 { 384 return errorSpacing_; 385 } 386 GetErrorIsInner()387 bool GetErrorIsInner() const 388 { 389 return errorIsInner_; 390 } 391 GetErrorBorderWidth()392 const Dimension& GetErrorBorderWidth() const 393 { 394 return errorBorderWidth_; 395 } 396 GetErrorBorderColor()397 const Color& GetErrorBorderColor() const 398 { 399 return errorBorderColor_; 400 } 401 GetErrorUnderlineColor()402 const Color& GetErrorUnderlineColor() const 403 { 404 return errorUnderlineColor_; 405 } 406 GetUnderlineColor()407 const Color& GetUnderlineColor() const 408 { 409 return underlineColor_; 410 } 411 GetDisableUnderlineColor()412 const Color& GetDisableUnderlineColor() const 413 { 414 return disableUnderlineColor_; 415 } 416 GetUnderlineTextColor()417 const Color& GetUnderlineTextColor() const 418 { 419 return underlineTextColor_; 420 } 421 GetOverCountBorderColor()422 const Color& GetOverCountBorderColor() const 423 { 424 return overCountBorderColor_; 425 } 426 GetTextStyle()427 TextStyle GetTextStyle() const 428 { 429 return textStyle_; 430 } 431 GetErrorTextStyle()432 const TextStyle& GetErrorTextStyle() const 433 { 434 return errorTextStyle_; 435 } 436 GetCountTextStyle()437 const TextStyle& GetCountTextStyle() const 438 { 439 return countTextStyle_; 440 } 441 GetOverCountStyle()442 const TextStyle& GetOverCountStyle() const 443 { 444 return overCountStyle_; 445 } 446 GetCountTextStyleOuter()447 const TextStyle& GetCountTextStyleOuter() const 448 { 449 return countTextStyleOuter_; 450 } 451 GetOverCountStyleOuter()452 const TextStyle& GetOverCountStyleOuter() const 453 { 454 return overCountStyleOuter_; 455 } 456 GetPasswordErrorTextColor()457 const Color& GetPasswordErrorTextColor() const 458 { 459 return passwordErrorTextColor_; 460 } 461 GetPasswordErrorInputColor()462 const Color& GetPasswordErrorInputColor() const 463 { 464 return passwordErrorInputColor_; 465 } 466 GetPasswordErrorBorderColor()467 const Color& GetPasswordErrorBorderColor() const 468 { 469 return passwordErrorBorderColor_; 470 } 471 GetPasswordErrorLableColor()472 const Color& GetPasswordErrorLableColor() const 473 { 474 return passwordErrorLableColor_; 475 } 476 GetOverCountTextStyle()477 const TextStyle& GetOverCountTextStyle() const 478 { 479 return overCountTextStyle_; 480 } 481 GetInlineTextColor()482 const Color& GetInlineTextColor() const 483 { 484 return inlineTextColor_; 485 } 486 GetInlineRadiusSize()487 const Radius& GetInlineRadiusSize() const 488 { 489 return inlineRadiusSize_; 490 } 491 GetInlineBgColor()492 const Color& GetInlineBgColor() const 493 { 494 return inlineBgColor_; 495 } 496 GetInlineBorderColor()497 const Color& GetInlineBorderColor() const 498 { 499 return inlineBorderColor_; 500 } 501 GetInlineBorderWidth()502 const Dimension& GetInlineBorderWidth() const 503 { 504 return inlineBorderWidth_; 505 } 506 GetDraggable()507 bool GetDraggable() const 508 { 509 return draggable_; 510 } 511 GetInsertCursorOffset()512 const Dimension& GetInsertCursorOffset() const 513 { 514 return insertCursorOffset_; 515 } 516 GetDefaultCounterColor()517 const Color& GetDefaultCounterColor() const 518 { 519 return defaultCounterColor_; 520 } 521 GetOverCounterColor()522 const Color& GetOverCounterColor() const 523 { 524 return overCounterColor_; 525 } 526 GetGlassOutlinePrimaryColor()527 const Color& GetGlassOutlinePrimaryColor() const 528 { 529 return glassOutlinePrimaryColor_; 530 } 531 GetGlassOutlineSecondaryColor()532 const Color& GetGlassOutlineSecondaryColor() const 533 { 534 return glassOutlineSecondaryColor_; 535 } 536 GetGlassMaskPrimaryColor()537 const Color& GetGlassMaskPrimaryColor() const 538 { 539 return glassMaskPrimaryColor_; 540 } 541 GetGlassMaskSecondaryColor()542 const Color& GetGlassMaskSecondaryColor() const 543 { 544 return glassMaskSecondaryColor_; 545 } 546 GetPasswordTypeHeight()547 const Dimension& GetPasswordTypeHeight() const 548 { 549 return passwordTypeHeight_; 550 } 551 IsShowPasswordDirectly()552 bool IsShowPasswordDirectly() const 553 { 554 return showPasswordDirectly_; 555 } 556 IsTextFieldShowHandle()557 bool IsTextFieldShowHandle() const 558 { 559 return textfieldShowHandle_; 560 } 561 GetAvoidKeyboardOffset()562 const Dimension& GetAvoidKeyboardOffset() const 563 { 564 return avoidKeyboardOffset_; 565 } 566 GetCancelButtonStyle()567 const CancelButtonStyle& GetCancelButtonStyle() const 568 { 569 return cancelButtonStyle_; 570 } 571 GetCancelButtonIconColor()572 const Color& GetCancelButtonIconColor() const 573 { 574 return cancelButtonIconColor_; 575 } 576 GetPreviewUnderlineColor()577 const Color& GetPreviewUnderlineColor() const 578 { 579 return previewUnderlineColor_; 580 } 581 GetPreviewBoardColor()582 const Color& GetPreviewBoardColor() const 583 { 584 return previewBoardColor_; 585 } 586 GetCancelButton()587 const std::string& GetCancelButton() const 588 { 589 return cancelButton_; 590 } 591 GetCancelImageText()592 const std::string& GetCancelImageText() const 593 { 594 return cancelImageText_; 595 } 596 getInlinePaddingRight()597 const Dimension& getInlinePaddingRight() const 598 { 599 return inlinePaddingRight_; 600 } 601 GetPlaceholderLineSpacing()602 const Dimension& GetPlaceholderLineSpacing() const 603 { 604 return placeholderLineSpacing_; 605 } 606 GetShowPasswordPromptInformation()607 const std::string& GetShowPasswordPromptInformation() const 608 { 609 return showPassword_; 610 } 611 GetHiddenPasswordPromptInformation()612 const std::string& GetHiddenPasswordPromptInformation() const 613 { 614 return hidePassword_; 615 } 616 GetAIWriteBundleName()617 const std::string& GetAIWriteBundleName() const 618 { 619 return aiWriteBundleName_; 620 } 621 GetAIWriteAbilityName()622 const std::string& GetAIWriteAbilityName() const 623 { 624 return aiWriteAbilityName_; 625 } 626 GetTranslateIsSupport()627 bool GetTranslateIsSupport() const 628 { 629 return translateIsSupport_; 630 } 631 GetAIWriteIsSupport()632 const std::string& GetAIWriteIsSupport() const 633 { 634 return aiWriteIsSupport_; 635 } 636 GetHasShowedPassword()637 const std::string& GetHasShowedPassword() const 638 { 639 return hasShowedPassword_; 640 } 641 GetHasHiddenPassword()642 const std::string& GetHasHiddenPassword() const 643 { 644 return hasHiddenPassword_; 645 } 646 647 protected: 648 TextFieldTheme() = default; 649 650 private: 651 Edge padding_; 652 Edge underlinePadding_; 653 Dimension height_; 654 Dimension contentHeight_; 655 Dimension fontSize_; 656 Dimension underlineFontSize_; 657 FontWeight fontWeight_ = FontWeight::NORMAL; 658 Radius borderRadius_; 659 660 Color bgColor_; 661 Radius borderRadiusSize_; 662 Color placeholderColor_; 663 Color focusBgColor_; 664 Color focusPlaceholderColor_; 665 Color focusTextColor_; 666 Color textColor_; 667 Color disableTextColor_; 668 Color underlineActivedColor_; 669 Color underlineTypingColor_; 670 Color textColorDisable_; 671 Color selectedColor_; 672 Color hoverColor_; 673 Color pressColor_; 674 Color disabledIconFillColor_; 675 Dimension errorSpacing_; 676 bool errorIsInner_ = false; 677 Dimension errorBorderWidth_; 678 Color errorBorderColor_; 679 Color overCountBorderColor_; 680 Color errorUnderlineColor_; 681 Color underlineColor_; 682 Color disableUnderlineColor_; 683 Color underlineTextColor_; 684 Color passwordErrorTextColor_; 685 Color passwordErrorInputColor_; 686 Color passwordErrorBorderColor_; 687 Color passwordErrorLableColor_; 688 TextStyle textStyle_; 689 TextStyle errorTextStyle_; 690 TextStyle countTextStyle_; 691 TextStyle overCountStyle_; 692 TextStyle countTextStyleOuter_; 693 TextStyle overCountStyleOuter_; 694 TextStyle overCountTextStyle_; 695 Color inlineTextColor_; 696 Radius inlineRadiusSize_; 697 Color inlineBgColor_; 698 Color inlineBorderColor_; 699 Color defaultCounterColor_; 700 Color overCounterColor_; 701 Color glassOutlinePrimaryColor_; 702 Color glassOutlineSecondaryColor_; 703 Color glassMaskPrimaryColor_; 704 Color glassMaskSecondaryColor_; 705 706 // UX::disable state: opacity is set to 38% of the default 707 double disableOpacityRatio_ = 1.0; 708 709 // UX::over length state 710 Dimension overHideLength_; 711 712 // UX::cursor state cursor-color=#000000, cursor blur-radius=0.9, cursor-width=2, cursor-height=24, cursor-radius=1 713 Color cursorColor_; 714 Dimension cursorRadius_; 715 Dimension cursorWidth_; 716 bool needFade_ = false; 717 718 // UX::icon size = 24, hotZoneSize = 36 719 Dimension iconSize_; 720 Dimension iconHotZoneSize_; 721 Dimension inlineBorderWidth_ = 2.0_vp; 722 723 // UX::insert cursor offset up by 24vp 724 Dimension insertCursorOffset_ = 24.0_vp; 725 726 Dimension avoidKeyboardOffset_ = 24.0_vp; 727 728 bool showEllipsis_ = true; 729 bool draggable_ = false; 730 bool showPasswordDirectly_ = false; 731 bool textfieldShowHandle_ = false; 732 bool translateIsSupport_ = false; 733 Dimension passwordTypeHeight_ = 40.0_vp; 734 735 // cancelButton 736 Color cancelButtonIconColor_; 737 CancelButtonStyle cancelButtonStyle_ = CancelButtonStyle::INPUT; 738 Color previewUnderlineColor_; 739 Color previewBoardColor_; 740 741 std::string cancelButton_; 742 743 Dimension inlinePaddingRight_ = 12.0_vp; 744 Dimension placeholderLineSpacing_ = 0.0_vp; 745 746 std::string hasShowedPassword_; 747 std::string hasHiddenPassword_; 748 std::string aiWriteBundleName_; 749 std::string aiWriteAbilityName_; 750 std::string aiWriteIsSupport_; 751 std::string showPassword_; 752 std::string hidePassword_; 753 std::string cancelImageText_; 754 }; 755 756 } // namespace OHOS::Ace 757 758 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXTFIELD_THEME_H 759