Skip to content

Commit

Permalink
Merge pull request #1275 from google/av/system-ui-controller-hoist-dark
Browse files Browse the repository at this point in the history
[SystemUiController] Update SystemUiController to hoist dark theme
  • Loading branch information
alexvanyo committed Aug 3, 2022
2 parents ac4b6da + 41de582 commit e69b0bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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 {}
}
}

0 comments on commit e69b0bf

Please sign in to comment.