Skip to content

Commit fb00557

Browse files
committed
library: Add windowDimming param to PopupUtil
1 parent b665cfd commit fb00557

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

composeApp/src/commonMain/kotlin/UITest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ fun UITest(
230230
alignment = PopupPositionProvider.Align.BottomRight,
231231
onDismissRequest = {
232232
isBottomPopupExpanded.value = false
233-
}
233+
},
234+
windowDimming = false
234235
) {
235236
ListPopupColumn {
236237
items.take(3).forEachIndexed { index, navigationItem ->

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ android-minSdk = "26"
33
android-compileSdk = "35"
44
android-targetSdk = "35"
55

6-
androidGradlePlugin = "8.7.3"
6+
androidGradlePlugin = "8.8.0"
77
androidx-activity-compose = "1.9.3"
88
androidx-window = "1.3.0"
99
compose-plugin = "1.7.3"

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/ListPopup.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fun ListPopup(
6666
popupModifier: Modifier = Modifier,
6767
popupPositionProvider: PopupPositionProvider = ListPopupDefaults.DropdownPositionProvider,
6868
alignment: PopupPositionProvider.Align = PopupPositionProvider.Align.Right,
69+
windowDimming: Boolean = true,
6970
onDismissRequest: (() -> Unit)? = null,
7071
maxHeight: Dp? = null,
7172
content: @Composable () -> Unit
@@ -143,7 +144,8 @@ fun ListPopup(
143144
11.dp.toPx()
144145
})
145146
showPopup(
146-
transformOrigin = { transformOrigin }
147+
transformOrigin = { transformOrigin },
148+
windowDimming = windowDimming,
147149
) {
148150
Box(
149151
modifier = popupModifier

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/utils/MiuixPopupUtil.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class MiuixPopupUtil {
3838
companion object {
3939
private var isPopupShowing = mutableStateOf(false)
4040
private var isDialogShowing = mutableStateOf(false)
41+
private var isWindowDimming = mutableStateOf(false)
4142
private var popupContext = mutableStateOf<(@Composable () -> Unit)?>(null)
4243
private var dialogContext = mutableStateOf<(@Composable () -> Unit)?>(null)
4344
private var popupTransformOrigin = mutableStateOf({ TransformOrigin.Center })
@@ -73,16 +74,19 @@ class MiuixPopupUtil {
7374
*
7475
* @param transformOrigin The pivot point in terms of fraction of the overall size,
7576
* used for scale transformations. By default it's [TransformOrigin.Center].
77+
* @param windowDimming Whether to dim the window when the popup is showing.
7678
* @param content The [Composable] content of the popup.
7779
*/
7880
@Composable
7981
fun showPopup(
8082
transformOrigin: (() -> TransformOrigin) = { TransformOrigin.Center },
83+
windowDimming: Boolean = true,
8184
content: (@Composable () -> Unit)? = null,
8285
) {
8386
if (isPopupShowing.value) return
8487
popupTransformOrigin.value = transformOrigin
8588
isPopupShowing.value = true
89+
isWindowDimming.value = windowDimming
8690
popupContext.value = content
8791
}
8892

@@ -118,7 +122,7 @@ class MiuixPopupUtil {
118122
dimExitDuration = 150
119123
}
120124
AnimatedVisibility(
121-
visible = isDialogShowing.value || isPopupShowing.value,
125+
visible = (isDialogShowing.value || isPopupShowing.value) && isWindowDimming.value,
122126
modifier = Modifier.zIndex(1f).fillMaxSize(),
123127
enter = fadeIn(animationSpec = tween(dimEnterDuration, easing = DecelerateEasing(1.5f))),
124128
exit = fadeOut(animationSpec = tween(dimExitDuration, easing = DecelerateEasing(1.5f)))
@@ -165,7 +169,7 @@ class MiuixPopupUtil {
165169
dialogContext.value?.invoke()
166170
}
167171
AnimatedVisibility(
168-
visible = isPopupShowing.value && isDialogShowing.value,
172+
visible = isPopupShowing.value && isDialogShowing.value && isWindowDimming.value,
169173
modifier = Modifier.zIndex(1f).fillMaxSize(),
170174
) {
171175
Box(

0 commit comments

Comments
 (0)