Save a LaunchedEffect in rememberBottomSheetState
This commit is contained in:
@@ -186,15 +186,11 @@ fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp): BottomSheetState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(animatable.value == upperBound) {
|
|
||||||
wasExpanded = animatable.value == upperBound
|
|
||||||
}
|
|
||||||
|
|
||||||
return remember(animatable, coroutineScope) {
|
return remember(animatable, coroutineScope) {
|
||||||
BottomSheetState(
|
BottomSheetState(
|
||||||
draggableState = DraggableState { delta ->
|
draggableState = DraggableState { delta ->
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
animatable.snapTo(animatable.value - density.run { delta.toDp() })
|
animatable.snapTo(animatable.value - with(density) { delta.toDp() })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
valueState = animatable.asState(),
|
valueState = animatable.asState(),
|
||||||
@@ -213,11 +209,13 @@ fun rememberBottomSheetState(lowerBound: Dp, upperBound: Dp): BottomSheetState {
|
|||||||
1f - (upperBound - animatable.value) / (upperBound - lowerBound)
|
1f - (upperBound - animatable.value) / (upperBound - lowerBound)
|
||||||
},
|
},
|
||||||
collapse = {
|
collapse = {
|
||||||
|
wasExpanded = false
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
animatable.animateTo(animatable.lowerBound!!)
|
animatable.animateTo(animatable.lowerBound!!)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
expand = {
|
expand = {
|
||||||
|
wasExpanded = true
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
animatable.animateTo(animatable.upperBound!!)
|
animatable.animateTo(animatable.upperBound!!)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user