Skip to content

Commit d75f07f

Browse files
committed
Updates to demo app and documentation for 1.2.3
1 parent 3540586 commit d75f07f

File tree

1,808 files changed

+1977
-1807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,808 files changed

+1977
-1807
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Navigator Changelog
22

3+
### 1.2.3
4+
5+
* Updates documentation to illustrate no longer needing `navigationDestination` registration in the majority of cases
6+
* Fixes a few non-Navigator issues in the demo app for Xcode 26
7+
38
### 1.2.1
49

510
* Adds new `navigationMap` modifier for multi-module application support

NavigatorDemo/NavigatorDemo/NavigatorDemo/Application/NavigatorDemoApp.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ extension NavigatorDemoApp{
5050

5151
nonisolated struct InitializationTask {
5252
let priority: TaskPriority
53-
let operation: @Sendable () async -> Void
53+
let operation: @isolated(any) @Sendable () async -> Void
5454
}
5555

5656
nonisolated static let tasks: [InitializationTask] = [
57-
.init(priority: .high, operation: task1),
58-
.init(priority: .high, operation: task2),
59-
.init(priority: .low, operation: task3),
60-
.init(priority: .medium, operation: task4),
57+
.init(priority: .high, operation: { await task1() }),
58+
.init(priority: .high, operation: { await task2() }),
59+
.init(priority: .low, operation: { await task3() }),
60+
.init(priority: .medium, operation: { await task4() }),
6161
]
6262

6363
}

