Skip to content

Commit

Permalink
Add SystemBarsColor
Browse files Browse the repository at this point in the history
  • Loading branch information
wmontwe committed Apr 11, 2023
1 parent 216350a commit e5bf49b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/ui/compose/theme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ android {

dependencies {
api(projects.core.ui.compose.common)
implementation(libs.accompanist.systemuicontroller)
implementation(libs.androidx.compose.material)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ private val k9LightColorPalette = lightColors(
primaryVariant = MaterialColor.gray_700,
secondary = MaterialColor.pink_500,
secondaryVariant = MaterialColor.pink_300,
toolbar = MaterialColor.gray_100,
)

private val k9DarkColorPalette = darkColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import app.k9mail.core.ui.compose.theme.color.Colors
import app.k9mail.core.ui.compose.theme.color.LocalColors
import app.k9mail.core.ui.compose.theme.color.SetSystemBarsColor
import app.k9mail.core.ui.compose.theme.color.toMaterialColors

@Composable
Expand All @@ -31,6 +32,8 @@ fun MainTheme(
lightImages
}

SetSystemBarsColor(color = colors.toolbar)

CompositionLocalProvider(
LocalColors provides colors,
LocalElevations provides Elevations(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class Colors(
val onBackground: Color,
val onSurface: Color,
val onMessage: Color,
val toolbar: Color,
val isLight: Boolean,
)

Expand All @@ -42,6 +43,7 @@ internal fun lightColors(
onBackground: Color = Color.Black,
onSurface: Color = Color.Black,
onMessage: Color = Color.White,
toolbar: Color = primary,
) = Colors(
primary = primary,
primaryVariant = primaryVariant,
Expand All @@ -58,6 +60,7 @@ internal fun lightColors(
onBackground = onBackground,
onSurface = onSurface,
onMessage = onMessage,
toolbar = toolbar,
isLight = true,
)

Expand All @@ -78,6 +81,7 @@ internal fun darkColors(
onBackground: Color = Color.White,
onSurface: Color = Color.White,
onMessage: Color = Color.Black,
toolbar: Color = surface,
) = Colors(
primary = primary,
primaryVariant = primaryVariant,
Expand All @@ -94,6 +98,7 @@ internal fun darkColors(
onBackground = onBackground,
onSurface = onSurface,
onMessage = onMessage,
toolbar = toolbar,
isLight = false,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package app.k9mail.core.ui.compose.theme.color

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.graphics.Color
import com.google.accompanist.systemuicontroller.rememberSystemUiController

@Composable
fun SetSystemBarsColor(
color: Color,
) {
val systemUiController = rememberSystemUiController()

DisposableEffect(Unit) {
systemUiController.setSystemBarsColor(color = color)

onDispose { }
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ androidxTransition = "1.4.1"
androidxComposeCompiler = "1.4.4"
androidxComposeBom = "2023.03.00"
androidxComposeMaterial = "1.3.1"
accompanist = "0.30.0"
fastAdapter = "5.7.0"
preferencesFix = "1.1.0"
timber = "5.0.1"
Expand Down Expand Up @@ -90,6 +91,7 @@ androidx-test-core = "androidx.test:core:1.5.0"
androidx-test-ext-junit-ktx = "androidx.test.ext:junit-ktx:1.1.5"
androidx-test-espresso-core = "androidx.test.espresso:espresso-core:3.5.1"
android-material = "com.google.android.material:material:1.8.0"
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
fastadapter = { module = "com.mikepenz:fastadapter", version.ref = "fastAdapter" }
fastadapter-extensions-drag = { module = "com.mikepenz:fastadapter-extensions-drag", version.ref = "fastAdapter" }
fastadapter-extensions-utils = { module = "com.mikepenz:fastadapter-extensions-utils", version.ref = "fastAdapter" }
Expand Down

0 comments on commit e5bf49b

Please sign in to comment.