back with dismiss(Environment) and view reappears.
struct Person: Identifiable {
let id = UUID()
let name: String
}
struct ContentView: View {
@State var people: [Person] = [.init(name: "mike")]
@State var isPresented = false
var body: some View {
NavigationStack {
List(people) { person in
Text(person.name)
}
.navigationTitle("People")
.navigationDestination(isPresented: $isPresented) {
NewPerson(people: $people)
}
.toolbar {
ToolbarItem {
Button("Add") {
isPresented.toggle()
}
}
}
}
}
}
struct NewPerson: View {
@Environment(\.dismiss) var dismiss
@Binding var people: [Person]
var body: some View {
Button("Add and Back") {
people.append(.init(name: "ace"))
dismiss()
}
}
}