Files
ComfyUI/composeApp/src/androidMain/kotlin/moe/uni/comfyKmp/SystemBars.android.kt
T
anran e5a779e48a
CI / android (push) Failing after 2m14s
chore: move package
2026-01-31 02:51:56 +08:00

37 lines
1.2 KiB
Kotlin

package moe.uni.comfyKmp
import android.app.Activity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
@Composable
actual fun SystemBarsEffect(hidden: Boolean) {
val view = LocalView.current
DisposableEffect(hidden) {
val activity = view.context as? Activity
val window = activity?.window
val controller = window?.let { WindowCompat.getInsetsController(it, it.decorView) }
val previousBehavior = controller?.systemBarsBehavior
if (hidden) {
controller?.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
controller?.hide(WindowInsetsCompat.Type.systemBars())
} else {
controller?.show(WindowInsetsCompat.Type.systemBars())
}
onDispose {
controller?.show(WindowInsetsCompat.Type.systemBars())
if (previousBehavior != null) {
controller.systemBarsBehavior = previousBehavior
}
}
}
}