https://kotlinlang.org logo
#compose
Title
# compose
v

Vivek Sharma

02/11/2021, 3:26 PM
I was using ModalBottomSheet like this:
Copy code
ModalBottomSheetLayout(
    sheetContent = {
        // sheet content
    }
) {
   // content of rest of the screen
}
So when I trigger
modalBottomSheetState.show()
, sheet gets visible and blocks screen behind it but the
back button is not closing the sheet
So I created composable and added it to navigation, but now sheet is
taking fullscreen, regardless of sheet content and modifier.height()
, so how can I achieve behaviour like bottom sheet blocking back screen and navigating back
d

Denis

02/11/2021, 3:35 PM
I don't know the right answer, but you probably can use https://github.com/airbnb/Showkase/blob/master/showkase/src/main/java/com/airbnb/android/showkase/ui/BackButtonHandler.kt and update
sheetState
on back button press
The first one works for me, I don't know if there are any differences between the two
v

Vivek Sharma

02/11/2021, 3:40 PM
I will try Backpress handler and tell
s

Se7eN

02/11/2021, 4:08 PM
Add a dependency for
androidx.activity:activity-compose:1.3.0-alpha02
to use the
BackHandler
Adam mentioned. https://developer.android.com/jetpack/androidx/releases/activity#1.3.0-alpha02
☝️ 1
v

Vivek Sharma

02/11/2021, 5:22 PM
Thanks, trying this
6 Views