Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SystemUiController] Update SystemUiController to hoist dark theme #1275

Merged
merged 1 commit into from Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/systemuicontroller.md
Expand Up @@ -12,9 +12,9 @@ In your layouts you can update the system bar colors like so:
``` kotlin
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = MaterialTheme.colors.isLight
val useDarkIcons = !isSystemInDarkTheme()

SideEffect {
DisposableEffect(systemUiController, useDarkIcons) {
// Update all of the system bar colors to be transparent, and use
// dark icons if we're in light theme
systemUiController.setSystemBarsColor(
Expand All @@ -23,6 +23,8 @@ SideEffect {
)

// setStatusBarColor() and setNavigationBarColor() also exist

onDispose {}
}
```

Expand Down
Expand Up @@ -16,19 +16,19 @@

package com.google.accompanist.sample.systemuicontroller

import androidx.compose.material.MaterialTheme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.graphics.Color
import com.google.accompanist.systemuicontroller.rememberSystemUiController

@Composable
fun SystemUiControllerSample() {
// Get the current SystemUiController
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = MaterialTheme.colors.isLight
val useDarkIcons = !isSystemInDarkTheme()

SideEffect {
DisposableEffect(systemUiController, useDarkIcons) {
// Update all of the system bar colors to be transparent, and use
// dark icons if we're in light theme
systemUiController.setSystemBarsColor(
Expand All @@ -37,5 +37,6 @@ fun SystemUiControllerSample() {
)

// setStatusBarColor() and setNavigationBarColor() also exist
onDispose {}
}
}