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; SetNavDestination(const std::string & name)44 void SetNavDestination(const std::string& name) 45 { 46 name_ = name; 47 } 48 GetNavDestination()49 const std::string& GetNavDestination() const 50 { 51 return name_; 52 } 53 SetRouteInfo(const RefPtr<RouteInfo> & routeInfo)54 void SetRouteInfo(const RefPtr<RouteInfo>& routeInfo) 55 { 56 routeInfo_ = routeInfo; 57 } 58 GetRouteInfo()59 const RefPtr<RouteInfo>& GetRouteInfo() 60 { 61 return routeInfo_; 62 } 63 SetNavRouteMode(NavRouteMode mode)64 void SetNavRouteMode(NavRouteMode mode) 65 { 66 mode_ = mode; 67 } 68 GetNavRouteMode()69 NavRouteMode GetNavRouteMode() 70 { 71 return mode_; 72 } 73 74 private: 75 RefPtr<ClickEvent> clickListener_; 76 std::string name_; 77 RefPtr<RouteInfo> routeInfo_; 78 NavRouteMode mode_ = NavRouteMode::PUSH_WITH_RECREATE; 79 }; 80 } // namespace OHOS::Ace::NG 81 82 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVROUTER_PATTERN_H 83