• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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             theme->chainMinSpace_ = themeConstants->GetDimension(THEME_LIST_CHAIN_MIN_SPACE);
49             theme->chainMaxSpace_ = themeConstants->GetDimension(THEME_LIST_CHAIN_MAX_SPACE);
50             theme->chainConductivity_ = themeConstants->GetDouble(THEME_LIST_CHAIN_CONDUCTIVITY);
51             theme->chainIntensity_ = themeConstants->GetDouble(THEME_LIST_CHAIN_INTENSITY);
52             theme->chainStiffness_ = themeConstants->GetDouble(THEME_LIST_CHAIN_STIFFNESS);
53             theme->chainDamping_ = themeConstants->GetDouble(THEME_LIST_CHAIN_DAMPING);
54             return theme;
55         }
56     };
57 
58     ~ListTheme() override = default;
59 
GetGradientWidth()60     const Dimension& GetGradientWidth() const
61     {
62         return gradientWidth_;
63     }
64 
GetBackgroundColor()65     const Color& GetBackgroundColor() const
66     {
67         return backgroundColor_;
68     }
69 
GetDividerColor()70     const Color& GetDividerColor() const
71     {
72         return dividerColor_;
73     }
74 
GetScrollDistance()75     double GetScrollDistance() const
76     {
77         return scrollDistance_;
78     }
79 
GetChainMinSpace()80     Dimension GetChainMinSpace() const
81     {
82         return chainMinSpace_;
83     }
GetChainMaxSpace()84     Dimension GetChainMaxSpace() const
85     {
86         return chainMaxSpace_;
87     }
GetChainConductivity()88     double GetChainConductivity() const
89     {
90         return chainConductivity_;
91     }
GetChainIntensity()92     double GetChainIntensity() const
93     {
94         return chainIntensity_;
95     }
GetChainStiffness()96     double GetChainStiffness() const
97     {
98         return chainStiffness_;
99     }
GetChainDamping()100     double GetChainDamping() const
101     {
102         return chainDamping_;
103     }
104 
105 protected:
106     ListTheme() = default;
107 
108 private:
109     Dimension gradientWidth_;
110     Color backgroundColor_;
111     Color dividerColor_;
112     double scrollDistance_ = 0.0;
113     Dimension chainMinSpace_;
114     Dimension chainMaxSpace_;
115     double chainConductivity_ = 0.0;
116     double chainIntensity_ = 0.0;
117     double chainStiffness_ = 0.0;
118     double chainDamping_ = 0.0;
119 };
120 
121 } // namespace OHOS::Ace
122 
123 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_LIST_LIST_THEME_H
124