@Kelly is trying thinking procedurally, instead of declaratively!
I am trying to figure out how to 'refresh' without going back to the menu.
Declare your Intentions!
Kelly! Remember that SwiftUI is a declarative language. First and foremost, just tell SwiftUI your intentions.
For example:
<< Hey! SwiftUI, I always want to show the user the cards that are in their hand. Always! >>
Now you need to provide the view with a model that represents the cards in your player's hand. If the model has six cards, SwiftUI will display the six cards. If you tap on one card, the .onTapGesture
should remove ONE card from your player's hand. How? The code should not try to update the user interface. Instead, the code should just CHANGE THE MODEL.
Change the Model
That is, the model, probably an array
of the player's hand will now only have five cards in it. Because the model has been updated, the user interface will invalidate itself and ask SwiftUI to update the PlayerHandView
.