• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_NG_PATTERN_SELECT_SELECT_THEME_WRAPPER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SELECT_SELECT_THEME_WRAPPER_H
18 
19 #include <memory>
20 
21 #include "base/memory/ace_type.h"
22 #include "core/components/select/select_theme.h"
23 #include "core/components_ng/token_theme/token_theme_wrapper.h"
24 
25 namespace OHOS::Ace::NG {
26 class SelectThemeWrapper : public SelectTheme, public TokenThemeWrapper {
27     DECLARE_ACE_TYPE(SelectThemeWrapper, SelectTheme);
28 
29 public:
30     class WrapperBuilder : public Builder {
31     public:
32         WrapperBuilder() = default;
33         ~WrapperBuilder() = default;
34 
BuildWrapper(const RefPtr<ThemeConstants> & themeConstants)35         RefPtr<TokenThemeWrapper> BuildWrapper(const RefPtr<ThemeConstants>& themeConstants) const
36         {
37             auto wrapper = AceType::MakeRefPtr<SelectThemeWrapper>();
38             auto theme = AceType::DynamicCast<SelectTheme>(wrapper);
39             if (!themeConstants) {
40                 return wrapper;
41             }
42             ParseNewPattern(themeConstants, theme);
43             Parse(themeConstants, theme);
44             return wrapper;
45         }
46     };
47 
48     ~SelectThemeWrapper() override = default;
49 
ApplyTokenTheme(const TokenTheme & theme)50     void ApplyTokenTheme(const TokenTheme& theme) override
51     {
52         if (auto colors = theme.Colors(); colors) {
53             SetFontColor(colors->FontPrimary());
54             SetButtonBackgroundColor(colors->CompBackgroundTertiary());
55         }
56     }
57 
58 protected:
59     SelectThemeWrapper() = default;
60 };
61 } // namespace OHOS::Ace::NG
62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SELECT_SELECT_THEME_WRAPPER_H