Let's start a thread on my best finding in #SwiftUI for iOS 16 exclusively, as I've used it to write #IceCubesApp
The 1.0 about to get released on the App Store (well if Apple finally decide so) so this is a good time for that thread.
1. .toolbar is more powerful than ever. You can use ToolbarTitleMenu to have a complexe menu right in the title of navigation bar. Don't forget you can also use .toolbar with keyboard placement on TextField for keyboard accessory view.
2. .presentationDetents is finally available in #SwiftUI for presenting sheet. You can use medium, large, a fraction of the height of the screen and a totally custom size.
3. New Environment values like .dismiss make it super easy to manage modal. And it's finally seems reliable.
4. One of the biggest iOS 16 news is NavigationStack, Ice Cubes app navigation is super simple. You can reference RouterPath from anywhere, and use the programatic .navigate(to:) API or use a RouteDestinations value for NavigationLink.
5. PhotoPicker is amazing and simple to use. Allow you to easily present the photo library UI and keep track of the selected images to load them into your app.
6. .searchable API is even more powerful now that you can easily use tokens, suggest tokens, decide of the search bar placement etc... I try to use the full extent of it in the app but I could do better.
7. I don't use it in the app yet, but you can now use TextField with a .vertical axis. This is very good for multiline text field. But it's not UITextView yet. And I wish there would be a SwiftUI input field that support AttributedString, for now I have to wrap a UITextView.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
So, how do you make this cool transition in pure #SwiftUI with a basic zoom navigation transition, using sheet presentation and a well-architectured router? I'm glad you asked! 🧵
This is the view I have in my post row below the text content. Notice that the tap gesture uses the router from the environment and passes the current namespace and sets the presented sheet to our full-screen media view. The other important thing is the matchedTransitionSource.
The router is pretty simple, I use it for per tab navigation and also at the root of the app to present various sheet, for now I only have a couple.