From 489e57c79f8e081be1b4c3e2b7134671326620ce Mon Sep 17 00:00:00 2001 From: lorenzhohermuth Date: Tue, 25 Mar 2025 13:45:15 +0100 Subject: [PATCH] Dark mode fix for Settings icon and Grant Permission Button --- .../main/java/com/module/breeze/MainActivity.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/module/breeze/MainActivity.kt b/app/src/main/java/com/module/breeze/MainActivity.kt index 702b8b4..d4963d2 100644 --- a/app/src/main/java/com/module/breeze/MainActivity.kt +++ b/app/src/main/java/com/module/breeze/MainActivity.kt @@ -13,6 +13,7 @@ import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.RequiresApi +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues @@ -63,7 +64,8 @@ val fontSizeUpper = 16.sp val fontSizeTitle = 22.sp val breezeFontWeight = FontWeight.Bold val iconStyle = Icons.Outlined -val textColor = Color(0, 0, 0) +val textColorLightMode = Color(0, 0, 0) +val textColorDarkMode = Color(255, 255, 255) val numberFormat = DecimalFormat("00") val apiKey = "8a6090c4308455152cd8c677b802883b" @@ -125,6 +127,7 @@ fun fetchCurrentTemp(ctx: Context, lat: Double, lon: Double): WeatherResponse { @Composable fun WeatherInfo(modifier: Modifier = Modifier) { val ctx = LocalContext.current + var textColor = if (isSystemInDarkTheme()) textColorDarkMode else textColorLightMode var forecast by remember { mutableStateOf(ForecastSummary(0.0, 0.0, false, false, false)) } var currentTemp by remember { mutableStateOf( @@ -229,12 +232,18 @@ fun WeatherInfo(modifier: Modifier = Modifier) { fontWeight = breezeFontWeight, ) } else { + Button( onClick = { permissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION) }, colors = ButtonDefaults.buttonColors( - containerColor = Color(0, 0, 0, 20), + containerColor = Color( + textColor.red, + textColor.green, + textColor.blue, + 0.09f, + ), contentColor = textColor, ), ) { @@ -257,6 +266,7 @@ fun GreetingPreview() { @Composable fun Navigation(icon: ImageVector, iconDescription: String, onClick: () -> Unit = {}) { + var textColor = if (isSystemInDarkTheme()) textColorDarkMode else textColorLightMode Row( horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth(),