Skip to content

Commit

Permalink
Add back in commented out code regarding the system status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverspryn committed Feb 7, 2024
1 parent 2a3e0fe commit 9c88a8d
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
Expand All @@ -28,26 +29,32 @@ private val LightColorScheme = darkColorScheme(

@Composable
fun MultimodalSpannerTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
allowDynamicTheme: Boolean = true,
isDeviceUsingDarkMode: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
allowDynamicTheme && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
if (isDeviceUsingDarkMode) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
isDeviceUsingDarkMode -> DarkColorScheme
else -> LightColorScheme
}

val view = LocalView.current
val isPreviewingInAndroidStudio = view.isInEditMode

if (!view.isInEditMode) {
if (!isPreviewingInAndroidStudio) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
//ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
val activity = view.context as Activity
activity.window.statusBarColor = colorScheme.primary.toArgb()

WindowCompat.getInsetsController(
activity.window,
view
).isAppearanceLightStatusBars = isDeviceUsingDarkMode
}
}

Expand Down

0 comments on commit 9c88a8d

Please sign in to comment.