I'm a n00b around here. Small diatribe.
I've been coding for many moons (just not in this neck of the woods) and one of my favorite adages is the "Make it Work, Make it Right, Make it Fast (Optimal)" adage. While accomplishing the first goal is often good enough and minimizes overall risk (especially in a "ticket driven" development world), it's actually where the least amount of learning happens. So while
@Jan’s request may not fit the "right" bill, I often learn the most when people entertain answers to what are even bad ideas. I've learned today that BoxWithConstraints apparently has performance issues, and that alignment lines apparently don't work for checkboxes (for now?)
So here's my solution:
@Composable
fun LowHungItem(label: String, timestamp: Instant, modifer: Modifier = Modifier) {
Row(modifier = modifer, verticalAlignment = Alignment.CenterVertically) {
Checkbox(checked = true, onCheckedChange = {}, modifier = Modifier)
Column(modifier = Modifier.weight(1f)) {
Text(text = "X", modifier = Modifier.alpha(0f), fontSize = 10.sp)
Text(text = label, fontSize = 20.sp)
Text(text = "${timestamp}", fontSize = 10.sp)
}
Icon(Icons.Outlined.Delete, null)
}
}
@Preview(showBackground = true)
@Composable
private fun LowHungItemPreview() {
PlansDemoTheme {
LowHungItem("Test", Clock.System.now(), modifer = Modifier.fillMaxWidth())
}
}
This works (I think). It looks like what was asked for. But it's obviously a long way away from Right(tm)