Prevent customize sheet to be dismissed by swipe when icon picker is open

This commit is contained in:
MM20 2022-07-31 15:11:01 +02:00
parent d5aa0667ad
commit b9e65f3c9f
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 6 additions and 1 deletions

View File

@ -36,13 +36,17 @@ fun BottomSheetDialog(
actions: @Composable RowScope.() -> Unit = {},
confirmButton: @Composable (() -> Unit)? = null,
dismissButton: @Composable (() -> Unit)? = null,
swipeToDismiss: () -> Boolean = { true },
content: @Composable () -> Unit,
) {
val swipeState = remember {
SwipeableState(
initialValue = SwipeState.Dismiss,
confirmStateChange = {
if (it == SwipeState.Dismiss) onDismissRequest()
if (it == SwipeState.Dismiss) {
if (swipeToDismiss()) onDismissRequest()
else return@SwipeableState false
}
return@SwipeableState true
}
)

View File

@ -47,6 +47,7 @@ fun CustomizeSearchableSheet(
title = {
Text(stringResource(if (pickIcon) R.string.icon_picker_title else R.string.menu_customize))
},
swipeToDismiss = { !pickIcon },
confirmButton = {
if (pickIcon) {
OutlinedButton(onClick = { viewModel.closeIconPicker() }) {