mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
fix(ui): chip selection outlines draw inside the chip so a scrolling row no longer cuts them
This commit is contained in:
1 parent
60ea4a3b99
commit
964c3628b0
2 files changed
+11
-2
No files matched your search
@@ -741,7 +741,8 @@ internal fun SheetChips(labels: List<String>, selected: Int, focus: List<FocusRe
|
||||
BoxWithConstraints(Modifier.fillMaxWidth().onFocusChanged { within = it.hasFocus }) {
|
||||
val equal = maxWidth / labels.size.coerceAtLeast(1) >= 96.dp
|
||||
val scroll = rememberScrollState()
|
||||
Box(if (equal) Modifier.fillMaxWidth() else Modifier.edgeFade(scroll).horizontalScroll(scroll)) {
|
||||
// Room inside the scroll for the focus ring, which the scroll's clip would otherwise cut.
|
||||
Box(if (equal) Modifier.fillMaxWidth() else Modifier.edgeFade(scroll).horizontalScroll(scroll).padding(3.dp)) {
|
||||
ChipGlide(selected, bounds[selected], tint)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = if (equal) Modifier.fillMaxWidth() else Modifier) {
|
||||
labels.forEachIndexed { i, label ->
|
||||
|
||||
@@ -107,7 +107,15 @@ internal fun BoxScope.ChipGlide(
|
||||
val r = CornerRadius(corner?.let { lerp(minOf(with(density) { it.toPx() }, round), round, p) } ?: round)
|
||||
// A drop in flight is solid; on a chip it is the chip's tinted fill and outline.
|
||||
drawRoundRect(tint.value.copy(alpha = lerp(fill, 0.9f, p)), at0, size, r)
|
||||
if (outline > 0f) drawRoundRect(tint.value.copy(alpha = outline * (1f - p)), at0, size, r, style = Stroke(with(density) { 1.dp.toPx() }))
|
||||
if (outline > 0f) {
|
||||
// Inside the chip's edge: a stroke on it would lose its outer half to a scrolling row's clip.
|
||||
val w = with(density) { 1.dp.toPx() }
|
||||
val inset = w / 2f
|
||||
drawRoundRect(
|
||||
tint.value.copy(alpha = outline * (1f - p)), at0 + Offset(inset, inset), Size(size.width - w, size.height - w),
|
||||
CornerRadius((r.x - inset).coerceAtLeast(0f)), style = Stroke(w),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user