theme: the phone app follows the App theme setting too, so Light is light everywhere

This commit is contained in:
Seb3thehacker committed 2026-10-26 23:33:59 -07:00
1 parent e4c2a72fad
commit cc522bb0b7
3 files changed
+14 -5

No files matched your search

@@ -3,7 +3,6 @@ package app.seb3thehacker.gearslip.ui
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.LocalView
import androidx.compose.runtime.SideEffect import androidx.compose.runtime.SideEffect
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.windowInsetsTopHeight import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.background import androidx.compose.foundation.background
@@ -105,7 +104,7 @@ fun GearslipApp(onDisconnect: () -> Unit, onRequestCallScreening: () -> Unit) {
// On a debug build, Home's yellow header runs up behind the status bar, whose icons then go dark. // On a debug build, Home's yellow header runs up behind the status bar, whose icons then go dark.
val debugHeader = BuildConfig.DEBUG && screen == Screen.HOME val debugHeader = BuildConfig.DEBUG && screen == Screen.HOME
val view = LocalView.current val view = LocalView.current
val darkTheme = isSystemInDarkTheme() val darkTheme = gearslipDark()
SideEffect { SideEffect {
val window = (view.context as? Activity)?.window ?: return@SideEffect val window = (view.context as? Activity)?.window ?: return@SideEffect
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = debugHeader || !darkTheme WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = debugHeader || !darkTheme
@@ -17,9 +17,20 @@ import app.seb3thehacker.gearslip.car.theme.withTintedSurfaces
@Composable @Composable
fun GearslipTheme(content: @Composable () -> Unit) { fun GearslipTheme(content: @Composable () -> Unit) {
val context = LocalContext.current val context = LocalContext.current
val dark = isSystemInDarkTheme() val dark = gearslipDark()
// The car's Dark mode setting, so the phone and the car screen stay one look. // The car's Dark mode setting, so the phone and the car screen stay one look.
val darkStyle by app.seb3thehacker.gearslip.car.CarSettings.darkStyle.collectAsState() val darkStyle by app.seb3thehacker.gearslip.car.CarSettings.darkStyle.collectAsState()
val scheme = (if (dark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)).withTintedSurfaces(dark, darkStyle) val scheme = (if (dark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)).withTintedSurfaces(dark, darkStyle)
MaterialTheme(colorScheme = scheme, content = content) MaterialTheme(colorScheme = scheme, content = content)
} }
/** Whether the phone app is dark: the car's App theme setting, so Light means light everywhere. */
@Composable
fun gearslipDark(): Boolean {
val theme by app.seb3thehacker.gearslip.car.CarSettings.appTheme.collectAsState()
return when (theme) {
app.seb3thehacker.gearslip.car.AppTheme.PHONE -> isSystemInDarkTheme()
app.seb3thehacker.gearslip.car.AppTheme.LIGHT -> false
app.seb3thehacker.gearslip.car.AppTheme.DARK -> true
}
}
@@ -21,7 +21,6 @@ import androidx.compose.foundation.layout.size
import android.content.Context import android.content.Context
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.foundation.isSystemInDarkTheme
import app.seb3thehacker.gearslip.car.CarSettings import app.seb3thehacker.gearslip.car.CarSettings
import app.seb3thehacker.gearslip.car.BluetoothAudioCheck import app.seb3thehacker.gearslip.car.BluetoothAudioCheck
import android.provider.Settings import android.provider.Settings
@@ -202,7 +201,7 @@ private fun BluetoothMissingCard() {
val context = LocalContext.current val context = LocalContext.current
// Yellow, not the theme's error red: music is missing, but nothing is broken. Material has no // Yellow, not the theme's error red: music is missing, but nothing is broken. Material has no
// warning colour, so these are fixed amber tones for light and dark. // warning colour, so these are fixed amber tones for light and dark.
val dark = isSystemInDarkTheme() val dark = gearslipDark()
val container = if (dark) Color(0xFF4A3B00) else Color(0xFFFFE08A) val container = if (dark) Color(0xFF4A3B00) else Color(0xFFFFE08A)
val content = if (dark) Color(0xFFFFE08A) else Color(0xFF3A2E00) val content = if (dark) Color(0xFFFFE08A) else Color(0xFF3A2E00)
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))