maxkeppeler / sheets

⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.
https://maxkeppeler.github.io/sheets/
Apache License 2.0
921 stars 77 forks source link

Make it impossible to open duplicate sheets #88

Closed GraxCode closed 3 years ago

GraxCode commented 3 years ago

When a button / view that opens a sheet is clicked two times very fast after each other, two sheets are opened. This can lead to NPEs in my application after interacting with them. Is there a way to integrate that when a sheet is opened, clicking is blocked instantly rather than after the sheet view is instantiated and open? This could make things much easier.

maxkeppeler commented 3 years ago

Just declare a global property for the sheet and check if it's already visible. If it's already visible, don't show it, otherwise show it. (Or do the same with a nullable property.) There are quite some threads about this topic online. The library isn't misbehaving at this point. It just creates a new instance every time you build or show a sheet. Making sure it's always the same instance and checking its state seems like the way to go then. (I try to check your other issue and the other issues in total this weekend when I find some free time.)