Hide bottom sheet on back press

This commit is contained in:
Suphon Thanakornpakapong
2022-01-11 20:17:21 +07:00
parent 87c906223f
commit 4874f83a7f
@@ -16,6 +16,7 @@
package app.lawnchair.ui.preferences
import androidx.activity.compose.BackHandler
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
@@ -86,7 +87,13 @@ fun Preferences(interactor: PreferenceInteractor = viewModel<PreferenceViewModel
SystemUi()
Providers(bottomSheetHandler = bottomSheetHandler) {
ModalBottomSheetLayout(
sheetContent = { bottomSheetContent.content() },
sheetContent = {
val isSheetShown = bottomSheetState.isAnimationRunning || bottomSheetState.isVisible
BackHandler(enabled = isSheetShown) {
bottomSheetHandler.hide()
}
bottomSheetContent.content()
},
sheetState = bottomSheetState
) {
Surface {