Skip to content

Commit 69d880e

Browse files
committed
library: Allow to set the inner and outer margins of the SuperDialog
1 parent 510fede commit 69d880e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/extra/SuperDialog.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.ui.graphics.graphicsLayer
2828
import androidx.compose.ui.input.pointer.pointerInput
2929
import androidx.compose.ui.text.font.FontWeight
3030
import androidx.compose.ui.text.style.TextAlign
31+
import androidx.compose.ui.unit.Dp
3132
import androidx.compose.ui.unit.DpSize
3233
import androidx.compose.ui.unit.dp
3334
import androidx.compose.ui.unit.sp
@@ -51,6 +52,7 @@ import top.yukonga.miuix.kmp.utils.squircleshape.SquircleShape
5152
* @param backgroundColor The background color of the [SuperDialog].
5253
* @param show The state of the [SuperDialog].
5354
* @param onDismissRequest The callback when the [SuperDialog] is dismissed.
55+
* @param outsideMargin The margin outside the [SuperDialog].
5456
* @param insideMargin The margin inside the [SuperDialog].
5557
* @param defaultWindowInsetsPadding Whether to apply default window insets padding to the [SuperDialog].
5658
* @param content The [Composable] content of the [SuperDialog].
@@ -65,17 +67,16 @@ fun SuperDialog(
6567
backgroundColor: Color = MiuixTheme.colorScheme.surfaceVariant,
6668
show: MutableState<Boolean>,
6769
onDismissRequest: () -> Unit,
68-
insideMargin: DpSize? = null,
70+
outsideMargin: DpSize = DpSize(12.dp, 12.dp),
71+
insideMargin: Dp = 24.dp,
6972
defaultWindowInsetsPadding: Boolean = true,
7073
content: @Composable () -> Unit
7174
) {
72-
@Suppress("NAME_SHADOWING")
73-
val insideMargin = remember { insideMargin } ?: remember { DpSize(12.dp, 12.dp) }
74-
val paddingModifier = remember(insideMargin) {
75-
Modifier.padding(horizontal = insideMargin.width).padding(bottom = insideMargin.height)
75+
val paddingModifier = remember(outsideMargin) {
76+
Modifier.padding(horizontal = outsideMargin.width).padding(bottom = outsideMargin.height)
7677
}
7778
val roundedCorner by rememberUpdatedState(getRoundedCorner())
78-
val bottomCornerRadius by remember { derivedStateOf { if (roundedCorner != 0.dp) roundedCorner - insideMargin.width else 32.dp } }
79+
val bottomCornerRadius by remember { derivedStateOf { if (roundedCorner != 0.dp) roundedCorner - outsideMargin.width else 32.dp } }
7980
val getWindowSize by rememberUpdatedState(getWindowSize())
8081
val contentAlignment by remember { derivedStateOf { if (getWindowSize.width > getWindowSize.height) Alignment.Center else Alignment.BottomCenter } }
8182

@@ -119,7 +120,7 @@ fun SuperDialog(
119120
color = backgroundColor,
120121
shape = SquircleShape(bottomCornerRadius)
121122
)
122-
.padding(24.dp),
123+
.padding(insideMargin),
123124
) {
124125
title?.let {
125126
Text(

0 commit comments

Comments
 (0)