I have a ContentView quite simple with a toolbar enabling selection among some more complex secondary views:
enum SelectedTab {
case checklist
case altitude
}
@State var selectedTab: SelectedTab?
var body: some View {
NavigationView {
VStack {
switch selectedTab {
case .checklist:
ChecklistView()
case .altitude:
AltitudeView()
default:
ChecklistView()
}
}
}
}
Problem is that when I switch from one tab to another, the view is replaced and all content resets: How can I save the view state when switching from one tab to another, including scroll position in lists, toggle, fields?
Thanks