composablehorizons / compose-unstyled

Unstyled, fully accessible Compose Multiplatform UI components that you can customize to your heart's content.
https://composeunstyled.com
MIT License
344 stars 11 forks source link

BottomSheet: Click on DragIndication crash with single detent BottomSheetState #21

Closed Nath-IS closed 2 weeks ago

Nath-IS commented 4 weeks ago

Description: Click on DragIndication crash when the BottomSheetState has only one detent set.

Steps to Reproduce:

  1. Initialize a BottomSheet with the following state:
val PartiallyExpanded = remember {
    SheetDetent(identifier = "part") { containerHeight, sheetHeight ->
        containerHeight * 0.5f
    }
}

val sheetState = rememberBottomSheetState(
    initialDetent = PartiallyExpanded,
    detents = listOf(partiallyExpanded),
)
  1. Add a DragIndication to the BottomSheet content as follows:
BottomSheet(state = sheetState) {
    Column(horizontalAlignment = Alignment.CenterHorizontally) {
        DragIndication(modifier = Modifier
             .padding(top = 22.dp)
             .background(Color.Black.copy(0.4f), RoundedCornerShape(100))
             .width(32.dp)
             .height(4.dp),
         )

        ...
    }
}
  1. Click on the DragIndication

Expected Behavior:

Nothing is supposed to append, because no other detent is available.

Actual Behavior:

I know that in theory the DragIndication is not necessary for a BottomSheet with only one detent, because it can't be moved with a swipe, but in practice it's possible. Is it possible to handle this case in the onIndicationClicked function?

alexstyl commented 2 weeks ago

Fixed. It will be available in the next version. I will post here when it is available

alexstyl commented 2 weeks ago

Now available in https://github.com/composablehorizons/composables-core/releases/tag/1.13.0