Check out the Migrating to new navigation types article to see how SwiftUI's navigation APIs changed.
New in iOS 17 is a modifier that seems to be a replacement for the tag-selection navigation link behaviour: navigationDestination(item:destination:).
Something like this could work:
var body: some View {
NavigationStack { // change here
VStack {
List(forms, id: \.self) { form in
// use new navigation link with a value
NavigationLink(value: form) {
Text(form)
}
}
// add new modifier
.navigationDestination(item: formBinding()) { form in
formView(for: form)
}
}
}
}
private var formBinding() -> Binding<String?> { // remove unused parameter
Binding<String?>(
get: { selectedForm },
set: { newValue in
if newValue != selectedForm {
selectedForm = newValue
isFormSelected = newValue != nil
}
}
)
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: