car toasts: match the message popup and stay up longer

A driver only glances at the screen, so short toasts now last 4 seconds and long
ones 7. The card uses the popup's colours, which read better over a map.
This commit is contained in:
Seb3thehacker committed 2026-10-09 14:24:32 -07:00
1 parent 006823232d
commit 179a51ea25
3 files changed
+10 -8

No files matched your search

@@ -4,6 +4,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -39,15 +40,15 @@ internal fun CarToastOverlay(modifier: Modifier = Modifier) {
modifier
.padding(horizontal = 24.dp, vertical = 16.dp)
.widthIn(max = 560.dp)
.clip(MaterialTheme.shapes.medium)
.background(MaterialTheme.colorScheme.inverseSurface)
.clip(RoundedCornerShape(20.dp))
.background(MaterialTheme.colorScheme.surfaceContainerHigh)
.semantics { liveRegion = LiveRegionMode.Polite },
) {
Text(
message.text,
modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp),
color = MaterialTheme.colorScheme.inverseOnSurface,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.titleMedium,
maxLines = 3,
overflow = TextOverflow.Ellipsis,
)
@@ -17,7 +17,8 @@ internal object CarToasts {
fun show(owner: Any, text: String, duration: Int) {
if (text.isBlank()) return
val durationMs = if (duration == CarToast.LENGTH_LONG) 3_500L else 2_000L
// Longer than a phone toast: the driver only glances at the screen now and then.
val durationMs = if (duration == CarToast.LENGTH_LONG) 7_000L else 4_000L
current.value = Message(owner, text, durationMs)
}