You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,47 @@ final class OrdersRouter: SwiftUINavigationRouterProtocol { ... }
196
196
197
197
---
198
198
199
+
## ☝️ One more thing...
200
+
201
+
### 🚀 Simplify Your Navigation with `NavigationRouterView`
202
+
203
+
**Bored and tired of repeatedly defining `navigationDestination` everywhere?** Let `NavigationRouterView` handle everything for you!
204
+
205
+
### 🎯 Why `NavigationRouterView`?
206
+
207
+
- ✅ **Simplified Setup**: Define your navigation logic once and reuse it effortlessly across your app.
208
+
- ✅ **Cleaner Code**: No more repetitive `navigationDestination` setups cluttering your SwiftUI views.
209
+
- ✅ **Easy Maintenance**: Centralized routing makes your navigation easy to maintain and scale.
210
+
211
+
### ⚙️ How Does It Work?
212
+
213
+
`NavigationRouterView` uses a simple yet powerful protocol `NavigationRouterProtocol`, which lets you define navigation paths and corresponding views neatly in one place.
214
+
215
+
### Set Up `NavigationRouterView`
216
+
217
+
Simplify your view by embedding it within `NavigationRouterView`:
218
+
219
+
```swift
220
+
structHomeView: View {
221
+
@StateObjectprivatevar router =MyRouter()
222
+
223
+
var body: some View {
224
+
NavigationRouterView(router: router) {
225
+
VStack {
226
+
Button("Push Detail View") {
227
+
router.push(screen: .detailView)
228
+
}
229
+
}
230
+
.navigationTitle("Home")
231
+
}
232
+
}
233
+
}
234
+
```
235
+
236
+
That's it! 🎉 Now your navigation is cleaner, modular, and easier than ever!
237
+
238
+
---
239
+
199
240
## 📱 Example App
200
241
201
242
A basic working example is available inside the [`ExampleApp`](./ExampleApp) folder.
0 commit comments