I have regrettably little time to devote to SwiftUI. I explore when I can, although I wish I were a lot further in that journey.
Here’s my latest go, where I’m looking to build a modal presentation. Today is the first time I’ve been able to play with Modal
, the storage type for a modal presentation. I tied it together with an isPresented
state, but I’m wondering if I’ve done this all wrong.
I can’t help but think there’s a better way to do this. I’m using a text button for “Done” instead of a system-supplied item, so it won’t be automatically internationalized. Nor, can I find any specialty “Done” item in SFSymbols. When looking at Apple’s samples, such as Working with UI Controls, I see the same Text("Done")
. While I know that Text
elements are automatically localized should resources be available, is SwiftUI providing us with any core dictionary of terms?
I think using the isPresented
state in the code below may be too clunky. I’d think that there would be a more direct way to coordinate a modal item. Any advice and guidance will be greatly welcomed.
I remain stuck in Mojave for most of my work, although I put an install of Catalina on a laptop. Although you can build proper SwiftUI apps using the beta Xcode, without the preview (and I’ve had no luck finding a secret default to enable it under Mojave) makes the experience way slower than working in a playground.
I’m hoping to dive next into Interfacing with UIKit.
One Comment
I suspect they are just missing a BarButton type that exposes what UIKit already offers. Fingers crossed.
As an aside, to get to the new presentationControllerDidAttemptToDismiss() delegate callbacks for a Modal, which allows you to ‘interrupt’ the user trying to dismiss your modal, I used a UIHostingController to show my SwiftUI view and a BindableObject in which I bound to via .sink on the UIKit side to dismiss it.