Код: Выделить всё
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun FullScreenPopup(
onDismissRequest: () -> Unit,
content: @Composable () -> Unit,
) {
val context = LocalContext.current
Popup(
onDismissRequest = onDismissRequest,
properties = PopupProperties(
usePlatformDefaultWidth = false,
clippingEnabled = false,
),
popupPositionProvider = object : PopupPositionProvider {
override fun calculatePosition(
anchorBounds: IntRect,
windowSize: IntSize,
layoutDirection: LayoutDirection,
popupContentSize: IntSize
): IntOffset {
return IntOffset.Zero
}
},
) {
Surface(
modifier = Modifier.fillMaxSize(),
content = content,
)
}
DisposableEffect(Unit) {
val window = context.findActivity()?.window ?: return@DisposableEffect onDispose {}
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
insetsController.apply {
hide(WindowInsetsCompat.Type.statusBars())
hide(WindowInsetsCompat.Type.navigationBars())
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
onDispose {
insetsController.apply {
show(WindowInsetsCompat.Type.statusBars())
show(WindowInsetsCompat.Type.navigationBars())
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
}
}
}
}
< /code>
И вот как я хочу использовать его < /p>
FullScreenPopupTestTheme {
var showFullScreenPopup by remember { mutableStateOf(false) }
Scaffold(
modifier = Modifier.fillMaxSize(),
contentWindowInsets = ScaffoldDefaults.contentWindowInsets,
) { innerPadding ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.background(Color.Cyan),
) {
Box(
modifier = Modifier
.size(100.dp)
.align(Alignment.Center)
.background(Color.Yellow)
.clickable { showFullScreenPopup = true },
contentAlignment = Alignment.Center,
) {
Text("Click here")
}
}
}
if (showFullScreenPopup) {
FullScreenPopup(
onDismissRequest = { showFullScreenPopup = false },
) {
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Blue)
.clickable { showFullScreenPopup = false },
)
}
}
}
Вот как это выглядит на Android 14
У кого -нибудь есть идея, как получить его, чтобы охватить весь экран, как на Android 15?>
Подробнее здесь: https://stackoverflow.com/questions/795 ... reen-popup