In old way, I can use slideOffset in BottomSheetBehavior.BottomSheetCallback
. But now in Jetpack compose, I can't use slideOffset. How to get it?
Asked
Active
Viewed 374 times
2

boybeak
- 417
- 5
- 19
-
Check out [this answer](https://stackoverflow.com/a/69052933/3585796) on how you can track state changes in compose, in case of `BottomSheetScaffold` you're probably looking for `scaffoldState.bottomSheetState.currentValue` – Phil Dukhov May 18 '22 at 03:18
-
This may not working. `scaffoldState.bottomSheetState.currentValue` is enum value, *Collapsed* or *Expanded*. What I want to use is the slide offset value, from 0.0 to 1.0. – boybeak May 19 '22 at 09:36
-
I found the `bottomSheetScaffoldState.bottomSheetState.offset` variable, but I don't know how to use it. I tried `LaunchedEffect(bottomSheetScaffoldState.bottomSheetState.offset.value)`, only called once, and the bottom content can not slide. – boybeak May 19 '22 at 10:21
-
Yes, you're right, I meant `scaffoldState.bottomSheetState.currentValue`, but to me it works fine to me with [this code](https://gist.github.com/PhilipDukhov/6ff432f49a5876ad3f7f13bee47c4295). Show how you're trying to use it. Also I've updated [my answer](https://stackoverflow.com/questions/69052660/listen-modalbottomsheetlayout-state-change-in-jetpack-compose/69052933#69052933) with a more performant version which uses `snapshotFlow`, check it out too – Phil Dukhov May 19 '22 at 10:51
-
Thanks bro. Finally I found a post [here](https://stackoverflow.com/questions/69529798/how-to-expand-bottomsheetscaffold-to-a-specific-height-at-with-jetpack-compose). Also I will try your code later. – boybeak May 19 '22 at 11:20