Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created August 27, 2021 22:58
Show Gist options
  • Save laevandus/39d43652d4c5e8b8e84c037e501d058f to your computer and use it in GitHub Desktop.
Save laevandus/39d43652d4c5e8b8e84c037e501d058f to your computer and use it in GitHub Desktop.
struct ContentView: View {
@StateObject var viewModel = ViewModel()
var body: some View {
NavigationView {
List {
ForEach(viewModel.fruits) { item in
NavigationLink(item.name, tag: item.id, selection: $viewModel.selectedId) {
Text(item.name)
.navigationTitle(item.name)
}
}
}
.listStyle(.sidebar)
Text("No selection")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment