Some interesting stuff in SwiftUI with macOS 13 and iOS 16:
- NavigationView is dead. Long live NavigationStack.
- On this topic, it looks a bit like NavigationStack might actually provide a navigation stack for macOS outside of catalyst? Need to play with it once I can install the beta.
- NavigationPath makes it easier to serialize navigation state to do things like handle iPhone/iPad size class switching, handoff, and more. Heck, the entire navigation model is a lot more sensible, and you can create a navigation router for a stack that is surprisingly VIPER like. Still needs to be embedded in a view, but you could easily create a view modifier or wrapping view that defines your routes and compartmentalize that way. Overall, navigation looks so much better now than it did last year. Sidebars might be less jank under this approach.
- Context menus can provide preview views now, just to get back to my opening post in this thread.
- Sheets now support detents, finally. Can even specify custom detents.
- Custom grid layouts will make a couple things I’ve banged my head against easier (trying to multiple VStacks properly).
- ViewThatFits to pick between different layouts based on what fits the space available. Useful for portrait vs landscape on iPad, and possibly iPhone vs iPad/Mac/AppleTV.
- A full layout engine you can seemingly take control over that is declarative.
- You can now specify background tasks without dropping to UIKit, so background refresh, network tasks and the like can be done fully in SwiftUI.
- Custom windows can now be created for specific needs, such as supplementary windows (say a diagnostics tool, or a mini player window, camera window, etc).
- There’s some new ways to declare toolbars that looks like it feeds the new iPad toolbars, but should also help with Mac toolbars.
- PhotosPicker is now available without dropping to UIKit (just after I wrote a wrapper…). Somehow it seems like this is supported on macOS 13 too? Huh?
- Some Apple Pay and Wallet integration
- Menus can now have their order defined by the developer, no more being stuck with “first closest to button” ordering when UIKit doesn’t do this.
- Rename action/button. huh.
- A couple new gesture modifiers that give you access to the gesture location, including “continuous hover”.
- ImageRenderer, a way to generate images from SwiftUI views.
And as an aside, the new AppIntents framework looks a lot like they have been watching the SwiftUI team. A declarative intents API that doesn’t rely on those external model files. Seeing @resultsBuilder trickle out into other APIs as well.