• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef FOUNDATION_ACE_ADAPTER_OHOS_OSAL_VIEW_DATA_WRAP_OHOS_H
17 #define FOUNDATION_ACE_ADAPTER_OHOS_OSAL_VIEW_DATA_WRAP_OHOS_H
18 
19 #include "base/view_data/view_data_wrap.h"
20 
21 #include <string>
22 #include <vector>
23 
24 #include "view_data.h"
25 
26 namespace OHOS::Ace {
27 class PageNodeInfoWrapOhos : public PageNodeInfoWrap {
DECLARE_ACE_TYPE(PageNodeInfoWrapOhos,PageNodeInfoWrap)28     DECLARE_ACE_TYPE(PageNodeInfoWrapOhos, PageNodeInfoWrap)
29 
30 public:
31     PageNodeInfoWrapOhos() {}
PageNodeInfoWrapOhos(const AbilityBase::PageNodeInfo & pageNodeInfo)32     PageNodeInfoWrapOhos(const AbilityBase::PageNodeInfo& pageNodeInfo): pageNodeInfo_(pageNodeInfo) {}
33     ~PageNodeInfoWrapOhos() = default;
34 
35     const AbilityBase::PageNodeInfo& GetPageNodeInfo() const;
36 
SetId(int32_t id)37     void SetId(int32_t id) override
38     {
39         pageNodeInfo_.id = id;
40     }
41 
GetId()42     int32_t GetId() const override
43     {
44         return pageNodeInfo_.id;
45     }
46 
SetDepth(int32_t depth)47     void SetDepth(int32_t depth) override
48     {
49         pageNodeInfo_.depth = depth;
50     }
51 
GetDepth()52     int32_t GetDepth() const override
53     {
54         return pageNodeInfo_.depth;
55     }
56 
SetAutoFillType(AceAutoFillType autoFillType)57     void SetAutoFillType(AceAutoFillType autoFillType) override
58     {
59         pageNodeInfo_.autoFillType = static_cast<AbilityBase::AutoFillType>(autoFillType);
60     }
61 
GetAutoFillType()62     AceAutoFillType GetAutoFillType() const override
63     {
64         return static_cast<AceAutoFillType>(pageNodeInfo_.autoFillType);
65     }
66 
SetTag(const std::string & tag)67     void SetTag(const std::string& tag) override
68     {
69         pageNodeInfo_.tag = tag;
70     }
71 
GetTag()72     const std::string& GetTag() const override
73     {
74         return pageNodeInfo_.tag;
75     }
76 
SetValue(const std::string & value)77     void SetValue(const std::string& value) override
78     {
79         pageNodeInfo_.value = value;
80     }
81 
GetValue()82     const std::string& GetValue() const override
83     {
84         return pageNodeInfo_.value;
85     }
86 
SetPlaceholder(const std::string & placeholder)87     void SetPlaceholder(const std::string& placeholder) override
88     {
89         pageNodeInfo_.placeholder = placeholder;
90     }
91 
GetPlaceholder()92     const std::string& GetPlaceholder() const override
93     {
94         return pageNodeInfo_.placeholder;
95     }
96 
SetPasswordRules(const std::string & passwordRules)97     void SetPasswordRules(const std::string& passwordRules) override
98     {
99         pageNodeInfo_.passwordRules = passwordRules;
100     }
101 
GetPasswordRules()102     const std::string& GetPasswordRules() const override
103     {
104         return pageNodeInfo_.passwordRules;
105     }
106 
SetEnableAutoFill(bool enableAutoFill)107     void SetEnableAutoFill(bool enableAutoFill) override
108     {
109         pageNodeInfo_.enableAutoFill = enableAutoFill;
110     }
111 
GetEnableAutoFill()112     bool GetEnableAutoFill() const override
113     {
114         return pageNodeInfo_.enableAutoFill;
115     }
116 private:
117     AbilityBase::PageNodeInfo pageNodeInfo_;
118 };
119 
120 class ViewDataWrapOhos : public ViewDataWrap {
DECLARE_ACE_TYPE(ViewDataWrapOhos,ViewDataWrap)121     DECLARE_ACE_TYPE(ViewDataWrapOhos, ViewDataWrap)
122 
123 public:
124     ViewDataWrapOhos() {}
125     ViewDataWrapOhos(const AbilityBase::ViewData& viewData);
126     ~ViewDataWrapOhos() = default;
127 
128     const AbilityBase::ViewData& GetViewData();
129 
SetBundleName(const std::string & bundleName)130     void SetBundleName(const std::string& bundleName) override
131     {
132         viewData_.bundleName = bundleName;
133     }
134 
GetBundleName()135     const std::string& GetBundleName() const override
136     {
137         return viewData_.bundleName;
138     }
139 
SetModuleName(const std::string & moduleName)140     void SetModuleName(const std::string& moduleName) override
141     {
142         viewData_.moduleName = moduleName;
143     }
144 
GetModuleName()145     const std::string& GetModuleName() const override
146     {
147         return viewData_.moduleName;
148     }
149 
SetAbilityName(const std::string & abilityName)150     void SetAbilityName(const std::string& abilityName) override
151     {
152         viewData_.abilityName = abilityName;
153     }
154 
GetAbilityName()155     const std::string& GetAbilityName() const override
156     {
157         return viewData_.abilityName;
158     }
159 
SetPageUrl(const std::string & pageUrl)160     void SetPageUrl(const std::string& pageUrl) override
161     {
162         viewData_.pageUrl = pageUrl;
163     }
164 
GetPageUrl()165     const std::string& GetPageUrl() const override
166     {
167         return viewData_.pageUrl;
168     }
169 
AddPageNodeInfoWrap(RefPtr<PageNodeInfoWrap> pageNodeInfoWrap)170     void AddPageNodeInfoWrap(RefPtr<PageNodeInfoWrap> pageNodeInfoWrap) override
171     {
172         pageNodeInfoWraps_.emplace_back(pageNodeInfoWrap);
173     }
174 
GetPageNodeInfoWraps()175     const std::vector<RefPtr<PageNodeInfoWrap>>& GetPageNodeInfoWraps() override
176     {
177         return pageNodeInfoWraps_;
178     }
179 private:
180     std::vector<RefPtr<PageNodeInfoWrap>> pageNodeInfoWraps_;
181     AbilityBase::ViewData viewData_;
182 };
183 } // namespace OHOS::Ace
184 #endif // FOUNDATION_ACE_ADAPTER_OHOS_OSAL_VIEW_DATA_WRAP_OHOS_H
185