Skip to content

Instantly share code, notes, and snippets.

@egorikftp
Created August 8, 2021 20:14
Show Gist options
  • Save egorikftp/898ef570175a3b80bfb8f88631fb82a2 to your computer and use it in GitHub Desktop.
Save egorikftp/898ef570175a3b80bfb8f88631fb82a2 to your computer and use it in GitHub Desktop.
@OptIn(ExperimentalMaterialApi::class)
val BottomSheetScaffoldState.currentFraction: Float
get() {
val fraction = bottomSheetState.progress.fraction
val targetValue = bottomSheetState.targetValue
val currentValue = bottomSheetState.currentValue
return when {
currentValue == Collapsed && targetValue == Collapsed -> 0f
currentValue == Expanded && targetValue == Expanded -> 1f
currentValue == Collapsed && targetValue == Expanded -> fraction
else -> 1f - fraction
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment