diff --git a/app/src/main/java/eu/kanade/presentation/components/Banners.kt b/app/src/main/java/eu/kanade/presentation/components/Banners.kt index d455b943d..465e3ad5a 100644 --- a/app/src/main/java/eu/kanade/presentation/components/Banners.kt +++ b/app/src/main/java/eu/kanade/presentation/components/Banners.kt @@ -19,6 +19,11 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import eu.kanade.tachiyomi.R +val DownloadedOnlyBannerBackgroundColor + @Composable get() = MaterialTheme.colorScheme.tertiary +val IncognitoModeBannerBackgroundColor + @Composable get() = MaterialTheme.colorScheme.primary + @Composable fun WarningBanner( @StringRes textRes: Int, @@ -66,7 +71,7 @@ private fun DownloadedOnlyModeBanner(modifier: Modifier = Modifier) { Text( text = stringResource(R.string.label_downloaded_only), modifier = Modifier - .background(color = MaterialTheme.colorScheme.tertiary) + .background(DownloadedOnlyBannerBackgroundColor) .fillMaxWidth() .padding(4.dp) .then(modifier), @@ -81,7 +86,7 @@ private fun IncognitoModeBanner(modifier: Modifier = Modifier) { Text( text = stringResource(R.string.pref_incognito_mode), modifier = Modifier - .background(color = MaterialTheme.colorScheme.primary) + .background(IncognitoModeBannerBackgroundColor) .fillMaxWidth() .padding(4.dp) .then(modifier), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index b17297d08..3323ce4e8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -29,6 +29,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.luminance import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -51,6 +52,8 @@ import eu.kanade.domain.library.service.LibraryPreferences import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.domain.ui.UiPreferences import eu.kanade.presentation.components.AppStateBanners +import eu.kanade.presentation.components.DownloadedOnlyBannerBackgroundColor +import eu.kanade.presentation.components.IncognitoModeBannerBackgroundColor import eu.kanade.presentation.util.AssistContentScreen import eu.kanade.presentation.util.DefaultNavigatorScreenTransition import eu.kanade.presentation.util.collectAsState @@ -149,22 +152,25 @@ class MainActivity : BaseActivity() { setComposeContent { val incognito by preferences.incognitoMode().collectAsState() - val download by preferences.downloadedOnly().collectAsState() + val downloadOnly by preferences.downloadedOnly().collectAsState() Column { AppStateBanners( - downloadedOnlyMode = download, + downloadedOnlyMode = downloadOnly, incognitoMode = incognito, ) // Set statusbar color val systemUiController = rememberSystemUiController() val isSystemInDarkTheme = isSystemInDarkTheme() - val active = incognito || download - val useDarkStatusBarIcons = if (isSystemInDarkTheme) active else !active - LaunchedEffect(systemUiController, useDarkStatusBarIcons) { + val statusBarBackgroundColor = when { + downloadOnly -> DownloadedOnlyBannerBackgroundColor + incognito -> IncognitoModeBannerBackgroundColor + else -> MaterialTheme.colorScheme.background + } + LaunchedEffect(systemUiController, statusBarBackgroundColor) { systemUiController.setStatusBarColor( color = ComposeColor.Transparent, - darkIcons = useDarkStatusBarIcons, + darkIcons = statusBarBackgroundColor.luminance() > 0.5, transformColorForLightContent = { ComposeColor.Black }, ) } @@ -206,7 +212,7 @@ class MainActivity : BaseActivity() { } // Consume insets already used by app state banners - val boxModifier = if (incognito || download) { + val boxModifier = if (incognito || downloadOnly) { Modifier.consumeWindowInsets(WindowInsets.statusBars) } else { Modifier