diff options
| author | 2025-02-26 04:50:18 -0800 | |
|---|---|---|
| committer | 2025-02-26 04:50:18 -0800 | |
| commit | 50777ff2d847fd8c74e52c74ef12bdee63c86cb0 (patch) | |
| tree | 81b3c1ddf0c30400085f16186e94bc8d482121a9 | |
| parent | a952ec62b430025df068c6e917e04c7453fbd97a (diff) | |
| parent | b7efb5558dc9e56c3572fbb8bcd045c688430fee (diff) | |
Merge "Always draw new Expandables in a graphics layer" into main
| -rw-r--r-- | packages/SystemUI/compose/core/src/com/android/compose/animation/Expandable.kt | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/animation/Expandable.kt b/packages/SystemUI/compose/core/src/com/android/compose/animation/Expandable.kt index 1e3c4c9e7c09..02eceeeda89e 100644 --- a/packages/SystemUI/compose/core/src/com/android/compose/animation/Expandable.kt +++ b/packages/SystemUI/compose/core/src/com/android/compose/animation/Expandable.kt @@ -308,34 +308,28 @@ private fun Modifier.expandable( interactionSource: MutableInteractionSource? = null, ): Modifier { val controller = controller as ExpandableControllerImpl + val graphicsLayer = rememberGraphicsLayer() val isAnimating = controller.isAnimating - val drawInOverlayModifier = - if (isAnimating) { - val graphicsLayer = rememberGraphicsLayer() - - FullScreenComposeViewInOverlay(controller.overlay) { view -> - Modifier.then(DrawExpandableInOverlayElement(view, controller, graphicsLayer)) - } - - Modifier.drawWithContent { graphicsLayer.record { this@drawWithContent.drawContent() } } - } else { - null + if (isAnimating) { + FullScreenComposeViewInOverlay(controller.overlay) { view -> + Modifier.then(DrawExpandableInOverlayElement(view, controller, graphicsLayer)) } + } + val drawContent = !isAnimating && !controller.isDialogShowing return this.thenIf(onClick != null) { Modifier.minimumInteractiveComponentSize() } - .thenIf(!isAnimating) { + .thenIf(drawContent) { Modifier.border(controller) .then(clickModifier(controller, onClick, interactionSource)) .background(controller.color, controller.shape) } - .thenIf(drawInOverlayModifier != null) { drawInOverlayModifier!! } .onPlaced { controller.boundsInComposeViewRoot = it.boundsInRoot() } - .thenIf(!isAnimating && controller.isDialogShowing) { - Modifier.layout { measurable, constraints -> - measurable.measure(constraints).run { - layout(width, height) { /* Do not place/draw. */ } - } + .drawWithContent { + graphicsLayer.record { this@drawWithContent.drawContent() } + + if (drawContent) { + drawLayer(graphicsLayer) } } } |