Committed unformatted again: I piped the check through grep, so the task's failure never reached the shell's exit status and the chained commit ran anyway. Check exit codes, not output. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
54 lines
1.9 KiB
Kotlin
54 lines
1.9 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import androidx.compose.foundation.Canvas
|
|
import androidx.compose.foundation.layout.height
|
|
import androidx.compose.foundation.layout.width
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.geometry.Offset
|
|
import androidx.compose.ui.graphics.Color
|
|
import androidx.compose.ui.graphics.StrokeCap
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
/**
|
|
* A chevron, pointing up or down.
|
|
*
|
|
* Drawn rather than set in a font: a chevron from an icon font is one of the glyphs a system font
|
|
* may simply not have, and the reader who gets an empty box instead is never the one who wrote it.
|
|
*
|
|
* One composable for both directions rather than two that differ by a minus sign -- the pair would
|
|
* drift, and the drift would be a bug in exactly one direction.
|
|
*
|
|
* It draws no label of its own, so every caller owes it a `contentDescription`: this is the whole
|
|
* of what assistive technology has to go on, and it is also the answer to "what was that arrow for"
|
|
* six months from now.
|
|
*/
|
|
@Composable
|
|
fun Chevron(
|
|
pointingUp: Boolean,
|
|
modifier: Modifier = Modifier,
|
|
colour: Color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
) {
|
|
Canvas(modifier.width(20.dp).height(10.dp)) {
|
|
val inset = 2.dp.toPx()
|
|
val point = if (pointingUp) inset else size.height - inset
|
|
val ends = if (pointingUp) size.height - inset else inset
|
|
val stroke = 2.dp.toPx()
|
|
drawLine(
|
|
colour,
|
|
Offset(inset, ends),
|
|
Offset(size.width / 2, point),
|
|
strokeWidth = stroke,
|
|
cap = StrokeCap.Round,
|
|
)
|
|
drawLine(
|
|
colour,
|
|
Offset(size.width / 2, point),
|
|
Offset(size.width - inset, ends),
|
|
strokeWidth = stroke,
|
|
cap = StrokeCap.Round,
|
|
)
|
|
}
|
|
}
|