maxkeppeler / sheets-compose-dialogs

✨ Enhancing Android UIs: A Jetpack Compose Library supporting a wide range of common use-cases with Material Design 3 Dialogs, Popups, and Bottom Sheets. ✨
https://maxkeppeler.github.io/sheets-compose-dialogs/
Apache License 2.0
780 stars 32 forks source link

[Feature] Add a declarative api #77

Closed Nek-12 closed 6 months ago

Nek-12 commented 6 months ago

Right now the api is imperative - the dialog forces the user to create and remember a useCaseState, which complicates management of the dialog visibility, forcing us to use one-time events. A declarative api (like a "visible") parameter of a dialog would fit Compose better, allow greater flexibility, prevent state management issues, and simplify the usage of the library.

maxkeppeler commented 6 months ago

UseCastState could continue to exist as an internal abstract remembered state, and the parameter visible could be extracted from it. This would replace useCaseState with visible for dialogs, views, etc. However, I don't see this change being worth the effort and time.

Nek-12 commented 6 months ago

I understand the decision. We are not against creating declarative wrappers for our dialogs, however the parameter visible in the dialog is remembered and not used as a key, which means it will not react to property change, forcing us to use the LaunchedEffect of sorts to manage it. Would it be possible to add the visible parameter as a key to the useCaseState then to make it react to changes ?