mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 13:38:13 -08:00
fix: System bars contiuously showing on Android video player (#568)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
861d75b1e9
commit
b9c1e82b43
2 changed files with 17 additions and 10 deletions
|
|
@ -3,7 +3,6 @@ package nl.jknaapen.fladder.utility
|
|||
import android.app.Activity
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
|
|
@ -11,25 +10,25 @@ import androidx.core.view.WindowInsetsControllerCompat
|
|||
@Composable
|
||||
fun ImmersiveSystemBars(isImmersive: Boolean) {
|
||||
val view = LocalView.current
|
||||
LaunchedEffect(view) {
|
||||
val activity = view.context as? Activity
|
||||
val window = activity?.window
|
||||
if (window != null) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
}
|
||||
}
|
||||
|
||||
DisposableEffect(view, isImmersive) {
|
||||
val activity = view.context as? Activity
|
||||
val window = activity?.window
|
||||
val controller = window?.let { WindowInsetsControllerCompat(it, view) }
|
||||
|
||||
if (window != null) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
}
|
||||
|
||||
if (isImmersive) {
|
||||
controller?.hide(androidx.core.view.WindowInsetsCompat.Type.systemBars())
|
||||
controller?.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
} else {
|
||||
controller?.show(androidx.core.view.WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
|
||||
onDispose { }
|
||||
onDispose {
|
||||
controller?.show(androidx.core.view.WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue