Bottom sheets: add back key handler

This commit is contained in:
MM20
2023-10-12 20:35:58 +02:00
parent 3516597d10
commit 903c161500
@@ -1,5 +1,6 @@
package de.mm20.launcher2.ui.component
import androidx.activity.compose.BackHandler
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.background
@@ -99,6 +100,15 @@ fun BottomSheetDialog(
)
}
BackHandler {
if (dismissible()) {
scope.launch {
draggableState.animateTo(SwipeState.Dismiss)
onDismissRequest()
}
}
}
LaunchedEffect(draggableState.currentValue) {
if (isOpenAnimationFinished && draggableState.currentValue == SwipeState.Dismiss) {
onDismissRequest()