neiam
/apollos_crib
It's Apollo's Crib
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions failure · Badges · Packages
⭐
Log in to mark this repository.
Keep the dial's footprint on a phone with no compass
d0b8c96 · Gabriel Morell · 2026-09-14 02:32
Message
{commit_body(@commit)}
Files changed
modified
clients/android/app/src/main/java/io/neiam/apolloscrib/ui/Compass.kt
+25
−9
@@ -216,26 +216,42 @@ fun Compass(
| 216 | 216 | /** How far through the card rotation, 0..1, or null when nothing rotates. */ |
| 217 | 217 | rotation: Float? = null |
| 218 | 218 | ) { |
| 219 | − if (!heading.available) return | |
| 220 | − | |
| 221 | 219 | val palette = LocalAppTheme.current |
| 222 | 220 | |
| 221 | + // A device with no rotation vector still gets the dial's footprint: the | |
| 222 | + // gestures that cycle the detailed cards and the turn speed hang off this | |
| 223 | + // composable, and returning nothing here took them away with the needle -- | |
| 224 | + // leaving the board stuck in whatever mode it was last left in, with no | |
| 225 | + // way to change it. What it does not get is a rose: a fixed card and a | |
| 226 | + // mark pointing at nothing is the decoration this avoids drawing. | |
| 223 | 227 | Column( |
| 224 | 228 | modifier = modifier, |
| 225 | 229 | horizontalAlignment = Alignment.CenterHorizontally, |
| 226 | 230 | verticalArrangement = Arrangement.spacedBy(1.dp) |
| 227 | 231 | ) { |
| 228 | 232 | Canvas(Modifier.size(34.dp)) { |
| 229 | − drawRose(heading.degrees, palette.dim, palette.accent) | |
| 233 | + if (heading.available) { | |
| 234 | + drawRose(heading.degrees, palette.dim, palette.accent) | |
| 235 | + } else { | |
| 236 | + // The track the turn sweeps, and on its own the only sign the | |
| 237 | + // dial is there to be pressed. | |
| 238 | + drawCircle( | |
| 239 | + color = palette.dim.copy(alpha = 0.35f), | |
| 240 | + radius = size.minDimension / 2f - 1f, | |
| 241 | + style = Stroke(width = 1.5f) | |
| 242 | + ) | |
| 243 | + } | |
| 230 | 244 | rotation?.let { drawTurn(it, palette.accent) } |
| 231 | 245 | } |
| 232 | 246 | |
| 233 | − Text( | |
| 234 | − "${wrap(heading.degrees).roundToInt()}° ${compassPoint(heading.degrees)}", | |
| 235 | − style = MaterialTheme.typography.labelSmall, | |
| 236 | − fontFamily = FontFamily.Monospace, | |
| 237 | − color = palette.dim | |
| 238 | − ) | |
| 247 | + if (heading.available) { | |
| 248 | + Text( | |
| 249 | + "${wrap(heading.degrees).roundToInt()}° ${compassPoint(heading.degrees)}", | |
| 250 | + style = MaterialTheme.typography.labelSmall, | |
| 251 | + fontFamily = FontFamily.Monospace, | |
| 252 | + color = palette.dim | |
| 253 | + ) | |
| 254 | + } | |
| 239 | 255 | } |
| 240 | 256 | } |
| 241 | 257 |
Parents: 4cfa437