[a11y] Add click action to the message bottom sheet handle (#5228)
This commit is contained in:
parent
f0ba59d84e
commit
66eb876b2d
3 changed files with 38 additions and 4 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue