mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app: sync system bar icon colors with theme
Because the base post-splash theme is a dark theme, the window defaults to light (white) status bar icons. When the app is in light theme, the icons blend into the light background and become invisible. Synchronize WindowInsetsControllerCompat's appearance flags with the active theme so dark icons are used in light theme and light icons in dark theme. Assisted-by: Gemini 3.8 Flash
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.topjohnwu.magisk.ui
|
||||
|
||||
import android.os.Build
|
||||
import androidx.activity.compose.LocalActivity
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -11,13 +12,16 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
@@ -193,6 +197,17 @@ fun MagiskTheme(
|
||||
else -> MagiskLightColorScheme
|
||||
}
|
||||
|
||||
val activity = LocalActivity.current
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode && activity != null) {
|
||||
SideEffect {
|
||||
val window = activity.window
|
||||
val controller = WindowCompat.getInsetsController(window, view)
|
||||
controller.isAppearanceLightStatusBars = !isDarkTheme
|
||||
controller.isAppearanceLightNavigationBars = !isDarkTheme
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
shapes = MagiskShapes,
|
||||
|
||||
Reference in New Issue
Block a user