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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATOR_NAVIGATOR_EVENT_HUB_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATOR_NAVIGATOR_EVENT_HUB_H
18 
19 #include "core/components/navigator/navigator_component.h"
20 #include "core/components_ng/event/event_hub.h"
21 
22 namespace OHOS::Ace::NG {
23 class InspectorFilter;
24 
25 class NavigatorEventHub : public EventHub {
26     DECLARE_ACE_TYPE(NavigatorEventHub, EventHub)
27 
28 public:
29     NavigatorEventHub() = default;
30     ~NavigatorEventHub() override = default;
31 
SetUrl(const std::string & url)32     void SetUrl(const std::string& url)
33     {
34         url_ = url;
35     }
36 
GetUrl()37     std::string GetUrl()
38     {
39         return url_;
40     }
41 
SetParams(const std::string & params)42     void SetParams(const std::string& params)
43     {
44         params_ = params;
45     }
46 
GetParams()47     std::string GetParams()
48     {
49         return params_;
50     }
51 
52     void SetActive(bool active);
GetActive()53     bool GetActive() const
54     {
55         return active_;
56     }
57 
SetType(NavigatorType type)58     void SetType(NavigatorType type)
59     {
60         type_ = type;
61     }
62 
GetType()63     NavigatorType GetType()
64     {
65         return type_;
66     }
67 
68     void NavigatePage();
69 
70     std::string GetNavigatorType() const;
71     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
72 
73 private:
74     std::string url_;
75     std::string params_;
76     NavigatorType type_ = NavigatorType::PUSH;
77     // navigate page if active_
78     bool active_ = false;
79 
80     ACE_DISALLOW_COPY_AND_MOVE(NavigatorEventHub);
81 };
82 } // namespace OHOS::Ace::NG
83 
84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVIGATOR_NAVIGATOR_EVENT_HUB_H
85