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

Commit 723b8911 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Apply size limit and measurement logic to navpill

NavPill should have at most 247dp, and attribution should be at most 37%
the size of the container.

Test: visual
Test: atest NavBarPillScreenshotTest
Bug: 407662106
Flag: com.android.systemui.enable_underlay
Change-Id: I00ddecf597b87977aee324fdc01bb7a76f8de281
parent 6656eb4c
Loading
Loading
Loading
Loading
+38 −22
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.IconButtonColors
@@ -48,6 +48,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
@@ -114,7 +115,7 @@ fun NavBarPill(
                verticalAlignment = Alignment.CenterVertically,
                modifier =
                    Modifier.clip(RoundedCornerShape(16.dp))
                        .defaultMinSize(minWidth = navBarWidth)
                        .widthIn(min = navBarWidth, max = 247.dp)
                        .background(backgroundColor)
                        .animatedActionBorder(
                            strokeWidth = 2.dp,
@@ -126,7 +127,14 @@ fun NavBarPill(
                        .padding(horizontal = 8.dp, vertical = 6.dp)
                        .onGloballyPositioned { expandedSize = it.size },
            ) {
                // Should have at most 1 expanded chip
                var expandedChip by remember { mutableStateOf(false) }
                actions.fastForEach { action ->
                    Row(
                        horizontalArrangement =
                            Arrangement.spacedBy(4.dp, Alignment.CenterHorizontally),
                        verticalAlignment = Alignment.CenterVertically,
                    ) {
                        Image(
                            painter = rememberDrawablePainter(action.icon),
                            colorFilter =
@@ -138,25 +146,33 @@ fun NavBarPill(
                            contentDescription = action.label,
                            modifier = Modifier.size(16.dp).clip(CircleShape),
                        )
                    if (actions.size == 1 || action.attribution != null) {
                        if ((actions.size == 1 || action.attribution != null) && !expandedChip) {
                            expandedChip = true
                            Text(
                                text = action.label,
                                style = MaterialTheme.typography.labelSmall,
                                maxLines = 1,
                                overflow = TextOverflow.Ellipsis,
                                color = outlineColor,
                                modifier = Modifier.weight(0.63f, fill = false),
                            )
                            if (action.attribution != null) {
                                Text(
                                    text = action.attribution,
                                    style = MaterialTheme.typography.labelSmall,
                                    maxLines = 1,
                                    overflow = TextOverflow.Ellipsis,
                                    color = outlineColor,
                                modifier = Modifier.padding(start = 4.dp).alpha(0.4f),
                                    modifier =
                                        Modifier.padding(start = 4.dp)
                                            .alpha(0.4f)
                                            .weight(0.37f, false),
                                )
                            }
                        }
                    }
                }
            }

            PlatformIconButton(
                modifier =