[a11y] Add click action to the message bottom sheet handle (#5228)

This commit is contained in:
Jorge Martin Espinosa 2025-09-01 15:27:40 +02:00 committed by GitHub
parent f0ba59d84e
commit 66eb876b2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 4 deletions

View file

@ -60,7 +60,7 @@ import kotlin.math.roundToInt
@Composable
fun ExpandableBottomSheetLayout(
sheetDragHandle: @Composable BoxScope.() -> Unit,
sheetDragHandle: @Composable BoxScope.(toggleAction: () -> Unit) -> Unit,
bottomSheetContent: @Composable ColumnScope.() -> Unit,
state: ExpandableBottomSheetLayoutState,
maxBottomSheetContentHeight: Dp,
@ -152,7 +152,19 @@ fun ExpandableBottomSheetLayout(
}
) {
Box(Modifier.fillMaxWidth()) {
sheetDragHandle()
sheetDragHandle {
coroutineScope.launch {
val destination = if (state.position == ExpandableBottomSheetLayoutState.Position.EXPANDED) {
state.internalPosition = ExpandableBottomSheetLayoutState.Position.COLLAPSED
minBottomContentHeightPx.toFloat()
} else {
state.internalPosition = ExpandableBottomSheetLayoutState.Position.EXPANDED
calculatedMaxBottomContentHeightPx.toFloat()
}
animatable.snapTo(currentBottomContentHeightPx.toFloat())
animatable.animateTo(destination)
}
}
}
bottomSheetContent()
}

View file

@ -38,7 +38,7 @@ class ExpandableBottomSheetLayoutState {
/**
* The current position of the bottom sheet layout.
*/
val position = internalPosition
val position get() = internalPosition
/**
* The percentage of the bottom sheet layout that is currently being dragged.