From 67764300a85bee6f4fa6bdbe12fb35f25a5cd2fd Mon Sep 17 00:00:00 2001 From: davotoula Date: Tue, 16 Jun 2026 20:37:39 +0200 Subject: [PATCH] feat: hide OS system bars during full-screen media Install a DisposableEffect in ZoomableImageDialog that hides both status and navigation bars via WindowInsetsControllerCompat when the full-screen media dialog opens, and restores them on dispose. --- .../ui/components/ZoomableContentDialog.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt index 93ab093d99..56b3440198 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt @@ -53,6 +53,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Surface import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue @@ -71,10 +72,13 @@ import androidx.compose.ui.layout.boundsInWindow import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView import androidx.compose.ui.util.lerp import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import androidx.core.net.toUri +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted @@ -206,6 +210,19 @@ fun ZoomableImageDialog( dialogWindow.attributes = attributes } + // Go fully immersive while the full-screen media viewer is open: hide both OS bars and + // restore them when the dialog closes. BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE lets the user + // swipe to peek the bars. Applies to full-screen images and video alike (shared dialog). + val dialogView = LocalView.current + DisposableEffect(dialogWindow, dialogView) { + val controller = dialogWindow?.let { WindowInsetsControllerCompat(it, dialogView) } + controller?.apply { + systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + hide(WindowInsetsCompat.Type.systemBars()) + } + onDispose { controller?.show(WindowInsetsCompat.Type.systemBars()) } + } + Box(modifier = Modifier.fillMaxSize()) { // Background surface that fades in as the content grows to fullscreen. Surface(