There's a specific SwiftUI type ContentTransition link which seems designed for this use case.
However:
The current library doesn't seem to have a way to ensure that the transition used will depend on how a property changes.
The currently library doesn't seem to provide for any custom creation of a ContentTransition (although the stock ones are really cool).
There's also a SwiftUI type PlaceholderContentView link which looks like it might be used to implement SwiftUI features such as transitions, so it could perhaps be used to implement the replacingWithTransitionOnChanges function I suggested above – however, it doesn't seem to be publicly accessible as far as I can tell.
A possible approach – I think it could be possible to nest several views inside each other with each of the views having a specific transition. Playing with id would then let a given view be replaced, which should trigger only its transition (because transitions only happen on the outermost view that is added or removed – as far as I know). This might work, but it isn't very extensible, at all reusable, or clear at the point of use what's going on.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: