Skip to content

Commit

Permalink
Fix stack case study (#2397)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stephencelis authored Aug 22, 2023
1 parent d22ed09 commit a7c1f79
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ComposableArchitecture
import SwiftUI

struct RootView: View {
@State var isNavigationStackCaseStudyPresented = false
let store: StoreOf<Root>

var body: some View {
Expand Down Expand Up @@ -161,15 +162,10 @@ struct RootView: View {
}

Section(header: Text("Navigation")) {
NavigationLink(
"Stack",
destination: NavigationDemoView(
store: self.store.scope(
state: \.navigationStack,
action: Root.Action.navigationStack
)
)
)
Button("Stack") {
self.isNavigationStackCaseStudyPresented = true
}
.buttonStyle(.plain)

NavigationLink(
"Navigate and load data",
Expand Down Expand Up @@ -256,6 +252,14 @@ struct RootView: View {
}
.navigationTitle("Case Studies")
.onAppear { self.store.send(.onAppear) }
.sheet(isPresented: self.$isNavigationStackCaseStudyPresented) {
NavigationDemoView(
store: self.store.scope(
state: \.navigationStack,
action: Root.Action.navigationStack
)
)
}
}
}
}
Expand Down

0 comments on commit a7c1f79

Please sign in to comment.