Skip to content

Commit 14f55a3

Browse files
committed
Make NavigationStack case study available on Mac
1 parent 9a4cec6 commit 14f55a3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ViewLifecycle/App.swift

+10
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@ struct ViewLifecycleApp: App {
66
WindowGroup {
77
RootView()
88
}
9+
#if os(macOS)
10+
Window("NavigationStack", id: "navigation-stack") {
11+
CaseStudyNavigationStack()
12+
.toolbar {
13+
ToolbarItem {
14+
Color.clear
15+
}
16+
}
17+
}
18+
#endif
919
}
1020
}

ViewLifecycle/CaseStudyNavigationStack.swift

+17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
import SwiftUI
22

3+
#if os(macOS)
4+
struct CaseStudyNavigationStackMac: View {
5+
@Environment(\.openWindow) private var openWindow: OpenWindowAction
6+
7+
var body: some View {
8+
VStack {
9+
Text("This example opens in a separate window because SwiftUI on macOS 13.1 can’t seem to handle a NavigationStack nested in a NavigationSplitView (or I’m holding it wrong; I’m running into an infinite loop with this setup).")
10+
Button("Open NavigationStack window") {
11+
openWindow(id: "navigation-stack")
12+
}
13+
}
14+
.padding()
15+
.navigationTitle("NavigationStack")
16+
}
17+
}
18+
#endif
19+
320
struct CaseStudyNavigationStack: View {
421
@State private var navigationPath: [Int] = []
522

ViewLifecycle/RootView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct MainContent: View {
7575
CaseStudyLazyVGrid()
7676
case .navigationStack:
7777
#if os(macOS)
78-
Text("SwiftUI on macOS 13.0 can’t seem to handle a NavigationStack nested in a NavigationSplitView. Please test this one on iOS.")
78+
CaseStudyNavigationStackMac()
7979
#else
8080
CaseStudyNavigationStack()
8181
#endif

0 commit comments

Comments
 (0)