On a short car screen, the player beside the map shows the cover behind its controls

The car UI now knows when the car's screen is short: under 420 dp tall
inside its margins, as a single-DIN unit's is (369 dp on a SOOEMAKA). Most
head units' screens are 480 dp or more, and nothing changes on them.

The player beside the map put the cover above the title, seek bar and
transport, so on a short screen the cover had room for a sliver. There, the
cover now fills the card, darkened toward the bottom, with the controls over
it in light colours. Tapping it opens the media screen, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HawkandClaude Opus 5.5 committed 2026-11-22 22:42:55 -08:00
1 parent 4e3f8e6657
commit 56dafa8fc3
2 files changed
+88 -2

No files matched your search

@@ -132,7 +132,11 @@ fun CarHome() {
top = CARD_GAP, top = CARD_GAP,
bottom = LocalNavBarInset.current + CARD_GAP, bottom = LocalNavBarInset.current + CARD_GAP,
) )
if (shown.value == SidePanel.LYRICS) SideLyrics(now, card) else DockedPlayer(now, card) when {
shown.value == SidePanel.LYRICS -> SideLyrics(now, card)
LocalShortScreen.current -> CoverPlayer(now, card)
else -> DockedPlayer(now, card)
}
} }
} }
} }
@@ -291,6 +295,76 @@ private fun DockedPlayer(now: NowPlaying, modifier: Modifier) {
} }
} }
/**
* The player beside the map on a short screen, where a cover above the controls had room for only
* a sliver: the cover fills the card, darkened toward the bottom, with the title, seek bar and
* transport over it. Tapping the cover opens the full media screen, as on the tall player.
*/
@Composable
private fun CoverPlayer(now: NowPlaying, modifier: Modifier, shape: androidx.compose.ui.graphics.Shape = CARD_SHAPE) {
val navigator = LocalCarNavigator.current
val media = CarServices.media
val art = rememberArt(now)
val scheme = MaterialTheme.colorScheme
// Light text and buttons over the darkened cover, whatever the theme; the theme's own without one.
val over = when {
art == null || scheme.surface.luminance() < 0.5f -> scheme
else -> androidx.compose.material3.dynamicDarkColorScheme(LocalContext.current)
}
Surface(modifier = modifier.gsPanelShadow(shape), shape = shape, color = scheme.surfaceContainer) {
Box(Modifier.fillMaxSize().clickable { navigator.media() }) {
// A new song's cover fades in over the old one instead of cutting to it.
androidx.compose.animation.Crossfade(art, animationSpec = tween(350), label = "cover") { shown ->
if (shown != null) {
Box(Modifier.fillMaxSize()) {
Image(shown.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop)
Box(
Modifier.fillMaxSize().background(
androidx.compose.ui.graphics.Brush.verticalGradient(
0f to Color.Black.copy(alpha = 0.2f),
0.4f to Color.Black.copy(alpha = 0.45f),
1f to Color.Black.copy(alpha = 0.78f),
),
),
)
}
} else {
AlbumGlow(null, Modifier.fillMaxSize())
}
}
MaterialTheme(colorScheme = over) {
Column(
Modifier.fillMaxSize().padding(12.dp),
verticalArrangement = Arrangement.Bottom,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
now.title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold,
color = over.onSurface, maxLines = 1, overflow = TextOverflow.Ellipsis,
)
Text(
now.artist, style = MaterialTheme.typography.bodyMedium, color = over.onSurfaceVariant,
maxLines = 1, overflow = TextOverflow.Ellipsis,
)
if (now.durationMs > 0) {
PlayerProgress(
now, media, Modifier.fillMaxWidth().padding(vertical = 2.dp),
timeStyle = MaterialTheme.typography.labelLarge,
)
} else {
Spacer(Modifier.height(10.dp))
}
BoxWithConstraints(Modifier.fillMaxWidth()) {
// As on the tall player: two skips, play at 1.25 times a skip, and two gaps.
val skip = ((maxWidth - 40.dp) / 3.25f).coerceIn(36.dp, 48.dp)
TransportRow(now, media, skip = skip, modifier = Modifier.fillMaxWidth())
}
}
}
}
}
}
/** /**
* Lyrics alone beside the map, big enough to read at a glance. The header is slim, since the * Lyrics alone beside the map, big enough to read at a glance. The header is slim, since the
* player goes back to the nav bar meanwhile and names the song there. Its note button swaps the * player goes back to the nav bar meanwhile and names the song there. Its note button swaps the
@@ -262,7 +262,8 @@ fun CarUi() {
val homeInset = if (barShown) NAV_BAR_HEIGHT else 0.dp val homeInset = if (barShown) NAV_BAR_HEIGHT else 0.dp
// Only the screen that asked: going Home or anywhere else ends it. // Only the screen that asked: going Home or anywhere else ends it.
val fullscreen = CarFullscreen.active && screen != CarScreen.Home val fullscreen = CarFullscreen.active && screen != CarScreen.Home
Box(Modifier.fillMaxSize().padding(pad)) { BoxWithConstraints(Modifier.fillMaxSize().padding(pad)) {
CompositionLocalProvider(LocalShortScreen provides (maxHeight < SHORT_SCREEN_HEIGHT)) {
Column(Modifier.fillMaxSize()) { Column(Modifier.fillMaxSize()) {
if (!safetyWarningSeen) { if (!safetyWarningSeen) {
CarSafetyWizard(onDone = CarSettings::markSafetyWarningSeen) CarSafetyWizard(onDone = CarSettings::markSafetyWarningSeen)
@@ -393,10 +394,21 @@ fun CarUi() {
} }
} }
} }
}
} }
internal val NAV_BAR_HEIGHT = 56.dp internal val NAV_BAR_HEIGHT = 56.dp
/**
* Whether the car's screen is short: under [SHORT_SCREEN_HEIGHT] tall inside the car's margins, as a
* single-DIN unit's is. Screens laid out for the usual height switch to a compact layout of their
* own on it; on any taller screen nothing changes.
*/
internal val LocalShortScreen = androidx.compose.runtime.compositionLocalOf { false }
/** A SOOEMAKA single-DIN unit's screen is 369 dp tall; most head units' are 480 dp or more. */
internal val SHORT_SCREEN_HEIGHT = 420.dp
/** /**
* How much of the bottom of Home the floating nav bar covers right now: its height while it shows, * How much of the bottom of Home the floating nav bar covers right now: its height while it shows,
* zero while it's hidden or when it has a row of its own. * zero while it's hidden or when it has a row of its own.