Don't dismiss bottom sheets when anchors change
This commit is contained in:
parent
09e76d3c28
commit
a544b85b67
@ -222,14 +222,22 @@ fun BottomSheetDialog(
|
|||||||
oldValue == SwipeState.Full && hasPeekAnchor -> SwipeState.Peek
|
oldValue == SwipeState.Full && hasPeekAnchor -> SwipeState.Peek
|
||||||
else -> SwipeState.Dismiss
|
else -> SwipeState.Dismiss
|
||||||
}
|
}
|
||||||
|
val newAnchors = DraggableAnchors {
|
||||||
|
SwipeState.Dismiss at 0f
|
||||||
|
if (hasPeekAnchor) SwipeState.Peek at -min(
|
||||||
|
maxHeightPx * 0.5f,
|
||||||
|
sheetHeight
|
||||||
|
)
|
||||||
|
if (hasFullAnchor) SwipeState.Full at -min(maxHeightPx, sheetHeight)
|
||||||
|
}
|
||||||
draggableState.updateAnchors(
|
draggableState.updateAnchors(
|
||||||
DraggableAnchors {
|
newAnchors,
|
||||||
SwipeState.Dismiss at 0f
|
with(draggableState) {
|
||||||
if (hasPeekAnchor) SwipeState.Peek at -min(
|
(if (!offset.isNaN()) {
|
||||||
maxHeightPx * 0.5f,
|
newAnchors.closestAnchor(offset) ?: targetValue
|
||||||
sheetHeight
|
} else targetValue).let {
|
||||||
)
|
if (it == SwipeState.Dismiss && targetValue != SwipeState.Dismiss && hasPeekAnchor) SwipeState.Peek else it
|
||||||
if (hasFullAnchor) SwipeState.Full at -min(maxHeightPx, sheetHeight)
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (newValue != oldValue) {
|
if (newValue != oldValue) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user