UBottomSheet
UBottomSheet copied to clipboard
SwiftUI integration
Hi OfTheWolf,
This package looks great!
Is there any way to integrate it into an app with SwiftUI?
Maybe using UIViewControllerRepresentable?
I can't seem to find any package delivering the same functionality as this for SwiftUI
The problem with all the SwiftUI solutions is, that they cannot contain a scrollview and still be able to move the sheet when dragging.
@philipholler SwiftUI has a ".sheet" extension which works great. You don't need to rely on any 3rd party sheet lib in SwiftUI.
Please see the official doc: https://developer.apple.com/documentation/SwiftUI/AnyView/sheet(isPresented:onDismiss:content:)
Yes, the SwiftUI sheet works great in situations where you only need two state, that is cover the entire screen og dismissed. In case one needs 3 States, however, (for example like in apple maps), it is not usable. Additionally the SwiftUI sheet pushes back the rest of the views like a modal. This can also not be disabled
Ah ok. I will look into this thoroughly.
That sounds great. Please let me know, if there’s anything i can help with :-)
Hi! Any updates on that? Do you (@OfTheWolf @philipholler) know newer/current alternatives for SwiftUI? Thanks a lot in advance :)
Hi @thomasmo3 @philipholler,
I couldn't have a chance to look at this. I can recommend https://github.com/applidium/OverlayContainer for Swift UI support.
Thanks
If you want SwiftUI content inside of UBottomSheet with scrolling: I did that. So far it works fine.
The main trick is to use a a UIKit UIScrollView.
The UIScrollView contains a UIView that contains a UIHostingController that contains SwiftUI.
This way, UBottomSheet has its UIScrollView to work with and does not know that it handles SwiftUI content. The SwiftUI code must not come with a ScrollView or anything else that scrolls.
There are still good reasons to use UBottomSheet. My main reason is that both UISheetPresentationController and SwiftUI .sheet do not work together with UITabBarController