From f25eafcc4867b000a0c6861693137119ae09a84d Mon Sep 17 00:00:00 2001 From: Seb3thehacker Date: Wed, 30 Sep 2026 13:17:37 -0700 Subject: [PATCH] Keep the map loaded behind other screens Leaving Home used to tear down the map's surface, so coming back showed black for a second or two while the nav app redrew. Home now stays composed under every other screen. --- .../app/seb3thehacker/gearslip/car/CarUi.kt | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) 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 2cf8aad..95177a6 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarUi.kt @@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.ui.graphics.lerp import androidx.compose.ui.graphics.Brush import androidx.compose.foundation.layout.widthIn @@ -176,18 +177,32 @@ fun CarUi() { // Header navigation (breadcrumb trail) - off for now, kept to tweak later. // BreadcrumbBar(navigator) Box(Modifier.weight(1f).fillMaxWidth()) { - when (screen) { - CarScreen.Home -> CarHome() - CarScreen.Apps -> CarLauncher() - CarScreen.Media -> mediaApp?.let { MediaScreen(it) { navigator.back() } } - CarScreen.Browse -> BrowseAppScreen(navigator) - CarScreen.Settings -> CarSettingsScreen() - CarScreen.Dashboard -> CarDashboardScreen() - CarScreen.Weather -> WeatherScreen() - CarScreen.VehicleData -> VehicleDataScreen() - is CarScreen.Notifications -> NotificationsScreen(screen.replyTo) - is CarScreen.Messages -> MessagesScreen(screen.packageName) - is CarScreen.App -> CarApps.find(screen.id)?.content?.invoke() + // Home never leaves the composition; other screens cover it. Dropping it + // would tear down the map's surface, and coming back would then show black + // while the nav app redrew on a new one. + CarHome() + if (screen != CarScreen.Home) { + Box( + Modifier + .fillMaxSize() + .background(MaterialTheme.colorScheme.background) + // Keeps touches that miss this screen's controls off the map. + .pointerInput(Unit) { detectTapGestures { } }, + ) { + when (screen) { + CarScreen.Home -> Unit + CarScreen.Apps -> CarLauncher() + CarScreen.Media -> mediaApp?.let { MediaScreen(it) { navigator.back() } } + CarScreen.Browse -> BrowseAppScreen(navigator) + CarScreen.Settings -> CarSettingsScreen() + CarScreen.Dashboard -> CarDashboardScreen() + CarScreen.Weather -> WeatherScreen() + CarScreen.VehicleData -> VehicleDataScreen() + is CarScreen.Notifications -> NotificationsScreen(screen.replyTo) + is CarScreen.Messages -> MessagesScreen(screen.packageName) + is CarScreen.App -> CarApps.find(screen.id)?.content?.invoke() + } + } } // The dashboard is already listing them, so it needs no popup. if (screen !is CarScreen.Notifications && screen != CarScreen.Dashboard) {