ericlewis / PageSheet

Customizable sheets using UISheetPresentationController in SwiftUI
MIT License
55 stars 7 forks source link

Selected Detent using Binding #23

Closed mlengert closed 1 year ago

mlengert commented 1 year ago

Hi, at first, thanks for this amazing library. It seems to be the best backward compatible SwiftUI implementation :)

I saw that your code internally uses @Binding for the selected detent. Is there a way to bind a value outside of your implementation to get informed if the user changes the selected detent by dragging. Additionally, if I change the selected detent programmatically, it looks like the selected bottom sheet detent didn't change at all.

For that it would be amazing if you could implement a solution similar to the native apple interface where the selected detent is a Binding object.

ericlewis commented 1 year ago

@mlengert the environment variable should do that as mentioned in the docs. the second issue could be due to changes they made in their official verison. PRs are welcome.

mlengert commented 1 year ago

@ericlewis thanks. The documentation is not really precise at this point. It is primarily a reference to the iOS documentation without mentioning any available env-key.  However, I was able to make it work with the Environment(\.selectedDetentIdentifier) variable and a custom modifier. With that, I was also able to fix my problem where the programmatically changed detent not works.

On my side, everything is fine now, and this issue can be closed :)

I already checked out your latest changes, which include namespaces. This commit fixed so many visual bugs. Big thanks.