Skip to content

Commit

Permalink
Adjust the status bar while using the system dark theme to not use da…
Browse files Browse the repository at this point in the history
…rk icons (#358)

* Disable light status bars when system dark theme is active

* Fix formatting for Theme.kt
  • Loading branch information
russjr08 authored Apr 25, 2023
1 parent 2075c1c commit 29625f5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/com/jerboa/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package com.jerboa.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.sp
import androidx.core.graphics.ColorUtils
import androidx.core.view.WindowCompat
import com.jerboa.ThemeColor
import com.jerboa.ThemeMode
import com.jerboa.db.AppSettings
Expand Down Expand Up @@ -54,6 +58,16 @@ fun JerboaTheme(

val typography = generateTypography(fontSize)

val view = LocalView.current

if (isSystemInDarkTheme()) {
SideEffect {
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)
insets.isAppearanceLightStatusBars = false
}
}

MaterialTheme(
colorScheme = colors,
typography = typography,
Expand Down

0 comments on commit 29625f5

Please sign in to comment.