Skip to content

Instantly share code, notes, and snippets.

@tjmaynes
Created September 22, 2021 15:16
Show Gist options
  • Select an option

  • Save tjmaynes/15baf4d900047dd44cf7775e3010ff98 to your computer and use it in GitHub Desktop.

Select an option

Save tjmaynes/15baf4d900047dd44cf7775e3010ff98 to your computer and use it in GitHub Desktop.
...
struct ContentView: View {
@State private var selection: String?
var body: some View {
NavigationView {
VStack {
ButtonView(
message: "First screen",
buttonTitle: "Tap me!",
onTap: { self.selection = "view-2" }
)
NavigationLink(
destination: ButtonView(
message: "Second screen",
buttonTitle: "Tap me, again!",
onTap: { self.selection = "view-3" }
),
tag: "view-2",
selection: self.$selection
) { EmptyView() }
NavigationLink(
destination: ButtonView(
message: "Third screen",
buttonTitle: "One more time...",
onTap: { self.selection = "view-4" }
),
tag: "view-3",
selection: self.$selection
) { EmptyView() }
NavigationLink(
destination: Text("Final screen"),
tag: "view-4",
selection: self.$selection
) { EmptyView() }
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment