1 /*
2  * Copyright (c) 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 #ifndef OHOS_THEME_PACK_CONFIG_H
16 #define OHOS_THEME_PACK_CONFIG_H
17 
18 #include "res_config_impl.h"
19 #include "resource_manager.h"
20 #include "res_common.h"
21 
22 namespace OHOS {
23 namespace Global {
24 namespace Resource {
25 class ThemeConfig {
26 public:
27     ThemeConfig();
28     /**
29      * Set theme resConfig direction
30      *
31      * @param direction the theme resConfig direction
32      */
33     void SetThemeDirection(Direction direction);
34 
35     /**
36      * Set theme resConfig colorMode
37      *
38      * @param colorMode the theme resConfig colorMode
39      */
40     void SetThemeColorMode(ColorMode colorMode);
41 
GetThemeColorMode()42     ColorMode GetThemeColorMode() const
43     {
44         return themeColorMode_;
45     }
46 
GetThemeDirection()47     Direction GetThemeDirection() const
48     {
49         return themeDirection_;
50     }
51 
52     /**
53      * Whether this themeConfig match the device resConfig
54      *
55      * @param themeConfig the theme resConfig
56      * @param resConfig the device resConfig
57      * @return true if this themeConfig match the device resConfig, else false
58      */
59     static bool Match(const std::shared_ptr<ThemeConfig> &themeConfig, const ResConfigImpl &resConfig);
60 
61     /**
62      * Whether this themeConfig best match the device resConfig
63      *
64      * @param themeConfig the theme resConfig
65      * @param resConfig the device resConfig
66      * @return true if this themeConfig best match the device resConfig, else false
67      */
68     bool BestMatch(const std::shared_ptr<ThemeConfig> &themeConfig, const ResConfigImpl &resConfig) const;
69 private:
70     bool IsMoreMatchThan(const std::shared_ptr<ThemeConfig> &themeConfig) const;
71 
72     Direction themeDirection_;
73     ColorMode themeColorMode_;
74 };
75 } // namespace Resource
76 } // namespace Global
77 } // namespace OHOS
78 #endif