Skip to content

Commit

Permalink
Merge pull request #222 from tarkalabs/mohanraj/enhancement/status-ba…
Browse files Browse the repository at this point in the history
…r-color-update

Status bar color updated based on the theme.
  • Loading branch information
rajajawahar authored Apr 12, 2024
2 parents e6e5f60 + d5e251b commit 79c8909
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tarka-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ publishing {
run {
groupId = "com.tarkalabs"
artifactId = getLibraryArtifactId()
version = "1.1.13"
version = "1.1.14"
artifact("$buildDir/outputs/aar/tarka-ui-release.aar")
}
}
Expand Down
18 changes: 18 additions & 0 deletions tarka-ui/src/main/java/com/tarkalabs/tarkaui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package com.tarkalabs.tarkaui.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.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

@Composable fun TUITheme(
darkTheme: Boolean = isSystemInDarkTheme(),
Expand All @@ -12,6 +21,15 @@ import androidx.compose.runtime.CompositionLocalProvider
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) darkColors else lightColors
val view = LocalView.current

if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colors.surface.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
}
}

CompositionLocalProvider(
LocalTUITypography provides extendedTypography, LocalTUIColors provides colors
Expand Down

0 comments on commit 79c8909

Please sign in to comment.