• 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     friend class ResourceAdapterImplV2;
31     using RawAttrMap = std::map<std::string, std::string>;
32     using RawPatternMap = std::map<std::string, RawAttrMap>;
33 
ResourceThemeStyle(RefPtr<ResourceAdapter> resAdapter)34     explicit ResourceThemeStyle(RefPtr<ResourceAdapter> resAdapter) : resAdapter_(resAdapter) {};
35     ~ResourceThemeStyle() override = default;
36 
37     void ParseContent() override;
38 
39 protected:
40     void OnParseStyle();
41     void OnParseResourceMedia(const std::string& attrName, const std::string& attrValue);
42 
43 private:
44     RawAttrMap rawAttrs_; // key and value read from global resource api.
45     RawPatternMap patternAttrs_;
46     RefPtr<ResourceAdapter> resAdapter_;
47 };
48 } // namespace OHOS::Ace
49 
50 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_RESOURCE_THEME_STYLE_H
51