• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_ADAPTER_OHOS_OSAL_RESOURCE_THEME_STYLE_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_RESOURCE_THEME_STYLE_H
18 
19 #include <map>
20 
21 #include "core/components/theme/theme_style.h"
22 #include "core/components/theme/resource_adapter.h"
23 
24 namespace OHOS::Ace {
25 class ResourceThemeStyle : public ThemeStyle {
26     DECLARE_ACE_TYPE(ResourceThemeStyle, ThemeStyle);
27 
28 public:
29     friend class ResourceAdapterImpl;
30     using RawAttrMap = std::map<std::string, std::string>;
31     using RawPatternMap = std::map<std::string, RawAttrMap>;
32 
ResourceThemeStyle(RefPtr<ResourceAdapter> resAdapter)33     explicit ResourceThemeStyle(RefPtr<ResourceAdapter> resAdapter) : resAdapter_(resAdapter) {};
34     ~ResourceThemeStyle() override = default;
35 
36     void ParseContent() override;
37 
38 protected:
39     void OnParseStyle();
40     void OnParseResourceMedia(const std::string& attrName, const std::string& attrValue);
41 
42 private:
43     RawAttrMap rawAttrs_; // key and value read from global resource api.
44     RawPatternMap patternAttrs_;
45     RefPtr<ResourceAdapter> resAdapter_;
46 };
47 } // namespace OHOS::Ace
48 
49 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_RESOURCE_THEME_STYLE_H
50