• 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_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     virtual ~ThemeManager() = default;
31 
InitResource(const ResourceInfo & resourceInfo)32     virtual void InitResource(const ResourceInfo& resourceInfo) {}
33 
ReloadResource()34     virtual void ReloadResource() {}
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 
ParseSystemTheme()40     virtual void ParseSystemTheme() {}
41 
LoadCustomTheme(const RefPtr<AssetManager> & assetManager)42     virtual void LoadCustomTheme(const RefPtr<AssetManager>& assetManager) {}
43 
SetColorScheme(ColorScheme colorScheme)44     virtual void SetColorScheme(ColorScheme colorScheme) {}
45 
46     virtual Color GetBackgroundColor() const = 0;
47 
48     virtual RefPtr<ThemeConstants> GetThemeConstants(
49         const std::string& bundleName = "", const std::string& moduleName = "") 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 };
61 } // namespace OHOS::Ace
62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_THEME_THEME_MANAGER_H
63