rubensousa / BottomSheetBuilder

A simple library that creates BottomSheets according to the Material Design specs
Apache License 2.0
559 stars 98 forks source link

Enable background dim while using a Builder with a coordinatorlayout? #24

Open SammyO opened 6 years ago

SammyO commented 6 years ago

I want to be a able to control the visibility of my BottomSheetDialog, so I'm using the builder with a coordinatorlayout provided. It seems however, that with that setup I can't enable background-dim? Could you suggest any workaround for this? Thank you in advance!

rubensousa commented 6 years ago

My suggestion would be placing a View with the background you want and then hide/show it according to the bottom sheet's visibility. If you pass a CoordinatorLayout, there's no BottomSheetDialog, but a plain View.

SammyO commented 6 years ago

The main thing I want to achieve is have a BottomSheetDialog that I initialise once, and after that show() and dismiss() accordingly. This I can do fine with using a BottomSheetDialog. However, once I've dismissed it and show it again, the click is ignored in onBottomSheetItemClick, because mClicked is true (and is not set to false again after dismissing the dialog).

rubensousa commented 6 years ago

Ah, so you're reusing the same instance? I usually don't do this, so I didn't even think about it. I'll mark this as a bug and will fix it once I have time. Meanwhile, please create a new instance of a BottomSheetDialog every time you need one.

SammyO commented 6 years ago

Yes, I'd like to use the same instance. Using Kotlin I'd like to do:

private val bottomSheet: BottomSheetMenuDialog by lazy {
        // Create dialog
    }

Thanks for your help!