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_COUNTER_COUNTER_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_COUNTER_COUNTER_THEME_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components/common/properties/edge.h" 21 #include "core/components/common/properties/radius.h" 22 #include "core/components/common/properties/text_style.h" 23 #include "core/components/theme/theme.h" 24 #include "core/components/theme/theme_constants.h" 25 #include "core/components/theme/theme_constants_defines.h" 26 #include "core/components_ng/property/border_property.h" 27 28 namespace OHOS::Ace { 29 30 class CounterTheme : public virtual Theme { 31 DECLARE_ACE_TYPE(CounterTheme, Theme); 32 33 public: 34 class Builder { 35 public: 36 Builder() = default; 37 ~Builder() = default; 38 Build(const RefPtr<ThemeConstants> & themeConstants)39 RefPtr<CounterTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 40 { 41 RefPtr<CounterTheme> theme = AceType::MakeRefPtr<CounterTheme>(); 42 if (!themeConstants) { 43 return theme; 44 } 45 46 // init theme from global data 47 theme->contentTextStyle_.SetFontSize(themeConstants->GetDimension(THEME_COUNTER_TITLE_FONTSIZE)); 48 theme->contentTextStyle_.SetTextColor(themeConstants->GetColor(THEME_COUNTER_FONTCOLOR)); 49 theme->backgroundColor_ = themeConstants->GetColor(THEME_COUNTER_BACKGROUND_COLOR); 50 return theme; 51 } 52 }; 53 54 ~CounterTheme() override = default; 55 GetContentTextStyle()56 const TextStyle& GetContentTextStyle() const 57 { 58 return contentTextStyle_; 59 } 60 GetBackGroundColor()61 const Color& GetBackGroundColor() const 62 { 63 return backgroundColor_; 64 } 65 GetHeight()66 const Dimension& GetHeight() const 67 { 68 return height_; 69 } 70 GetWidth()71 const Dimension& GetWidth() const 72 { 73 return width_; 74 } 75 GetControlWidth()76 const Dimension& GetControlWidth() const 77 { 78 return controlWidth_; 79 } 80 GetContentWidth()81 const Dimension& GetContentWidth() const 82 { 83 return contentWidth_; 84 } 85 GetBorderRadius()86 const NG::BorderRadiusProperty& GetBorderRadius() const 87 { 88 return borderRadius_; 89 } 90 GetBorderWidth()91 const NG::BorderWidthProperty& GetBorderWidth() const 92 { 93 return borderWidth_; 94 } 95 GetBorderColor()96 const NG::BorderColorProperty& GetBorderColor() const 97 { 98 return borderColor_; 99 } 100 GetBorderStyle()101 const NG::BorderStyleProperty& GetBorderStyle() const 102 { 103 return borderStyle_; 104 } 105 106 private: 107 TextStyle contentTextStyle_; 108 Color backgroundColor_ = Color(0xff191919); 109 Dimension height_ = 32.0_vp; 110 Dimension width_ = 100.0_vp; 111 Dimension controlWidth_ = 32.0_vp; 112 Dimension contentWidth_ = 36.0_vp; 113 NG::BorderRadiusProperty borderRadius_ = { 4.0_vp, 4.0_vp, 4.0_vp, 4.0_vp }; 114 NG::BorderWidthProperty borderWidth_ = { 1.0_vp, 1.0_vp, 1.0_vp, 1.0_vp }; 115 NG::BorderColorProperty borderColor_ = { Color::GRAY, Color::GRAY, Color::GRAY, Color::GRAY }; 116 NG::BorderStyleProperty borderStyle_ = { BorderStyle::SOLID, BorderStyle::SOLID, BorderStyle::SOLID, 117 BorderStyle::SOLID }; 118 }; 119 120 } // namespace OHOS::Ace 121 122 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_COUNTER_COUNTER_THEME_H 123