Skip to content

Commit

Permalink
Replace onSizeChanged with layout
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo committed Jan 16, 2024
1 parent 1323d48 commit b9a1e1a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,22 @@ fun ListDetail(
val minDetailPaneWidth = 300.dp

Box(
modifier = modifier.onSizeChanged {
modifier = modifier.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)

anchoredDraggableState.updateAnchors(
newAnchors = DraggableAnchors {
ExpandablePaneState.ListOnly at it.width.toFloat()
ExpandablePaneState.ListAndDetail at it.width.toFloat() / 2f
ExpandablePaneState.ListOnly at placeable.width.toFloat()
ExpandablePaneState.ListAndDetail at placeable.width.toFloat() / 2f
ExpandablePaneState.DetailOnly at 0f
},
// Keep the current target, even if resizing causes the offset to be closer to a different one
newTarget = anchoredDraggableState.targetValue
)

layout(placeable.width, placeable.height) {
placeable.placeRelative(0, 0)
}
}
) {
if (showList && showDetail) {
Expand Down

0 comments on commit b9a1e1a

Please sign in to comment.