Skip to content

Commit a7c1f79

Browse files
authored
Fix stack case study (#2397)
We originally took advantage of the fact that `NavigationView` could nest `NavigationStack`, though it was a little funky. We independently updated the root to be a `NavigationStack`, though, which unfortunately broke the stack case study since nested `NavigationStack`s are not supported in SwiftUI. Fixes #2396.
1 parent d22ed09 commit a7c1f79

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ComposableArchitecture
22
import SwiftUI
33

44
struct RootView: View {
5+
@State var isNavigationStackCaseStudyPresented = false
56
let store: StoreOf<Root>
67

78
var body: some View {
@@ -161,15 +162,10 @@ struct RootView: View {
161162
}
162163

163164
Section(header: Text("Navigation")) {
164-
NavigationLink(
165-
"Stack",
166-
destination: NavigationDemoView(
167-
store: self.store.scope(
168-
state: \.navigationStack,
169-
action: Root.Action.navigationStack
170-
)
171-
)
172-
)
165+
Button("Stack") {
166+
self.isNavigationStackCaseStudyPresented = true
167+
}
168+
.buttonStyle(.plain)
173169

174170
NavigationLink(
175171
"Navigate and load data",
@@ -256,6 +252,14 @@ struct RootView: View {
256252
}
257253
.navigationTitle("Case Studies")
258254
.onAppear { self.store.send(.onAppear) }
255+
.sheet(isPresented: self.$isNavigationStackCaseStudyPresented) {
256+
NavigationDemoView(
257+
store: self.store.scope(
258+
state: \.navigationStack,
259+
action: Root.Action.navigationStack
260+
)
261+
)
262+
}
259263
}
260264
}
261265
}

0 commit comments

Comments
 (0)