Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06231663 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix bundle preview icon animation by fixing where we reverse.

Change I36e515164d4a6febad90f9dba26dce5795aecf05 attempted to fix this by adjusting the layout position of the icons, but that didn't account for the STL transitions of each icon element being static based on where the icon is relative to the expander. As a result, the icons had a strange staggering disappearance, different from the design.

Test: manual
Fixes: 424616749
Flag: com.android.systemui.notification_bundle_ui
Change-Id: Id8cdb1dce647767ce37a527134e6dfbeee010c17
parent 5d914b59
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.constrainHeight
import androidx.compose.ui.unit.constrainWidth
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEachReversed
import androidx.compose.ui.util.fastForEach
import androidx.compose.ui.util.fastMap
import androidx.compose.ui.util.fastMaxOfOrDefault
import androidx.compose.ui.util.fastSumBy
@@ -233,20 +233,25 @@ private fun ContentScope.BundlePreviewIcons(
                compositingStrategy = CompositingStrategy.Offscreen
            }
    ) {
        // We need to lay out icons from the end (icon1) to the start (icon3) so that we can define
        // STL animations statically per element, rather than making the movement of each element's
        // animation dynamic based on the number of visible siblings. This take/reversed does that,
        // while preserving the user's expected ordering of start-to-end == top-to-bottom contents.
        val reversedIcons = previewDrawables.take(3).reversed()
        PreviewIcon(
            drawable = previewDrawables[0],
            drawable = reversedIcons[0],
            modifier = Modifier.element(BundleHeader.Elements.PreviewIcon1).size(iconSize),
            borderWidth = borderWidth,
        )
        if (previewDrawables.size < 2) return@HalfOverlappingReversedRow
        if (reversedIcons.size < 2) return@HalfOverlappingReversedRow
        PreviewIcon(
            drawable = previewDrawables[1],
            drawable = reversedIcons[1],
            modifier = Modifier.element(BundleHeader.Elements.PreviewIcon2).size(iconSize),
            borderWidth = borderWidth,
        )
        if (previewDrawables.size < 3) return@HalfOverlappingReversedRow
        if (reversedIcons.size < 3) return@HalfOverlappingReversedRow
        PreviewIcon(
            drawable = previewDrawables[2],
            drawable = reversedIcons[2],
            modifier = Modifier.element(BundleHeader.Elements.PreviewIcon3).size(iconSize),
            borderWidth = borderWidth,
        )
@@ -304,7 +309,7 @@ private fun HalfOverlappingReversedRow(
        layout(constraints.constrainWidth(width), constraints.constrainHeight(childHeight)) {
            // Start in the middle of the right-most placeable
            var currentXPosition = placeables.fastSumBy { it.width / 2 }
            placeables.fastForEachReversed { placeable ->
            placeables.fastForEach { placeable ->
                currentXPosition -= placeable.width / 2
                placeable.placeRelative(x = currentXPosition, y = 0)
            }