shadow the starred badge with the icon shape, not a disc

Modifier.shadow only takes a Shape, so over artwork the star now draws with a dark copy of
the same glyph offset behind it instead of a circular halo.
This commit is contained in:
austinried
2026-10-04 00:29:59 +00:00
parent 73db0681b5
commit 3f4dc5f866
@@ -13,10 +13,10 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Star import androidx.compose.material.icons.rounded.Star
@@ -313,17 +313,24 @@ fun StarredBadge(
shadow: Boolean = false, shadow: Boolean = false,
) { ) {
if (starred) { if (starred) {
Box(modifier.size(size)) {
if (shadow) {
Icon(
imageVector = Icons.Rounded.Star,
contentDescription = null,
tint = Color.Black.copy(alpha = 0.5f),
modifier = Modifier.matchParentSize().offset(x = 0.5.dp, y = 1.dp),
)
}
Icon( Icon(
imageVector = Icons.Rounded.Star, imageVector = Icons.Rounded.Star,
contentDescription = "Starred", contentDescription = "Starred",
tint = MaterialTheme.colorScheme.primary, tint = MaterialTheme.colorScheme.primary,
modifier = modifier = Modifier.matchParentSize(),
modifier
.then(if (shadow) Modifier.shadow(2.dp, CircleShape, clip = false) else Modifier)
.size(size),
) )
} }
} }
}
@Composable @Composable
fun Modifier.statusBarScrim(): Modifier { fun Modifier.statusBarScrim(): Modifier {