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         }
216     };
217 
218     ~TextFieldTheme() override = default;
219 
GetPadding()220     const Edge& GetPadding() const
221     {
222         return padding_;
223     }
224 
GetUnderlinePadding()225     const Edge& GetUnderlinePadding() const
226     {
227         return underlinePadding_;
228     }
229 
GetHeight()230     const Dimension& GetHeight() const
231     {
232         return height_;
233     }
234 
GetContentHeight()235     const Dimension& GetContentHeight() const
236     {
237         return contentHeight_;
238     }
239 
GetFontSize()240     const Dimension& GetFontSize() const
241     {
242         return fontSize_;
243     }
244 
GetUnderlineFontSize()245     const Dimension& GetUnderlineFontSize() const
246     {
247         return underlineFontSize_;
248     }
249 
GetFontWeight()250     const FontWeight& GetFontWeight() const
251     {
252         return fontWeight_;
253     }
254 
GetBorderRadius()255     const Radius& GetBorderRadius() const
256     {
257         return borderRadius_;
258     }
259 
GetBgColor()260     const Color& GetBgColor() const
261     {
262         return bgColor_;
263     }
264 
GetPlaceholderColor()265     const Color& GetPlaceholderColor() const
266     {
267         return placeholderColor_;
268     }
269 
GetFocusBgColor()270     const Color& GetFocusBgColor() const
271     {
272         return focusBgColor_;
273     }
274 
GetFocusPlaceholderColor()275     const Color& GetFocusPlaceholderColor() const
276     {
277         return focusPlaceholderColor_;
278     }
279 
GetFocusTextColor()280     const Color& GetFocusTextColor() const
281     {
282         return focusTextColor_;
283     }
284 
GetTextColor()285     const Color& GetTextColor() const
286     {
287         return textColor_;
288     }
289 
GetDisableTextColor()290     const Color& GetDisableTextColor() const
291     {
292         return disableTextColor_;
293     }
294 
GetTextColorDisable()295     const Color& GetTextColorDisable() const
296     {
297         return textColorDisable_;
298     }
299 
GetUnderlineActivedColor()300     const Color& GetUnderlineActivedColor() const
301     {
302         return underlineActivedColor_;
303     }
304 
GetUnderlineTypingColor()305     const Color& GetUnderlineTypingColor() const
306     {
307         return underlineTypingColor_;
308     }
309 
GetSelectedColor()310     const Color& GetSelectedColor() const
311     {
312         return selectedColor_;
313     }
314 
GetHoverColor()315     const Color& GetHoverColor() const
316     {
317         return hoverColor_;
318     }
319 
GetPressColor()320     const Color& GetPressColor() const
321     {
322         return pressColor_;
323     }
324 
GetBorderRadiusSize()325     const Radius& GetBorderRadiusSize() const
326     {
327         return borderRadiusSize_;
328     }
329 
GetDisableOpacityRatio()330     double GetDisableOpacityRatio() const
331     {
332         return disableOpacityRatio_;
333     }
334 
GetDisabledIconFillColor()335     const Color& GetDisabledIconFillColor() const
336     {
337         return disabledIconFillColor_;
338     }
339 
GetOverHideLength()340     const Dimension& GetOverHideLength() const
341     {
342         return overHideLength_;
343     }
344 
GetCursorColor()345     const Color& GetCursorColor() const
346     {
347         return cursorColor_;
348     }
349 
GetCursorRadius()350     const Dimension& GetCursorRadius() const
351     {
352         return cursorRadius_;
353     }
354 
GetCursorWidth()355     const Dimension& GetCursorWidth() const
356     {
357         return cursorWidth_;
358     }
359 
NeedFade()360     bool NeedFade() const
361     {
362         return needFade_;
363     }
364 
GetIconSize()365     const Dimension& GetIconSize() const
366     {
367         return iconSize_;
368     }
369 
GetIconHotZoneSize()370     const Dimension& GetIconHotZoneSize() const
371     {
372         return iconHotZoneSize_;
373     }
374 
ShowEllipsis()375     bool ShowEllipsis() const
376     {
377         return showEllipsis_;
378     }
379 
GetErrorSpacing()380     const Dimension& GetErrorSpacing() const
381     {
382         return errorSpacing_;
383     }
384 
GetErrorIsInner()385     bool GetErrorIsInner() const
386     {
387         return errorIsInner_;
388     }
389 
GetErrorBorderWidth()390     const Dimension& GetErrorBorderWidth() const
391     {
392         return errorBorderWidth_;
393     }
394 
GetErrorBorderColor()395     const Color& GetErrorBorderColor() const
396     {
397         return errorBorderColor_;
398     }
399 
GetErrorUnderlineColor()400     const Color& GetErrorUnderlineColor() const
401     {
402         return errorUnderlineColor_;
403     }
404 
GetUnderlineColor()405     const Color& GetUnderlineColor() const
406     {
407         return underlineColor_;
408     }
409 
GetDisableUnderlineColor()410     const Color& GetDisableUnderlineColor() const
411     {
412         return disableUnderlineColor_;
413     }
414 
GetUnderlineTextColor()415     const Color& GetUnderlineTextColor() const
416     {
417         return underlineTextColor_;
418     }
419 
GetOverCountBorderColor()420     const Color& GetOverCountBorderColor() const
421     {
422         return overCountBorderColor_;
423     }
424 
GetTextStyle()425     TextStyle GetTextStyle() const
426     {
427         return textStyle_;
428     }
429 
GetErrorTextStyle()430     const TextStyle& GetErrorTextStyle() const
431     {
432         return errorTextStyle_;
433     }
434 
GetCountTextStyle()435     const TextStyle& GetCountTextStyle() const
436     {
437         return countTextStyle_;
438     }
439 
GetOverCountStyle()440     const TextStyle& GetOverCountStyle() const
441     {
442         return overCountStyle_;
443     }
444 
GetCountTextStyleOuter()445     const TextStyle& GetCountTextStyleOuter() const
446     {
447         return countTextStyleOuter_;
448     }
449 
GetOverCountStyleOuter()450     const TextStyle& GetOverCountStyleOuter() const
451     {
452         return overCountStyleOuter_;
453     }
454 
GetPasswordErrorTextColor()455     const Color& GetPasswordErrorTextColor() const
456     {
457         return passwordErrorTextColor_;
458     }
459 
GetPasswordErrorInputColor()460     const Color& GetPasswordErrorInputColor() const
461     {
462         return passwordErrorInputColor_;
463     }
464 
GetPasswordErrorBorderColor()465     const Color& GetPasswordErrorBorderColor() const
466     {
467         return passwordErrorBorderColor_;
468     }
469 
GetPasswordErrorLableColor()470     const Color& GetPasswordErrorLableColor() const
471     {
472         return passwordErrorLableColor_;
473     }
474 
GetOverCountTextStyle()475     const TextStyle& GetOverCountTextStyle() const
476     {
477         return overCountTextStyle_;
478     }
479 
GetInlineTextColor()480     const Color& GetInlineTextColor() const
481     {
482         return inlineTextColor_;
483     }
484 
GetInlineRadiusSize()485     const Radius& GetInlineRadiusSize() const
486     {
487         return inlineRadiusSize_;
488     }
489 
GetInlineBgColor()490     const Color& GetInlineBgColor() const
491     {
492         return inlineBgColor_;
493     }
494 
GetInlineBorderColor()495     const Color& GetInlineBorderColor() const
496     {
497         return inlineBorderColor_;
498     }
499 
GetInlineBorderWidth()500     const Dimension& GetInlineBorderWidth() const
501     {
502         return inlineBorderWidth_;
503     }
504 
GetDraggable()505     bool GetDraggable() const
506     {
507         return draggable_;
508     }
509 
GetInsertCursorOffset()510     const Dimension& GetInsertCursorOffset() const
511     {
512         return insertCursorOffset_;
513     }
514 
GetDefaultCounterColor()515     const Color& GetDefaultCounterColor() const
516     {
517         return defaultCounterColor_;
518     }
519 
GetOverCounterColor()520     const Color& GetOverCounterColor() const
521     {
522         return overCounterColor_;
523     }
524 
GetGlassOutlinePrimaryColor()525     const Color& GetGlassOutlinePrimaryColor() const
526     {
527         return glassOutlinePrimaryColor_;
528     }
529 
GetGlassOutlineSecondaryColor()530     const Color& GetGlassOutlineSecondaryColor() const
531     {
532         return glassOutlineSecondaryColor_;
533     }
534 
GetGlassMaskPrimaryColor()535     const Color& GetGlassMaskPrimaryColor() const
536     {
537         return glassMaskPrimaryColor_;
538     }
539 
GetGlassMaskSecondaryColor()540     const Color& GetGlassMaskSecondaryColor() const
541     {
542         return glassMaskSecondaryColor_;
543     }
544 
GetPasswordTypeHeight()545     const Dimension& GetPasswordTypeHeight() const
546     {
547         return passwordTypeHeight_;
548     }
549 
IsShowPasswordDirectly()550     bool IsShowPasswordDirectly() const
551     {
552         return showPasswordDirectly_;
553     }
554 
IsTextFieldShowHandle()555     bool IsTextFieldShowHandle() const
556     {
557         return textfieldShowHandle_;
558     }
559 
GetAvoidKeyboardOffset()560     const Dimension& GetAvoidKeyboardOffset() const
561     {
562         return avoidKeyboardOffset_;
563     }
564 
GetCancelButtonStyle()565     const CancelButtonStyle& GetCancelButtonStyle() const
566     {
567         return cancelButtonStyle_;
568     }
569 
GetCancelButtonIconColor()570     const Color& GetCancelButtonIconColor() const
571     {
572         return cancelButtonIconColor_;
573     }
574 
GetPreviewUnderlineColor()575     const Color& GetPreviewUnderlineColor() const
576     {
577         return previewUnderlineColor_;
578     }
579 
GetPreviewBoardColor()580     const Color& GetPreviewBoardColor() const
581     {
582         return previewBoardColor_;
583     }
584 
GetCancelButton()585     const std::string& GetCancelButton() const
586     {
587         return cancelButton_;
588     }
589 
GetCancelImageText()590     const std::string& GetCancelImageText() const
591     {
592         return cancelImageText_;
593     }
594 
getInlinePaddingRight()595     const Dimension& getInlinePaddingRight() const
596     {
597         return inlinePaddingRight_;
598     }
599 
GetPlaceholderLineSpacing()600     const Dimension& GetPlaceholderLineSpacing() const
601     {
602         return placeholderLineSpacing_;
603     }
604 
GetShowPasswordPromptInformation()605     const std::string& GetShowPasswordPromptInformation() const
606     {
607         return showPassword_;
608     }
609 
GetHiddenPasswordPromptInformation()610     const std::string& GetHiddenPasswordPromptInformation() const
611     {
612         return hidePassword_;
613     }
614 
GetAIWriteBundleName()615     const std::string& GetAIWriteBundleName() const
616     {
617         return aiWriteBundleName_;
618     }
619 
GetAIWriteAbilityName()620     const std::string& GetAIWriteAbilityName() const
621     {
622         return aiWriteAbilityName_;
623     }
624 
GetAIWriteIsSupport()625     const std::string& GetAIWriteIsSupport() const
626     {
627         return aiWriteIsSupport_;
628     }
629 
GetHasShowedPassword()630     const std::string& GetHasShowedPassword() const
631     {
632         return hasShowedPassword_;
633     }
634 
GetHasHiddenPassword()635     const std::string& GetHasHiddenPassword() const
636     {
637         return hasHiddenPassword_;
638     }
639 
640 protected:
641     TextFieldTheme() = default;
642 
643 private:
644     Edge padding_;
645     Edge underlinePadding_;
646     Dimension height_;
647     Dimension contentHeight_;
648     Dimension fontSize_;
649     Dimension underlineFontSize_;
650     FontWeight fontWeight_ = FontWeight::NORMAL;
651     Radius borderRadius_;
652 
653     Color bgColor_;
654     Radius borderRadiusSize_;
655     Color placeholderColor_;
656     Color focusBgColor_;
657     Color focusPlaceholderColor_;
658     Color focusTextColor_;
659     Color textColor_;
660     Color disableTextColor_;
661     Color underlineActivedColor_;
662     Color underlineTypingColor_;
663     Color textColorDisable_;
664     Color selectedColor_;
665     Color hoverColor_;
666     Color pressColor_;
667     Color disabledIconFillColor_;
668     Dimension errorSpacing_;
669     bool errorIsInner_ = false;
670     Dimension errorBorderWidth_;
671     Color errorBorderColor_;
672     Color overCountBorderColor_;
673     Color errorUnderlineColor_;
674     Color underlineColor_;
675     Color disableUnderlineColor_;
676     Color underlineTextColor_;
677     Color passwordErrorTextColor_;
678     Color passwordErrorInputColor_;
679     Color passwordErrorBorderColor_;
680     Color passwordErrorLableColor_;
681     TextStyle textStyle_;
682     TextStyle errorTextStyle_;
683     TextStyle countTextStyle_;
684     TextStyle overCountStyle_;
685     TextStyle countTextStyleOuter_;
686     TextStyle overCountStyleOuter_;
687     TextStyle overCountTextStyle_;
688     Color inlineTextColor_;
689     Radius inlineRadiusSize_;
690     Color inlineBgColor_;
691     Color inlineBorderColor_;
692     Color defaultCounterColor_;
693     Color overCounterColor_;
694     Color glassOutlinePrimaryColor_;
695     Color glassOutlineSecondaryColor_;
696     Color glassMaskPrimaryColor_;
697     Color glassMaskSecondaryColor_;
698 
699     // UX::disable state: opacity is set to 38% of the default
700     double disableOpacityRatio_ = 1.0;
701 
702     // UX::over length state
703     Dimension overHideLength_;
704 
705     // UX::cursor state cursor-color=#000000, cursor blur-radius=0.9, cursor-width=2, cursor-height=24, cursor-radius=1
706     Color cursorColor_;
707     Dimension cursorRadius_;
708     Dimension cursorWidth_;
709     bool needFade_ = false;
710 
711     // UX::icon size = 24, hotZoneSize = 36
712     Dimension iconSize_;
713     Dimension iconHotZoneSize_;
714     Dimension inlineBorderWidth_ = 2.0_vp;
715 
716     // UX::insert cursor offset up by 24vp
717     Dimension insertCursorOffset_ = 24.0_vp;
718 
719     Dimension avoidKeyboardOffset_ = 24.0_vp;
720 
721     bool showEllipsis_ = true;
722     bool draggable_ = false;
723     bool showPasswordDirectly_ = false;
724     bool textfieldShowHandle_ = false;
725     Dimension passwordTypeHeight_ = 40.0_vp;
726 
727     // cancelButton
728     Color cancelButtonIconColor_;
729     CancelButtonStyle cancelButtonStyle_ = CancelButtonStyle::INPUT;
730     Color previewUnderlineColor_;
731     Color previewBoardColor_;
732 
733     std::string cancelButton_;
734 
735     Dimension inlinePaddingRight_ = 12.0_vp;
736     Dimension placeholderLineSpacing_ = 0.0_vp;
737 
738     std::string hasShowedPassword_;
739     std::string hasHiddenPassword_;
740     std::string aiWriteBundleName_;
741     std::string aiWriteAbilityName_;
742     std::string aiWriteIsSupport_;
743     std::string showPassword_;
744     std::string hidePassword_;
745     std::string cancelImageText_;
746 };
747 
748 } // namespace OHOS::Ace
749 
750 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TEXT_FIELD_TEXTFIELD_THEME_H
751