Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI integration #62

Open
philipholler opened this issue May 16, 2021 · 8 comments
Open

SwiftUI integration #62

philipholler opened this issue May 16, 2021 · 8 comments

Comments

@philipholler
Copy link

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

@philipholler
Copy link
Author

The problem with all the SwiftUI solutions is, that they cannot contain a scrollview and still be able to move the sheet when dragging.

@OfTheWolf
Copy link
Owner

@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:)

@philipholler
Copy link
Author

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

@OfTheWolf
Copy link
Owner

Ah ok. I will look into this thoroughly.

@philipholler
Copy link
Author

That sounds great. Please let me know, if there’s anything i can help with :-)

@tomsun3
Copy link

tomsun3 commented Nov 15, 2021

Hi! Any updates on that? Do you (@OfTheWolf @philipholler) know newer/current alternatives for SwiftUI? Thanks a lot in advance :)

@OfTheWolf
Copy link
Owner

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

@GerdC
Copy link

GerdC commented Feb 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants