1 /* 2 * Copyright (c) 2021-2023 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_THEME_THEME_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_THEME_MANAGER_H 18 19 #include "base/memory/ace_type.h" 20 #include "base/resource/asset_manager.h" 21 #include "core/components/theme/theme.h" 22 #include "core/components/theme/theme_constants.h" 23 24 namespace OHOS::Ace { 25 class ACE_EXPORT ThemeManager : public AceType { 26 DECLARE_ACE_TYPE(ThemeManager, AceType); 27 28 public: 29 ThemeManager() = default; 30 ~ThemeManager() override = default; 31 InitResource(const ResourceInfo & resourceInfo)32 virtual void InitResource(const ResourceInfo& resourceInfo) {} 33 UpdateConfig(const ResourceConfiguration & config)34 virtual void UpdateConfig(const ResourceConfiguration& config) {} 35 LoadSystemTheme(int32_t themeId)36 virtual void LoadSystemTheme(int32_t themeId) {} 37 ParseSystemTheme()38 virtual void ParseSystemTheme() {} 39 LoadCustomTheme(const RefPtr<AssetManager> & assetManager)40 virtual void LoadCustomTheme(const RefPtr<AssetManager>& assetManager) {} 41 SetColorScheme(ColorScheme colorScheme)42 virtual void SetColorScheme(ColorScheme colorScheme) {} 43 44 virtual Color GetBackgroundColor() const = 0; 45 46 virtual RefPtr<ThemeConstants> GetThemeConstants( 47 const std::string& bundleName, const std::string& moduleName) const = 0; 48 49 virtual RefPtr<ThemeConstants> GetThemeConstants() const = 0; 50 51 virtual RefPtr<Theme> GetTheme(ThemeType type) = 0; 52 LoadResourceThemes()53 virtual void LoadResourceThemes() {} 54 55 template<typename T> GetTheme()56 RefPtr<T> GetTheme() 57 { 58 return AceType::DynamicCast<T>(GetTheme(T::TypeId())); 59 } 60 GetResourceLimitKeys()61 virtual uint32_t GetResourceLimitKeys() const 62 { 63 return 0; 64 } 65 }; 66 } // namespace OHOS::Ace 67 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_THEME_MANAGER_H 68