google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.43k stars 598 forks source link

[Navigation Material] BottomSheetState progress not updated as it should be #1586

Closed AnthonyFillionMaillet closed 1 year ago

AnthonyFillionMaillet commented 1 year ago

Description

After updating accompanist from 0.28.0 to 0.30.1 I couldn't use progress.fraction anymore from the SwipeProgress object in the bottom sheet state so I now use progress directly from the new bottom sheet state.

I noticed there is an issue with the update of this value and I wonder if this is intended behavior.

When I scroll in a BottomSheetScaffold, on the first pixels (around 50px) the value of progress is not updated right away. The same issue happens when the sheet is fully expanded and I swipe to collapse, progress value is not updated in the first pixels. You can check the videos down below for more context.

Before (0.28.0) After (0.30.1)
https://user-images.githubusercontent.com/9885223/233347676-8c4e606e-e670-4f5d-8417-1079b8e10608.mp4 https://user-images.githubusercontent.com/9885223/233347757-b472a6d9-2b88-463b-a366-881b5c33f9ce.mp4

Steps to reproduce

@Composable
fun BottomSheet() {
    val scaffoldState = rememberBottomSheetScaffoldState(
        bottomSheetState = rememberBottomSheetState(
            initialValue = BottomSheetValue.Collapsed
        )
    )

    BottomSheetScaffold(
        sheetContent = {
            Content(scaffoldState.bottomSheetState)
        },
        scaffoldState = scaffoldState,
    ) { padding ->
        Box(
            modifier = Modifier
                .background(Color.Yellow)
                .fillMaxSize()
        ) {
            Text(
                modifier = Modifier
                    .align(Alignment.Center)
                    .padding(padding),
                color = Color.Blue,
                text = scaffoldState.bottomSheetState.progress.toString()
            )
        }
    }
}
@Composable
private fun Content(
    bottomSheetState: BottomSheetState,
) {
    println("updateProgress ${bottomSheetState.progress}")

    Column(
        modifier = Modifier
            .background(Color.Red)
            .fillMaxSize()
    ) {}
}

Expected behavior

The progress value should be updated as soon as the the bottom sheet is moving.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

AnthonyFillionMaillet commented 1 year ago

Any updates on this?