fix(ui): update the status bar icons to match the current theme

This commit is contained in:
junkfood 2024-05-31 03:35:47 +08:00
parent bddc8766ec
commit de9986c2e7
No known key found for this signature in database
GPG Key ID: 2EA5B648DB112A34
1 changed files with 20 additions and 0 deletions

View File

@ -1,10 +1,14 @@
package me.ash.reader.ui.theme
import android.os.Build
import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import me.ash.reader.infrastructure.preference.LocalBasicFonts
import me.ash.reader.infrastructure.preference.LocalThemeIndex
import me.ash.reader.ui.theme.palette.LocalTonalPalettes
@ -20,6 +24,22 @@ fun AppTheme(
wallpaperPalettes: List<TonalPalettes> = extractTonalPalettesFromUserWallpaper(),
content: @Composable () -> Unit,
) {
val view = LocalView.current
LaunchedEffect(useDarkTheme) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (useDarkTheme) {
view.windowInsetsController?.setSystemBarsAppearance(
0, APPEARANCE_LIGHT_STATUS_BARS
)
} else {
view.windowInsetsController?.setSystemBarsAppearance(
APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS
)
}
}
}
val themeIndex = LocalThemeIndex.current
val tonalPalettes = wallpaperPalettes[