Fix z order of popups
This commit is contained in:
parent
5a821eaabe
commit
e08e9a370c
@ -66,6 +66,7 @@ import androidx.compose.ui.window.Popup
|
|||||||
import androidx.compose.ui.window.PopupPositionProvider
|
import androidx.compose.ui.window.PopupPositionProvider
|
||||||
import androidx.compose.ui.window.PopupProperties
|
import androidx.compose.ui.window.PopupProperties
|
||||||
import de.mm20.launcher2.ui.ktx.toPixels
|
import de.mm20.launcher2.ui.ktx.toPixels
|
||||||
|
import de.mm20.launcher2.ui.overlays.LocalZIndex
|
||||||
import de.mm20.launcher2.ui.overlays.Overlay
|
import de.mm20.launcher2.ui.overlays.Overlay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -79,6 +80,7 @@ fun BottomSheetDialog(
|
|||||||
confirmButton: @Composable (() -> Unit)? = null,
|
confirmButton: @Composable (() -> Unit)? = null,
|
||||||
dismissButton: @Composable (() -> Unit)? = null,
|
dismissButton: @Composable (() -> Unit)? = null,
|
||||||
dismissible: () -> Boolean = { true },
|
dismissible: () -> Boolean = { true },
|
||||||
|
zIndex: Float = LocalZIndex.current + 1f,
|
||||||
content: @Composable (paddingValues: PaddingValues) -> Unit,
|
content: @Composable (paddingValues: PaddingValues) -> Unit,
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
@ -155,13 +157,7 @@ fun BottomSheetDialog(
|
|||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalAbsoluteTonalElevation provides 0.dp,
|
LocalAbsoluteTonalElevation provides 0.dp,
|
||||||
) {
|
) {
|
||||||
val density = LocalDensity.current
|
Overlay(zIndex = zIndex) {
|
||||||
val insets = WindowInsets.systemBars
|
|
||||||
WindowInsets
|
|
||||||
val positionProvider = remember(insets, density) {
|
|
||||||
BottomSheetPositionProvider(insets, density)
|
|
||||||
}
|
|
||||||
Overlay(zIndex = 9999f) {
|
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
|||||||
@ -207,7 +207,7 @@ fun ItemPopup(origin: Rect, searchable: Searchable, onDismissRequest: () -> Unit
|
|||||||
show.targetState = false
|
show.targetState = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlay(zIndex = 1f) {
|
Overlay {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.background(MaterialTheme.colorScheme.scrim.copy(alpha = 0.32f * animationProgress.value))
|
.background(MaterialTheme.colorScheme.scrim.copy(alpha = 0.32f * animationProgress.value))
|
||||||
|
|||||||
@ -92,7 +92,8 @@ fun CustomizeSearchableSheet(
|
|||||||
Text(stringResource(id = android.R.string.cancel))
|
Text(stringResource(id = android.R.string.cancel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else null
|
} else null,
|
||||||
|
zIndex = 100f,
|
||||||
) {
|
) {
|
||||||
if (!pickIcon) {
|
if (!pickIcon) {
|
||||||
Column(
|
Column(
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import androidx.compose.runtime.DisposableEffect
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Overlay(
|
fun Overlay(
|
||||||
zIndex: Float = 0f,
|
zIndex: Float = LocalZIndex.current + 1f,
|
||||||
overlay: @Composable () -> Unit
|
overlay: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
val overlayManager = LocalOverlayManager.current
|
val overlayManager = LocalOverlayManager.current
|
||||||
|
|||||||
@ -26,8 +26,12 @@ fun OverlayHost(
|
|||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
for (overlay in overlayManager.overlays) {
|
for (overlay in overlayManager.overlays) {
|
||||||
Box(modifier = Modifier.zIndex(overlay.zIndex + 1f)) {
|
Box(modifier = Modifier.zIndex(overlay.zIndex)) {
|
||||||
overlay()
|
CompositionLocalProvider(
|
||||||
|
LocalZIndex provides overlay.zIndex
|
||||||
|
) {
|
||||||
|
overlay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,4 +40,8 @@ fun OverlayHost(
|
|||||||
|
|
||||||
val LocalOverlayManager = compositionLocalOf<OverlayManager> {
|
val LocalOverlayManager = compositionLocalOf<OverlayManager> {
|
||||||
OverlayManager()
|
OverlayManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
val LocalZIndex = compositionLocalOf<Float> {
|
||||||
|
0f
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user