1 /*
2  * Copyright (c) 2021-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_FRAMEWORKS_CORE_COMPONENTS_NAVIGATOR_NAVIGATOR_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NAVIGATOR_NAVIGATOR_COMPONENT_H
18 
19 #include <string>
20 
21 #include "base/utils/macros.h"
22 #include "core/pipeline/base/sole_child_component.h"
23 
24 namespace OHOS::Ace {
25 
26 enum class NavigatorType {
27     DEFAULT = 0,
28     PUSH,
29     REPLACE,
30     BACK
31 };
32 
33 class ACE_EXPORT NavigatorComponent : public SoleChildComponent {
34     DECLARE_ACE_TYPE(NavigatorComponent, SoleChildComponent);
35 
36 public:
NavigatorComponent(const RefPtr<Component> & child)37     explicit NavigatorComponent(const RefPtr<Component>& child) : SoleChildComponent(child) {}
38     ~NavigatorComponent() override = default;
39 
40     RefPtr<RenderNode> CreateRenderNode() override;
41     RefPtr<Element> CreateElement() override;
42 
GetUri()43     std::string GetUri() const
44     {
45         return uri_;
46     }
47 
SetUri(const std::string & uri)48     void SetUri(const std::string& uri)
49     {
50         uri_ = uri;
51     }
52 
GetType()53     NavigatorType GetType() const
54     {
55         return type_;
56     }
57 
SetType(NavigatorType type)58     void SetType(NavigatorType type)
59     {
60         type_ = type;
61     }
62 
GetActive()63     bool GetActive() const
64     {
65         return active_;
66     }
67 
SetParams(const std::string & params)68     void SetParams(const std::string& params)
69     {
70         params_ = params;
71     }
72 
GetParams()73     const std::string& GetParams() const
74     {
75         return params_;
76     }
77 
SetActive(bool active)78     void SetActive(bool active)
79     {
80         active_ = active;
81     }
82 
IsDefHeight()83     bool IsDefHeight() const
84     {
85         return isDefHeight_;
86     }
87 
SetIsDefHeight(bool isDefHeight)88     void SetIsDefHeight(bool isDefHeight)
89     {
90         isDefHeight_ = isDefHeight;
91     }
92 
IsDefWidth()93     bool IsDefWidth() const
94     {
95         return isDefWidth_;
96     }
97 
SetIsDefWidth(bool isDefWidth)98     void SetIsDefWidth(bool isDefWidth)
99     {
100         isDefWidth_ = isDefWidth;
101     }
102 
GetClickedEventId()103     const EventMarker& GetClickedEventId() const
104     {
105         return clickEventId_;
106     }
107 
SetClickedEventId(const EventMarker & eventId)108     void SetClickedEventId(const EventMarker& eventId)
109     {
110         clickEventId_ = eventId;
111     }
112 
113 private:
114     std::string uri_;
115     std::string params_;
116     NavigatorType type_ = NavigatorType::PUSH;
117     bool active_ = false;
118     bool isDefHeight_ = false;
119     bool isDefWidth_ = false;
120     EventMarker clickEventId_;
121 };
122 
123 } // namespace OHOS::Ace
124 
125 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NAVIGATOR_NAVIGATOR_COMPONENT_H
126