Hi there. I am getting a wrong progress from `Bott...
# compose
s
Hi there. I am getting a wrong progress from
BottomSheetState
when used in
BottomSheetScaffold
and decreasing the
sheetPeekHeight
. Example code in comment
I have a
BottomSheetScaffold
where I set the peek height with a slider. I noticed that when the peek height decreases, the
BottomSheetState.progress
has wrong values
Copy code
fun Greeting() {
    var sliderValue by remember { mutableStateOf(0f) }
    val bottomSheetState = rememberBottomSheetScaffoldState()

    val sheetPeekHeight = 70.dp * (1 - sliderValue)

    bottomSheetState.bottomSheetState.progress.let {
        Log.e("Simon", "from: ${it.from} to: ${<http://it.to|it.to>} val: ${it.fraction}")
    }


    BottomSheetScaffold(
        sheetContent = {
            Text(
                modifier = Modifier.height(300.dp).padding(10.dp),
                text = "Sheet content"
            )
        },
        scaffoldState = bottomSheetState,
        sheetPeekHeight = sheetPeekHeight,
        sheetShape = RoundedCornerShape(
            topStart = 20.dp,
            topEnd = 20.dp
        ),
        sheetBackgroundColor = Color.LightGray
    ) {
        Slider(value = sliderValue, onValueChange = { sliderValue = it })
    }
}
when I move the slider to the right, to decrease the peek height, I get log outputs like this one
Copy code
from: Collapsed to: Expanded val: 0.0010182378
even though
from
and
to
should be the same at this point and the
fraction
should be
0f
I assumed a rounding issue, but it looks like there might be a race condition or timing issue of when
offset
and
fraction
are changed
I think
Swipeable.findBounds()
is being called at a moment when
anchors
and
offest
are out of sync?
Question is if I am doing something wrong on my side or if this is a bug?
j
Swipeable has some synchronization issues so this sounds like it could be a bug. CC @matvei
c
I think I filed a bug about progress and bottom sheets being wrong in accompanist. on mobile right now but if you search my name on accompanist issue tracker you can see if its the same.
s
@Colton Idle in accompanist? Not sure how this is related. This issue seems to be in
SwipeProgress
in compose itself.
anyhow, i did look up your name in the accompanist issues and didn't find you. maybe i'm looking at the wrong place? https://github.com/google/accompanist/issues
s
Thanks. Looks like the author autocomplete does not work with your name 🙂
I don't think any of your issues are the same as what i am experiencing. I think i'll go ahead and file a compose bug for it
1
c
Sorry!
s
no worries 🙂
j
Thanks for filing🙏