@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.imePadding
1919import androidx.compose.foundation.layout.padding
2020import androidx.compose.foundation.layout.statusBars
2121import androidx.compose.foundation.layout.width
22+ import androidx.compose.foundation.layout.widthIn
2223import androidx.compose.foundation.layout.wrapContentHeight
2324import androidx.compose.runtime.Composable
2425import androidx.compose.runtime.MutableState
@@ -62,6 +63,7 @@ import top.yukonga.miuix.kmp.utils.getWindowSize
6263 * @param backgroundColor The background color of the [SuperBottomSheet].
6364 * @param enableWindowDim Whether to dim the window behind the [SuperBottomSheet].
6465 * @param cornerRadius The corner radius of the top corners of the [SuperBottomSheet].
66+ * @param sheetMaxWidth The maximum width of the [SuperBottomSheet].
6567 * @param onDismissRequest The callback when the [SuperBottomSheet] is dismissed.
6668 * @param outsideMargin The margin outside the [SuperBottomSheet].
6769 * @param insideMargin The margin inside the [SuperBottomSheet].
@@ -79,6 +81,7 @@ fun SuperBottomSheet(
7981 backgroundColor : Color = SuperBottomSheetDefaults .backgroundColor(),
8082 enableWindowDim : Boolean = true,
8183 cornerRadius : Dp = SuperBottomSheetDefaults .cornerRadius,
84+ sheetMaxWidth : Dp = SuperBottomSheetDefaults .maxWidth,
8285 onDismissRequest : (() -> Unit )? = null,
8386 outsideMargin : DpSize = SuperBottomSheetDefaults .outsideMargin,
8487 insideMargin : DpSize = SuperBottomSheetDefaults .insideMargin,
@@ -107,6 +110,7 @@ fun SuperBottomSheet(
107110 rightAction = rightAction,
108111 backgroundColor = backgroundColor,
109112 cornerRadius = cornerRadius,
113+ sheetMaxWidth = sheetMaxWidth,
110114 outsideMargin = outsideMargin,
111115 insideMargin = insideMargin,
112116 defaultWindowInsetsPadding = defaultWindowInsetsPadding,
@@ -131,7 +135,7 @@ fun SuperBottomSheet(
131135 }
132136 val offset = event.progress * maxOffset
133137 dragOffsetY.snapTo(offset)
134-
138+
135139 // Update dim alpha
136140 dimAlpha.value = 1f - event.progress
137141 }
@@ -157,6 +161,7 @@ private fun SuperBottomSheetContent(
157161 rightAction : @Composable (() -> Unit? )? = null,
158162 backgroundColor : Color ,
159163 cornerRadius : Dp ,
164+ sheetMaxWidth : Dp ,
160165 outsideMargin : DpSize ,
161166 insideMargin : DpSize ,
162167 defaultWindowInsetsPadding : Boolean ,
@@ -195,6 +200,7 @@ private fun SuperBottomSheetContent(
195200 rightAction = rightAction,
196201 backgroundColor = backgroundColor,
197202 cornerRadius = cornerRadius,
203+ sheetMaxWidth = sheetMaxWidth,
198204 outsideMargin = outsideMargin,
199205 insideMargin = insideMargin,
200206 defaultWindowInsetsPadding = defaultWindowInsetsPadding,
@@ -219,6 +225,7 @@ private fun SuperBottomSheetColumn(
219225 rightAction : @Composable (() -> Unit? )? ,
220226 backgroundColor : Color ,
221227 cornerRadius : Dp ,
228+ sheetMaxWidth : Dp ,
222229 outsideMargin : DpSize ,
223230 insideMargin : DpSize ,
224231 defaultWindowInsetsPadding : Boolean ,
@@ -243,6 +250,7 @@ private fun SuperBottomSheetColumn(
243250 .pointerInput(Unit ) {
244251 detectTapGestures { /* Consume click to prevent dismissal */ }
245252 }
253+ .widthIn(max = sheetMaxWidth)
246254 .fillMaxWidth()
247255 .wrapContentHeight()
248256 .heightIn(max = windowHeight - statusBarHeight)
@@ -413,6 +421,11 @@ object SuperBottomSheetDefaults {
413421 */
414422 val cornerRadius = 28 .dp
415423
424+ /* *
425+ * The default maximum width of the [SuperBottomSheet].
426+ */
427+ val maxWidth = 640 .dp
428+
416429 /* *
417430 * The default margin outside the [SuperBottomSheet].
418431 */
0 commit comments