Move long press menu drag handle to its own composable

This commit is contained in:
Stypox 2025-02-11 16:09:03 +01:00
parent 719f8a5f28
commit 4581f20885
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -115,31 +115,7 @@ fun LongPressMenu(
ModalBottomSheet(
onDismissRequest,
sheetState = sheetState,
dragHandle = {
Box(
modifier = Modifier.fillMaxWidth()
) {
BottomSheetDefaults.DragHandle(
modifier = Modifier.align(Alignment.Center)
)
IconButton(
onClick = onEditActions,
modifier = Modifier.align(Alignment.CenterEnd)
) {
// show a small button here, it's not an important button and it shouldn't
// capture the user attention
Icon(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.edit),
// same color and height as the DragHandle
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier
.padding(2.dp)
.size(16.dp),
)
}
}
},
dragHandle = { LongPressMenuDragHandle(onEditActions) },
) {
BoxWithConstraints(
modifier = Modifier
@ -202,6 +178,34 @@ fun LongPressMenu(
}
}
@Preview
@Composable
fun LongPressMenuDragHandle(onEditActions: () -> Unit = {}) {
Box(
modifier = Modifier.fillMaxWidth()
) {
BottomSheetDefaults.DragHandle(
modifier = Modifier.align(Alignment.Center)
)
IconButton(
onClick = onEditActions,
modifier = Modifier.align(Alignment.CenterEnd)
) {
// show a small button here, it's not an important button and it shouldn't
// capture the user attention
Icon(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.edit),
// same color and height as the DragHandle
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier
.padding(2.dp)
.size(16.dp),
)
}
}
}
@Composable
fun LongPressMenuHeader(
item: LongPressable,