From 0cf28b875c6b0906602bd21876414f1d0511ff8c Mon Sep 17 00:00:00 2001 From: Seb3thehacker Date: Sat, 24 Oct 2026 13:53:05 -0700 Subject: [PATCH] car: tint the car UI with the phone's Material You color Cards over the map use the nav bar's color instead of near-black. --- .../app/seb3thehacker/gearslip/car/CarUi.kt | 3 +- .../gearslip/car/TemplateParts.kt | 3 +- .../gearslip/car/theme/CarColors.kt | 29 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 gearslip/src/main/java/app/seb3thehacker/gearslip/car/theme/CarColors.kt diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt index 43d5be8..761dcf4 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt @@ -75,6 +75,7 @@ import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.style.TextOverflow import app.seb3thehacker.gearslip.R import app.seb3thehacker.gearslip.car.theme.GsColors +import app.seb3thehacker.gearslip.car.theme.withTintedSurfaces import app.seb3thehacker.gearslip.car.theme.GsIconBox import app.seb3thehacker.gearslip.car.theme.GsIconButton import app.seb3thehacker.gearslip.car.theme.GsButton @@ -117,7 +118,7 @@ fun CarUi() { AppTheme.LIGHT -> false AppTheme.DARK -> true } - val colors = if (dark) dynamicDarkColorScheme(appContext) else dynamicLightColorScheme(appContext) + val colors = (if (dark) dynamicDarkColorScheme(appContext) else dynamicLightColorScheme(appContext)).withTintedSurfaces(dark) val base = LocalDensity.current val insets by CarEnvironment.insets.collectAsState() val navigator = remember { CarNavigator(CarSettings.openOnConnect.value) } diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateParts.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateParts.kt index 67579be..0256025 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateParts.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateParts.kt @@ -106,7 +106,8 @@ internal fun ChromeSurface( ) { Surface( shadowElevation = shadowElevation, - color = MaterialTheme.colorScheme.surface, + // The nav bar's own container colour, so cards over the map match the rest of the car UI. + color = MaterialTheme.colorScheme.surfaceContainer, contentColor = MaterialTheme.colorScheme.onSurface, shape = shape, modifier = modifier, diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/theme/CarColors.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/theme/CarColors.kt new file mode 100644 index 0000000..ec99cc3 --- /dev/null +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/theme/CarColors.kt @@ -0,0 +1,29 @@ +package app.seb3thehacker.gearslip.car.theme + +import androidx.compose.material3.ColorScheme +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.compositeOver + +/** + * The phone's Material You colours, with its accent washed over the surfaces. Material You's own + * surfaces are nearly neutral, which reads as flat grey on a car screen; tinting them with the + * phone's primary colour (purple on a purple phone) gives the whole UI the phone's hue, the way + * Material 3's surface tint does, and it changes with the wallpaper like everything else. + * Higher containers take more of the tint, so cards still stand off the background. + */ +fun ColorScheme.withTintedSurfaces(dark: Boolean): ColorScheme { + val base = if (dark) 0.03f else 0.02f + fun tint(own: Color, step: Int) = primary.copy(alpha = base + step * (if (dark) 0.015f else 0.01f)).compositeOver(own) + return copy( + background = tint(background, 0), + surface = tint(surface, 0), + surfaceDim = tint(surfaceDim, 0), + surfaceContainerLowest = tint(surfaceContainerLowest, 0), + surfaceContainerLow = tint(surfaceContainerLow, 1), + surfaceContainer = tint(surfaceContainer, 2), + surfaceContainerHigh = tint(surfaceContainerHigh, 3), + surfaceContainerHighest = tint(surfaceContainerHighest, 4), + surfaceBright = tint(surfaceBright, 4), + surfaceVariant = tint(surfaceVariant, 3), + ) +}