1 /* 2 * Copyright (c) 2024 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_PICKER_DATE_PICKER_THEME_WRAPPER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PICKER_DATE_PICKER_THEME_WRAPPER_H 18 19 #include <memory> 20 21 #include "base/memory/ace_type.h" 22 #include "core/components/picker/picker_theme.h" 23 #include "core/components_ng/token_theme/token_theme_wrapper.h" 24 25 namespace OHOS::Ace::NG { 26 27 class PickerThemeWrapper : public PickerTheme, public TokenThemeWrapper { 28 DECLARE_ACE_TYPE(PickerThemeWrapper, PickerTheme); 29 30 public: 31 class WrapperBuilder : public Builder { 32 public: 33 WrapperBuilder() = default; 34 ~WrapperBuilder() = default; 35 BuildWrapper(const RefPtr<ThemeConstants> & themeConstants)36 RefPtr<TokenThemeWrapper> BuildWrapper(const RefPtr<ThemeConstants>& themeConstants) const 37 { 38 auto theme = AceType::MakeRefPtr<PickerThemeWrapper>(); 39 InitTheme(theme, themeConstants); 40 return theme; 41 } 42 }; 43 44 ~PickerThemeWrapper() override = default; 45 ApplyTokenTheme(const TokenTheme & theme)46 void ApplyTokenTheme(const TokenTheme& theme) override 47 { 48 if (auto colors = theme.Colors(); colors) { 49 TextStyle selectedOptionStyle = GetOptionStyle(true, false); 50 selectedOptionStyle.SetTextColor(colors->FontEmphasize()); 51 SetOptionStyle(true, false, selectedOptionStyle); 52 TextStyle disappearOptionStyle = GetDisappearOptionStyle(); 53 disappearOptionStyle.SetTextColor(colors->FontPrimary()); 54 SetDisappearOptionStyle(disappearOptionStyle); 55 TextStyle normalOptionStyle = GetOptionStyle(false, false); 56 normalOptionStyle.SetTextColor(colors->FontPrimary()); 57 SetOptionStyle(false, false, normalOptionStyle); 58 } 59 } 60 protected: 61 PickerThemeWrapper() = default; 62 }; 63 } // namespace OHOS::Ace::NG 64 65 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PICKER_DATE_PICKER_THEME_WRAPPER_H 66