1 /*
2  * Copyright (c) 2020-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 /**
17  * @addtogroup UI_Theme
18  * @{
19  *
20  * @brief Defines UI themes.
21  *
22  * @since 1.0
23  * @version 1.0
24  */
25 
26 /**
27  * @file theme_manager.h
28  *
29  * @brief Declares the singleton class used to manage the current screen theme of an application.
30  *
31  * @since 1.0
32  * @version 1.0
33  */
34 
35 #ifndef GRAPHIC_LITE_THEME_MANAGER_H
36 #define GRAPHIC_LITE_THEME_MANAGER_H
37 
38 #include "themes/theme.h"
39 
40 namespace OHOS {
41 /**
42  * @brief Declares the singleton class used to manage the current screen theme of an application.
43  *
44  * @since 1.0
45  * @version 1.0
46  */
47 class ThemeManager : public HeapBase {
48 public:
49     /**
50      * @brief Obtains the singleton instance of the <b>ThemeManager</b> class.
51      *
52      * @return Returns the singleton instance of the <b>ThemeManager</b> class.
53      */
54     static ThemeManager& GetInstance();
55 
56     /**
57      * @brief Sets the current screen theme for this application.
58      *
59      * @param theme Indicates the theme to set.
60      *
61      * @since 1.0
62      * @version 1.0
63      */
64     void SetCurrent(Theme* theme);
65 
66     /**
67      * @brief Obtains the current screen theme of this application.
68      *
69      * @return Returns the current theme if available; returns <b>nullptr</b> otherwise.
70      *
71      * @since 1.0
72      * @version 1.0
73      */
GetCurrent()74     Theme* GetCurrent()
75     {
76         return theme_;
77     };
78 
79 private:
ThemeManager()80     ThemeManager() : theme_(nullptr) {}
~ThemeManager()81     virtual ~ThemeManager()
82     {
83         theme_ = nullptr;
84     }
85 
86     Theme* theme_;
87 };
88 } // namespace OHOS
89 #endif // GRAPHIC_LITE_THEME_MANAGER_H
90