1 /* 2 * Copyright (c) 2024 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_NAVDESTINATION_CONTEXT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_CONTEXT_H 18 19 #include <string> 20 21 #include "base/memory/ace_type.h" 22 #include "core/components_ng/pattern/navigation/navigation_stack.h" 23 24 namespace OHOS::Ace::NG { 25 class NavigationStack; 26 class NavPathInfo : public virtual AceType { 27 DECLARE_ACE_TYPE(NavPathInfo, AceType) 28 public: 29 NavPathInfo() = default; NavPathInfo(const std::string & name)30 explicit NavPathInfo(const std::string& name) : name_(name) {} NavPathInfo(const std::string & name,bool isEntry)31 NavPathInfo(const std::string& name, bool isEntry) : name_(name), isEntry_(isEntry) {} 32 virtual ~NavPathInfo() = default; 33 SetName(const std::string & name)34 void SetName(const std::string& name) 35 { 36 name_ = name; 37 } 38 GetName()39 std::string GetName() const 40 { 41 return name_; 42 } 43 GetParamObj()44 virtual napi_value GetParamObj() const 45 { 46 return nullptr; 47 } 48 GetIsEntry()49 bool GetIsEntry() const 50 { 51 return isEntry_; 52 } 53 SetIsEntry(bool isEntry)54 void SetIsEntry(bool isEntry) 55 { 56 isEntry_ = isEntry; 57 } 58 59 protected: 60 std::string name_; 61 bool isEntry_ = false; 62 }; 63 64 class NavDestinationContext : public virtual AceType { 65 DECLARE_ACE_TYPE(NavDestinationContext, AceType) 66 public: 67 NavDestinationContext() = default; 68 virtual ~NavDestinationContext() = default; 69 SetNavPathInfo(RefPtr<NavPathInfo> info)70 void SetNavPathInfo(RefPtr<NavPathInfo> info) 71 { 72 pathInfo_ = info; 73 } 74 GetNavPathInfo()75 RefPtr<NavPathInfo> GetNavPathInfo() const 76 { 77 return pathInfo_; 78 } 79 SetNavigationStack(WeakPtr<NavigationStack> stack)80 void SetNavigationStack(WeakPtr<NavigationStack> stack) 81 { 82 navigationStack_ = stack; 83 } 84 GetNavigationStack()85 WeakPtr<NavigationStack> GetNavigationStack() const 86 { 87 return navigationStack_; 88 } 89 GetIndex()90 int32_t GetIndex() const 91 { 92 return index_; 93 } 94 SetIndex(int32_t index)95 void SetIndex(int32_t index) 96 { 97 index_ = index; 98 } 99 GetPreIndex()100 int32_t GetPreIndex() const 101 { 102 return preIndex_; 103 } 104 SetPreIndex(int32_t index)105 void SetPreIndex(int32_t index) 106 { 107 preIndex_ = index; 108 } 109 GetNavDestinationId()110 uint64_t GetNavDestinationId() const 111 { 112 return navDestinationId_; 113 } 114 SetNavDestinationId(uint64_t id)115 void SetNavDestinationId(uint64_t id) 116 { 117 navDestinationId_ = id; 118 } 119 SetIsEmpty(bool isEmpty)120 void SetIsEmpty(bool isEmpty) 121 { 122 isEmpty_ = isEmpty; 123 } 124 GetIsEmpty()125 bool GetIsEmpty() const 126 { 127 return isEmpty_; 128 } 129 SetMode(NavDestinationMode mode)130 void SetMode(NavDestinationMode mode) 131 { 132 mode_ = mode; 133 } 134 GetMode()135 NavDestinationMode GetMode() const 136 { 137 return mode_; 138 } 139 140 protected: 141 int32_t index_ = -1; 142 int32_t preIndex_ = -1; 143 uint64_t navDestinationId_ = 0; 144 NavDestinationMode mode_; 145 RefPtr<NavPathInfo> pathInfo_; 146 bool isEmpty_ = false; 147 WeakPtr<NavigationStack> navigationStack_; 148 }; 149 } // namespace OHOS::Ace::NG 150 151 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_NAVROUTER_NAVDESTINATION_CONTEXT_H 152