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_FOCUS_ANIMATION_FOCUS_ANIMATION_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FOCUS_ANIMATION_FOCUS_ANIMATION_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 24 namespace OHOS::Ace { 25 26 /** 27 * FocusAnimationTheme defines color of FocusAnimationTheme. FocusAnimationTheme should be built 28 * using FocusAnimationTheme::Builder. 29 */ 30 class FocusAnimationTheme : public virtual Theme { 31 DECLARE_ACE_TYPE(FocusAnimationTheme, Theme); 32 33 public: 34 class Builder { 35 public: 36 Builder() = default; 37 ~Builder() = default; 38 Build(const RefPtr<ThemeConstants> & themeConstants)39 RefPtr<FocusAnimationTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 40 { 41 RefPtr<FocusAnimationTheme> theme = AceType::Claim(new FocusAnimationTheme()); 42 if (!themeConstants) { 43 return theme; 44 } 45 RefPtr<ThemeStyle> pattern = themeConstants->GetPatternByName(THEME_PATTERN_FOCUS_ANIMATION); 46 if (!pattern) { 47 LOGW("find pattern of focus_animation fail"); 48 return theme; 49 } 50 theme->color_ = pattern->GetAttr<Color>("focus_animation_color", Color::BLUE); 51 return theme; 52 } 53 }; 54 55 ~FocusAnimationTheme() override = default; 56 GetColor()57 const Color& GetColor() const 58 { 59 return color_; 60 } 61 62 protected: 63 FocusAnimationTheme() = default; 64 65 private: 66 Color color_; 67 }; 68 69 } // namespace OHOS::Ace 70 71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FOCUS_ANIMATION_FOCUS_ANIMATION_THEME_H 72