Skip to content

Commit

Permalink
don't make it so the ui asks for the insets controller every recompos…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
theScrabi committed Oct 23, 2024
1 parent b44acdd commit 75cb373
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions new-player/src/main/java/net/newpipe/newplayer/ui/NewPlayerUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,7 @@ fun NewPlayerUI(
val activity = LocalContext.current as Activity
val view = LocalView.current

// TODO this is a side-effect of the composition and should (probably) not happen on every
// recomposition
val window = activity.window
val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

val defaultBrightness = getDefaultBrightness(activity)

// Setup fullscreen

Expand All @@ -121,6 +114,10 @@ fun NewPlayerUI(
LaunchedEffect(
key1 = uiState.uiMode.systemInsetsVisible,
) {
val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

if (uiState.uiMode.systemInsetsVisible) {
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
} else {
Expand Down Expand Up @@ -149,6 +146,8 @@ fun NewPlayerUI(

LaunchedEffect(key1 = uiState.brightness) {
Log.d(TAG, "New Brightnes: ${uiState.brightness}")
val defaultBrightness = getDefaultBrightness(activity)

setScreenBrightness(
uiState.brightness ?: defaultBrightness, activity
)
Expand Down

0 comments on commit 75cb373

Please sign in to comment.