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

Commit 5817b270 authored by amehfooz's avatar amehfooz Committed by burakov
Browse files

[Dual Shade] Fix SystemIconChip hover behavior

Uses default hover and ripple indication to match
UX specs.
The chip shape is now applied via a Clip modifier
so both the ripple and background share it.

Bug: 408486251
Test: manual, video in bug
Flag: com.android.systemui.scene_container

Change-Id: Iede60e03cdbbe5f51575bf792191dd86a78214d7
parent 59956d6a
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
@@ -756,29 +757,21 @@ private fun SystemIconChip(
    onClick: (() -> Unit)? = null,
    content: @Composable RowScope.() -> Unit,
) {
    val interactionSource = remember { MutableInteractionSource() }
    val isHovered by interactionSource.collectIsHoveredAsState()
    val hoverModifier =
        with(MaterialTheme.colorScheme) {
            Modifier.background(onScrimDim, RoundedCornerShape(CollapsedHeight / 4))
        }

    Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier =
            modifier
                .thenIf(backgroundColor != Color.Unspecified) {
                    Modifier.background(backgroundColor, RoundedCornerShape(25.dp))
                        .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
                }
                .clip(RoundedCornerShape(25.dp))
                .thenIf(onClick != null) {
                    Modifier.clickable(
                        interactionSource = interactionSource,
                        indication = null,
                        onClick = { onClick?.invoke() },
                    )
                }
                .thenIf(isHovered) { hoverModifier },
                .thenIf(backgroundColor != Color.Unspecified) {
                    Modifier.background(backgroundColor)
                        .padding(horizontal = ChipPaddingHorizontal, vertical = ChipPaddingVertical)
                },

        content = content,
    )
}