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_LIST_LIST_THEME_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_LIST_LIST_THEME_H 18 19 #include "core/components/theme/theme.h" 20 #include "core/components/theme/theme_constants.h" 21 #include "core/components/theme/theme_constants_defines.h" 22 23 namespace OHOS::Ace { 24 25 /** 26 * ListTheme defines styles of list. ListTheme should be built 27 * using ListTheme::Builder. 28 */ 29 class ListTheme : public virtual Theme { 30 DECLARE_ACE_TYPE(ListTheme, Theme); 31 32 public: 33 class Builder { 34 public: 35 Builder() = default; 36 ~Builder() = default; 37 Build(const RefPtr<ThemeConstants> & themeConstants)38 RefPtr<ListTheme> Build(const RefPtr<ThemeConstants>& themeConstants) const 39 { 40 RefPtr<ListTheme> theme = AceType::Claim(new ListTheme()); 41 if (!themeConstants) { 42 return theme; 43 } 44 theme->gradientWidth_ = themeConstants->GetDimension(THEME_LIST_GRADIENT_WIDTH); 45 theme->backgroundColor_ = themeConstants->GetColor(THEME_LIST_BACKGROUND_COLOR); 46 theme->scrollDistance_ = themeConstants->GetDouble(THEME_LIST_SCROLL_DISTANCE); 47 theme->dividerColor_ = themeConstants->GetColor(THEME_LIST_DIVIDER_COLOR); 48 return theme; 49 } 50 }; 51 52 ~ListTheme() override = default; 53 GetGradientWidth()54 const Dimension& GetGradientWidth() const 55 { 56 return gradientWidth_; 57 } 58 GetBackgroundColor()59 const Color& GetBackgroundColor() const 60 { 61 return backgroundColor_; 62 } 63 GetDividerColor()64 const Color& GetDividerColor() const 65 { 66 return dividerColor_; 67 } 68 GetScrollDistance()69 double GetScrollDistance() const 70 { 71 return scrollDistance_; 72 } 73 74 protected: 75 ListTheme() = default; 76 77 private: 78 Dimension gradientWidth_; 79 Color backgroundColor_; 80 Color dividerColor_; 81 double scrollDistance_ = 0.0; 82 }; 83 84 } // namespace OHOS::Ace 85 86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_LIST_LIST_THEME_H 87