SwiftUI Essentials
Prefer smaller, single-purpose views
Put conditions inside modifiers when possible (flipped ? 180 : 0
) – returning separate objects in if/else may create a separate hierarchy where SwiftUI needs to add/remove views when switching, and then by default it uses a fade animation to switch between those
It’s really easy to break your code into smaller pieces and refactor it, so do it often
All controls have adaptive behavior – they describe the role they serve, instead of how they look, and the framework adapts the look to the environment
Same Button()
can be a navigation item button, an unstyled iOS button, a macOS push button, or even a context menu item (!)
Modifiers like .disabled()
can be applied even to whole screens