diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt index d22e117..bf52636 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt @@ -25,6 +25,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -86,9 +87,16 @@ fun OxygenApp(appState: OxygenAppState) { } ) - LaunchedEffect(Unit) { + DisposableEffect(Unit) { windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + val listener = WindowInsetsControllerCompat.OnControllableInsetsChangedListener { _, _ -> + isFullScreen = false + } + windowInsetsController.addOnControllableInsetsChangedListener(listener) + onDispose { + windowInsetsController.removeOnControllableInsetsChangedListener(listener) + } } LaunchedEffect(isFullScreen) { diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt index 11f5328..f11362d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt @@ -16,21 +16,17 @@ import androidx.activity.compose.ManagedActivityResultLauncher import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.ActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.imePadding -import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.safeDrawing import androidx.compose.foundation.layout.widthIn -import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog @@ -101,22 +97,16 @@ internal fun ToolViewScreen( ) { val (isFullScreen, onFullScreenStateChange) = LocalFullScreen.current - Column( - modifier - .fillMaxWidth() - .windowInsetsPadding( - WindowInsets.safeDrawing.only( - WindowInsetsSides.Horizontal - ) + Column(modifier.fillMaxWidth()) { + AnimatedVisibility(!isFullScreen) { + TopBar( + toolViewUiState = toolViewUiState, + isPreview = isPreview, + isFullScreen = isFullScreen, + onBackClick = onBackClick, + onFullScreenChange = onFullScreenStateChange ) - ) { - TopBar( - toolViewUiState = toolViewUiState, - isPreview = isPreview, - isFullScreen = isFullScreen, - onBackClick = onBackClick, - onFullScreenChange = onFullScreenStateChange - ) + } Content( toolViewUiState = toolViewUiState, webViewInstanceState = webViewInstanceState