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_NAVROUTER_NAVROUTER_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVROUTER_PATTERN_H
18 
19 #include "core/components_ng/pattern/navigation/navigation_declaration.h"
20 #include "core/components_ng/pattern/navigation/navigation_stack.h"
21 #include "core/components_ng/pattern/navrouter/navrouter_event_hub.h"
22 #include "core/components_ng/pattern/pattern.h"
23 
24 namespace OHOS::Ace::NG {
25 
26 class ACE_EXPORT NavRouterPattern : public Pattern {
27     DECLARE_ACE_TYPE(NavRouterPattern, Pattern);
28 
29 public:
30     NavRouterPattern() = default;
31     ~NavRouterPattern() override = default;
32 
IsAtomicNode()33     bool IsAtomicNode() const override
34     {
35         return false;
36     }
37 
CreateEventHub()38     RefPtr<EventHub> CreateEventHub() override
39     {
40         return MakeRefPtr<NavRouterEventHub>();
41     }
42 
43     void OnModifyDone() override;
44 
SetRouteInfo(const RefPtr<RouteInfo> & routeInfo)45     void SetRouteInfo(const RefPtr<RouteInfo>& routeInfo)
46     {
47         routeInfo_ = routeInfo;
48     }
49 
GetRouteInfo()50     const RefPtr<RouteInfo>& GetRouteInfo()
51     {
52         return routeInfo_;
53     }
54 
SetNavRouteMode(NavRouteMode mode)55     void SetNavRouteMode(NavRouteMode mode)
56     {
57         mode_ = mode;
58     }
59 
GetNavRouteMode()60     NavRouteMode GetNavRouteMode()
61     {
62         return mode_;
63     }
64 
65 private:
66     RefPtr<ClickEvent> clickListener_;
67     RefPtr<RouteInfo> routeInfo_;
68     NavRouteMode mode_ = NavRouteMode::PUSH_WITH_RECREATE;
69 };
70 } // namespace OHOS::Ace::NG
71 
72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVROUTER_PATTERN_H
73