Dark mode fix for Settings icon and Grant Permission Button

This commit is contained in:
Lorenz Hohermuth 2025-03-25 13:45:15 +01:00
parent f10e030647
commit 489e57c79f
1 changed files with 12 additions and 2 deletions

View File

@ -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(),