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_THEME_CARD_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_CARD_THEME_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components/theme/theme.h" 21 #include "core/components/theme/theme_constants.h" 22 #include "core/components/theme/theme_constants_defines.h" 23 #include "core/components/theme/theme_manager.h" 24 25 namespace OHOS::Ace { 26 27 class CardTheme : public virtual Theme { 28 DECLARE_ACE_TYPE(CardTheme, Theme); 29 30 public: 31 class Builder { 32 public: 33 Builder() = default; 34 ~Builder() = default; 35 Build(const RefPtr<ThemeConstants> & themeConstants)36 RefPtr<CardTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 37 { 38 RefPtr<CardTheme> theme = AceType::Claim(new CardTheme()); 39 if (!themeConstants) { 40 return theme; 41 } 42 theme = AceType::Claim(new CardTheme()); 43 theme->borderRadius_ = themeConstants->GetDimension(THEME_CARD_BORDER_RADIUS); 44 theme->backgroundColor_ = themeConstants->GetColor(THEME_CARD_BACKGROUND_COLOR); 45 theme->blurRadius_ = themeConstants->GetDimension(THEME_CARD_BLUR_RADIUS); 46 return theme; 47 } 48 }; 49 50 ~CardTheme() override = default; 51 GetBackgroundColor()52 const Color& GetBackgroundColor() const 53 { 54 return backgroundColor_; 55 } 56 GetBorderRadius()57 const Dimension& GetBorderRadius() const 58 { 59 return borderRadius_; 60 } 61 GetBlurRadius()62 const Dimension& GetBlurRadius() const 63 { 64 return blurRadius_; 65 } 66 67 protected: 68 CardTheme() = default; 69 70 private: 71 Dimension borderRadius_; 72 Color backgroundColor_; 73 Dimension blurRadius_; 74 }; 75 76 } // namespace OHOS::Ace 77 78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_CARD_THEME_H 79