Feat(App): Support sliding down the notification bar to exit full screen

This commit is contained in:
2024-10-15 12:01:30 +08:00
parent e855a414a4
commit db25ab4e5f
2 changed files with 19 additions and 21 deletions

View File

@@ -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) {

View File

@@ -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