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 #include "ui/view/theme/theme_style.h" 25 26 namespace OHOS::Ace { 27 class ACE_EXPORT ThemeManager : public AceType { 28 DECLARE_ACE_TYPE(ThemeManager, AceType); 29 30 public: 31 ThemeManager() = default; 32 ~ThemeManager() override = default; 33 InitResource(const ResourceInfo & resourceInfo)34 virtual void InitResource(const ResourceInfo& resourceInfo) {} 35 UpdateConfig(const ResourceConfiguration & config)36 virtual void UpdateConfig(const ResourceConfiguration& config) {} 37 LoadSystemTheme(int32_t themeId)38 virtual void LoadSystemTheme(int32_t themeId) {} 39 SetSystemThemeId(int32_t themeId)40 virtual void SetSystemThemeId(int32_t themeId) {} 41 GetSystemTheme()42 virtual int32_t GetSystemTheme() 43 { 44 return -1; 45 } 46 ParseSystemTheme()47 virtual void ParseSystemTheme() {} 48 LoadCustomTheme(const RefPtr<AssetManager> & assetManager)49 virtual void LoadCustomTheme(const RefPtr<AssetManager>& assetManager) {} 50 SetColorScheme(ColorScheme colorScheme)51 virtual void SetColorScheme(ColorScheme colorScheme) {} 52 53 virtual Color GetBackgroundColor() const = 0; 54 55 virtual RefPtr<ThemeConstants> GetThemeConstants( 56 const std::string& bundleName, const std::string& moduleName) const = 0; 57 58 virtual RefPtr<ThemeConstants> GetThemeConstants() const = 0; 59 60 virtual RefPtr<Theme> GetTheme(ThemeType type) = 0; 61 62 virtual RefPtr<Theme> GetTheme(ThemeType type, int32_t themeScopeId) = 0; 63 LoadResourceThemes()64 virtual void LoadResourceThemes() {} 65 66 template<typename T> GetTheme()67 RefPtr<T> GetTheme() 68 { 69 return AceType::DynamicCast<T>(GetTheme(T::TypeId())); 70 } 71 72 template<typename T> GetTheme(int32_t themeScopeId)73 RefPtr<T> GetTheme(int32_t themeScopeId) 74 { 75 return AceType::DynamicCast<T>(GetTheme(T::TypeId(), themeScopeId)); 76 } 77 GetResourceLimitKeys()78 virtual uint32_t GetResourceLimitKeys() const 79 { 80 return 0; 81 } 82 83 virtual void RegisterThemeKit(ThemeType type, Ace::Kit::BuildFunc func) = 0; 84 85 virtual void RegisterCustomThemeKit(ThemeType type, Ace::Kit::BuildThemeWrapperFunc func) = 0; 86 }; 87 } // namespace OHOS::Ace 88 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_THEME_MANAGER_H 89