Skip to content

Instantly share code, notes, and snippets.

@EfeBudak
Created August 7, 2024 19:28
Show Gist options
  • Save EfeBudak/707f987c44b29f6b57ce08e49fb753f7 to your computer and use it in GitHub Desktop.
Save EfeBudak/707f987c44b29f6b57ce08e49fb753f7 to your computer and use it in GitHub Desktop.
Collect current offset of the bottom sheet
fun SomeComposable(){
val bottomSheetState = rememberStandardBottomSheetState()
val scaffoldState = rememberBottomSheetScaffoldState(bottomSheetState)
var currentOffset by remember { mutableFloatStateOf(0f) }
runCatching {
LaunchedEffect(bottomSheetState.requireOffset()) {
snapshotFlow { bottomSheetState.requireOffset() }
.collect { currentOffset = it }
}
}
// Here comes the BottomSheetScaffold
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment