So, the Apple button example for @State has no real utility as a button.
To be honest, I find a View's ability to interleave (procedural) state with (declarative) layout and gestures to be rather complex.
Currently, am using a MVVM pattern; a combination of Model, ViewModel (or Vm), and View. The Vm is passed as an @ObservedObject and receives the View's .onAppear
and .onChange
messages. This eliminates the View's need for @State, @Binding, and @StateObject. So, the Vm focuses on the state machine, while the View focuses on layout and dispatching gestures.
A Vm class can also persist and synchronize across devices, such as iWatch-iPhone-iPad-AppleTv-SharePlay, etc. But, maybe there is a better way of accomplishing the same goals with a self modifying struct. I dunno; still trying to wrap my head around the best approach.
Thanks.