I would like to call a function, after clicking on an item, and before displaying the destination view.
The code below doesn't seem to work: myFunction
is called, but the destination view is not shown.
It looks like the onTapGesture
overwrites the NavigationLink
destination.
NavigationView {
List(restaurants) { restaurant in
NavigationLink(destination: RestaurantView(restaurant: restaurant)) {
RestaurantRow(restaurant: restaurant)
}.onTapGesture { myModel.myFunction(restaurant) }
}
}
How can I have both, when clicking on a list item?
- function is called
- destination view is shown