• 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 BASE_PAGE_H
17 #define BASE_PAGE_H
18 
19 #include <memory>
20 #include <string>
21 #include <string_view>
22 #include <unordered_map>
23 #include "page.h"
24 #include "view_api.h"
25 
26 namespace Updater {
27 class BasePage : public Page {
28     friend class Page;
29     friend class PageManager; // for create dummy page when operator[]
30 public:
31     [[nodiscard]] bool BuildPage(const UxPageInfo &pageInfo);
32     std::string GetPageId() override;
33     void SetVisible(bool isVisible) override;
34     bool IsVisible() const override;
35     OHOS::UIViewGroup *GetView() const override;
36     bool IsValid() const override;
37     bool IsValidCom(const std::string &id) const override;
38     ViewProxy &operator[](const std::string &id) override;
39     static bool IsPageInfoValid(const UxPageInfo &pageInfo);
40 private:
41     BasePage();
42     BasePage(int16_t width, int16_t height);
43     void Reset();
44     [[nodiscard]] bool BuildComs(const UxPageInfo &pageInfo);
45     [[nodiscard]] bool BuildCom(const UxViewInfo &viewInfo, int &minY);
46     int16_t width_;
47     int16_t height_;
48     std::unique_ptr<OHOS::UIViewGroup> root_;
49     std::vector<std::unique_ptr<ViewProxy>> coms_;
50     std::unordered_map<std::string_view, ViewProxy *> comsMap_;
51     std::string pageId_;
52     OHOS::ColorType color_;
53 };
54 } // namespace Updater
55 #endif
56