3 ms·
Also, your can't yet derive all of your views from state like you can in React or Elm because it doesn't expose all state to you. For example, <NavigationView>
by hombre_fatal 7y ago
Also, your can't yet derive all of your views from state like you can in React or Elm because it doesn't expose all state to you.
For example, <NavigationView> + <NavigationLink> doesn't update a History state object that you can control, push, or pop.
- dwaite 7y agoThe view layer is meant to be dependent either on application state you provide, or its own internal state if you don't provide any. So for the NavigationLink example, there is an isActive parameter which takes a Binding<Bool>. If you set that value as true, the navigation will be made active. Likewise, you can read whether the navigation link is active by reading the bound parameter. Instead of pushing navigations onto a history object stack, you return a view that represents the nested navigations based on state. Bindings like 'isActive' are discretionary because the NavigationLink can provide the appropriate (if non-persisted) state if your application logic doesn't care.
- ollysb 7y agoAs an Elm dev jumping into swift a couple of weeks ago I decided to just do the nav myself. I have an enum for Page and switch over that in the view. It seems far more obvious to use than the built in nav which doesn’t actually do an awful lot for you but takes away control(I did try the isActive approach but it seemed far more fiddly than using a Page enum).