adamfootdev / BottomSheet

Access UISheetPresentationController in SwiftUI on iOS 15 using a simple .bottomSheet modifier.
MIT License
346 stars 40 forks source link

Feature request: Set preferredContentSize #2

Open benubois opened 3 years ago

benubois commented 3 years ago

Hi, thanks for making this!

I was watching the WWDC sheets session and at around the 9:15 mark, Russell mentions that the sheet should respect a preferredContentSize if widthFollowsPreferredContentSizeWhenEdgeAttached = true.

I was wondering if it would be possible to automatically set preferredContentSize in this component to something like view.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) so that the sheet only takes up the width of the contentView?

Or alternatively provide a way to set a preferredContentSize?

I failed to get this to work, but I was hoping you would know how to do it.

Here's the example from the session:

Before:

large

After:

small

adamfootdev commented 3 years ago

Thanks for the suggestion. After spending some time looking into it, SwiftUI doesn't appear to work very well with preferredContentSize and have seen others file feedback for similar issues. I'll keep looking into it to see if I can find a solution.