Feat(App): Support sliding down the notification bar to exit full screen
This commit is contained in:
@@ -25,6 +25,7 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
@@ -86,9 +87,16 @@ fun OxygenApp(appState: OxygenAppState) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
windowInsetsController.systemBarsBehavior =
|
windowInsetsController.systemBarsBehavior =
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
val listener = WindowInsetsControllerCompat.OnControllableInsetsChangedListener { _, _ ->
|
||||||
|
isFullScreen = false
|
||||||
|
}
|
||||||
|
windowInsetsController.addOnControllableInsetsChangedListener(listener)
|
||||||
|
onDispose {
|
||||||
|
windowInsetsController.removeOnControllableInsetsChangedListener(listener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(isFullScreen) {
|
LaunchedEffect(isFullScreen) {
|
||||||
|
|||||||
@@ -16,21 +16,17 @@ import androidx.activity.compose.ManagedActivityResultLauncher
|
|||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
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.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.imePadding
|
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.widthIn
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
@@ -101,22 +97,16 @@ internal fun ToolViewScreen(
|
|||||||
) {
|
) {
|
||||||
val (isFullScreen, onFullScreenStateChange) = LocalFullScreen.current
|
val (isFullScreen, onFullScreenStateChange) = LocalFullScreen.current
|
||||||
|
|
||||||
Column(
|
Column(modifier.fillMaxWidth()) {
|
||||||
modifier
|
AnimatedVisibility(!isFullScreen) {
|
||||||
.fillMaxWidth()
|
TopBar(
|
||||||
.windowInsetsPadding(
|
toolViewUiState = toolViewUiState,
|
||||||
WindowInsets.safeDrawing.only(
|
isPreview = isPreview,
|
||||||
WindowInsetsSides.Horizontal
|
isFullScreen = isFullScreen,
|
||||||
)
|
onBackClick = onBackClick,
|
||||||
|
onFullScreenChange = onFullScreenStateChange
|
||||||
)
|
)
|
||||||
) {
|
}
|
||||||
TopBar(
|
|
||||||
toolViewUiState = toolViewUiState,
|
|
||||||
isPreview = isPreview,
|
|
||||||
isFullScreen = isFullScreen,
|
|
||||||
onBackClick = onBackClick,
|
|
||||||
onFullScreenChange = onFullScreenStateChange
|
|
||||||
)
|
|
||||||
Content(
|
Content(
|
||||||
toolViewUiState = toolViewUiState,
|
toolViewUiState = toolViewUiState,
|
||||||
webViewInstanceState = webViewInstanceState
|
webViewInstanceState = webViewInstanceState
|
||||||
|
|||||||
Reference in New Issue
Block a user