NavigatorDemo/NavigatorDemo/NavigatorDemo/Application/TabView/ModernTabView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct ModernTabView : View {
2020
}
2121
}
2222
}
23+
.tint(.primary)
2324
// setup tab switching
2425
.onNavigationReceive { (tab: RootTabs, navigator: Navigator) in
2526
if tab == selectedTab {

NavigatorDemo/NavigatorDemo/NavigatorDemo/Features/Home/HomeView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ struct HomeRootView: View {
2424
var body: some View {
2525
ManagedNavigationStack(scene: RootTabs.home.id) {
2626
HomeContentView(viewModel: HomeContentViewModel(resolver: viewModel.resolver, title: "Home Navigation"))
27-
.tint(.white)
2827
.navigationCheckpoint(KnownCheckpoints.home)
2928
.onNavigationReceive { (destination: HomeDestinations, navigator) in
3029
navigator.navigate(to: destination)
@@ -36,7 +35,6 @@ struct HomeRootView: View {
3635
.toolbarBackground(.hidden, for: .navigationBar)
3736
}
3837
}
39-
.tint(.white)
4038
}
4139
}
4240

NavigatorDemo/NavigatorDemo/NavigatorDemo/Features/Settings/UnregisteredDestinations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import NavigatorUI
99
import SwiftUI
1010

11-
public enum UnregisteredDestinations: NavigationDestination {
11+
nonisolated public enum UnregisteredDestinations: NavigationDestination {
1212

1313
case page1
1414
case page2

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Advanced Navigation Support for SwiftUI.
88

9-
## Navigator 1.2.1
9+
## Navigator 1.2.3
1010

1111
Navigator provides SwiftUI with a simple yet powerful navigation layer based on NavigationStack.
1212

@@ -83,7 +83,7 @@ struct RootView: View {
8383
```
8484
It's that simple.
8585

86-
ManagedNavigationStack creates a NavigationStack for you and installs the associated Navigator environment variable that "manages" the stack. It provides the NavigationPath and also supports navigation options like automatically presenting sheets and fullScreenCovers.
86+
ManagedNavigationStack creates a NavigationStack for you and installs the associated Navigator environment variable that "manages" that particular NavigationStack. It provides it with the NavigationPath and also supports navigation options like automatically presenting sheets and fullScreenCovers.
8787

8888
Those with sharp eyes might have noticed something missing in the above code. We're using `NavigationLink` with a destination value, but where's the `.navigationDestination(for: HomeDestinations.self) { ... )` modifier?
8989

@@ -191,7 +191,7 @@ extension HomeDestinations {
191191
```
192192
In this case, should `navigator.navigate(to: HomeDestinations.page3)` be called, Navigator will automatically present that view in a sheet. All other views will be pushed onto the navigation stack.
193193

194-
The current navigation methods are: .push (default), .sheet, .cover, and .send.
194+
The current navigation methods are: .push (default), .sheet, .managedSheet, .cover, .managedCover, and .send.
195195

196196
Predefined methods can be overridden using Navigator's `navigate(to:method:)` function.
197197

Sources/NavigatorUI/Documentation.docc/Advanced/AdvancedDestinations.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
Building NavigationDestinations that access the environment and other use cases
44

5-
## External NavigationDestinations
5+
## Overview
66

77
Earlier we demonstrated how to provide ``NavigationDestination`` types with a view body that returns the correct view for that type.
88
```swift
9-
extension HomeDestinations: NavigationDestination {
9+
...
10+
case pageN(Int)
11+
1012
public var body: some View {
1113
switch self {
1214
case .page2:
@@ -24,7 +26,9 @@ It's a powerful technique, but what if we can't construct a specific view withou
2426

2527
Simple. Just delegate the view building to a standard SwiftUI view!
2628
```swift
27-
extension HomeDestinations: NavigationDestination {
29+
...
30+
case pageN(Int)
31+
2832
public var body: some View {
2933
HomeDestinationsView(destination: self)
3034
}
@@ -84,7 +88,7 @@ struct HomePageNView: View {
8488
```
8589
*See the 'DemoDependency.swift' file in the NavigatorDemo project for a possible dependency injection mechanism.*
8690

87-
## NavigationDestinations within Views
91+
### NavigationDestinations within Views
8892

8993
This technique also allows us to construct and use fully functional views elsewhere in our view code. Consider.
9094
```swift
@@ -100,7 +104,7 @@ struct RootHomeView: View {
100104
Remember, our enumerated values are Views! Just drop the value into a view to obtain a fully resolved `HomePageView` and view model from `HomeDestinationsView`,
101105
complete and ready to go.
102106

103-
## Custom Sheets using NavigationDestination
107+
### Custom Sheets using NavigationDestination
104108
Let's demonstrate that again using a custom presentation mechanism with detents.
105109

106110
Only this time instead of evaluating the enumerated value directly we'll do the same using a destination variable.
@@ -127,10 +131,48 @@ struct CustomSheetView: View {
127131
```
128132
Setting the variable passes the desired destination to the sheet closure via the `$showSettings` binding. Which again allows us to directly evaluate the value and obtain a fully resolved view ready for presentation.
129133

130-
## Cross Module View Dependencies
131-
Another technique that might not be apparent and you might have missed at first glance is how this gives us the ability to pass required views across features.
134+
Note that the `.navigationDismissible()` modifier "registers" our custom sheet with Navigator, and allows the view to be dismissed as needed when deep links and routing occurs elsewhere in the application. (See: <doc:Dismissible>.)
135+
136+
### Modular Views
137+
138+
We can also use this technique to expose a module's feature views *without* exposing exposing the views themselves. Consider.
139+
```swift
140+
public enum OrderDestinations: NavigationDestination {
141+
case orderSummaryCard(Order)
142+
case order(Item)
143+
case listPastOrders
144+
145+
public var body: some View {
146+
OrderDestinationsView(destination: self)
147+
}
148+
}
149+
```
150+
Again, this lets us obtain and use fully constructed views from a module *without* seeing the actual views that support them, and *without* knowing any details of how they're constructed.
151+
```swift
152+
struct CustomView: View {
153+
@Environment(\.navigator) var navigator
154+
@State var order: Order
155+
var body: some View {
156+
VStack {
157+
...
158+
OrderDestinations.orderSummaryCard(order)
159+
...
160+
}
161+
}
162+
}
163+
```
164+
And now the order summary card is in our view, doing it's thing.
165+
166+
Couple that with Navigator 1.2's ability to avoid the need for `navigationDestination` registrations, and you have an extremely powerful system at your command.
167+
168+
If the `orderSummaryCard` has a button that takes them to an internal `OrderSummaryDetails` page, that's fine.
169+
170+
It just works.
171+
172+
### Cross Module View Dependencies
173+
Another technique that might not be apparent is how this gives us the ability to pass required views across features.
132174

133-
Take another look at our `HomeDestinationsView`.
175+
Take another look at our original `HomeDestinationsView`.
134176
```swift
135177
private struct HomeDestinationsView: View {
136178
let destination: HomeDestinations

0 commit comments

Comments
 (0)