Fix z order of popups

This commit is contained in:
MM20 2023-10-01 21:35:36 +02:00
parent 5a821eaabe
commit e08e9a370c
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
5 changed files with 17 additions and 12 deletions

View File

@ -66,6 +66,7 @@ import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupPositionProvider
import androidx.compose.ui.window.PopupProperties
import de.mm20.launcher2.ui.ktx.toPixels
import de.mm20.launcher2.ui.overlays.LocalZIndex
import de.mm20.launcher2.ui.overlays.Overlay
import kotlinx.coroutines.launch
import kotlin.math.min
@ -79,6 +80,7 @@ fun BottomSheetDialog(
confirmButton: @Composable (() -> Unit)? = null,
dismissButton: @Composable (() -> Unit)? = null,
dismissible: () -> Boolean = { true },
zIndex: Float = LocalZIndex.current + 1f,
content: @Composable (paddingValues: PaddingValues) -> Unit,
) {
val scope = rememberCoroutineScope()
@ -155,13 +157,7 @@ fun BottomSheetDialog(
CompositionLocalProvider(
LocalAbsoluteTonalElevation provides 0.dp,
) {
val density = LocalDensity.current
val insets = WindowInsets.systemBars
WindowInsets
val positionProvider = remember(insets, density) {
BottomSheetPositionProvider(insets, density)
}
Overlay(zIndex = 9999f) {
Overlay(zIndex = zIndex) {
BoxWithConstraints(
modifier = Modifier
.fillMaxSize()

View File

@ -207,7 +207,7 @@ fun ItemPopup(origin: Rect, searchable: Searchable, onDismissRequest: () -> Unit
show.targetState = false
}
Overlay(zIndex = 1f) {
Overlay {
Box(
modifier = Modifier
.background(MaterialTheme.colorScheme.scrim.copy(alpha = 0.32f * animationProgress.value))

View File

@ -92,7 +92,8 @@ fun CustomizeSearchableSheet(
Text(stringResource(id = android.R.string.cancel))
}
}
} else null
} else null,
zIndex = 100f,
) {
if (!pickIcon) {
Column(

View File

@ -5,7 +5,7 @@ import androidx.compose.runtime.DisposableEffect
@Composable
fun Overlay(
zIndex: Float = 0f,
zIndex: Float = LocalZIndex.current + 1f,
overlay: @Composable () -> Unit
) {
val overlayManager = LocalOverlayManager.current

View File

@ -26,8 +26,12 @@ fun OverlayHost(
content()
}
for (overlay in overlayManager.overlays) {
Box(modifier = Modifier.zIndex(overlay.zIndex + 1f)) {
overlay()
Box(modifier = Modifier.zIndex(overlay.zIndex)) {
CompositionLocalProvider(
LocalZIndex provides overlay.zIndex
) {
overlay()
}
}
}
}
@ -36,4 +40,8 @@ fun OverlayHost(
val LocalOverlayManager = compositionLocalOf<OverlayManager> {
OverlayManager()
}
val LocalZIndex = compositionLocalOf<Float> {
0f
}