Skip to content

Commit 97bf93e

Browse files
committed
library: SuperBottomSheet: Add sheetMaxWidth param
1 parent f60d428 commit 97bf93e

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

docs/components/superbottomsheet.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Scaffold {
5353
| backgroundColor | Color | Bottom sheet background color | SuperBottomSheetDefaults.backgroundColor() | No |
5454
| enableWindowDim | Boolean | Whether to enable dimming layer | true | No |
5555
| cornerRadius | Dp | Corner radius of the top corners | SuperBottomSheetDefaults.cornerRadius | No |
56+
| sheetMaxWidth | Dp | Maximum width of the bottom sheet | SuperBottomSheetDefaults.sheetMaxWidth | No |
5657
| onDismissRequest | (() -> Unit)? | Callback when bottom sheet is dismissed | null | No |
5758
| outsideMargin | DpSize | Bottom sheet external margin | SuperBottomSheetDefaults.outsideMargin | No |
5859
| insideMargin | DpSize | Bottom sheet internal content margin | SuperBottomSheetDefaults.insideMargin | No |
@@ -69,6 +70,7 @@ The SuperBottomSheetDefaults object provides default settings for the SuperBotto
6970
| Property Name | Type | Description |
7071
| -------------- | ------ | -------------------------------------- |
7172
| cornerRadius | Dp | Default corner radius (28.dp) |
73+
| sheetMaxWidth | Dp | Default maximum width (640.dp) |
7274
| outsideMargin | DpSize | Default bottom sheet external margin |
7375
| insideMargin | DpSize | Default bottom sheet internal margin |
7476

docs/zh_CN/components/superbottomsheet.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Scaffold {
5353
| backgroundColor | Color | 底部抽屉背景色 | SuperBottomSheetDefaults.backgroundColor() ||
5454
| enableWindowDim | Boolean | 是否启用遮罩层 | true ||
5555
| cornerRadius | Dp | 顶部圆角半径 | SuperBottomSheetDefaults.cornerRadius ||
56+
| sheetMaxWidth | Dp | 底部抽屉的最大宽度 | SuperBottomSheetDefaults.sheetMaxWidth ||
5657
| onDismissRequest | (() -> Unit)? | 底部抽屉关闭时的回调函数 | null ||
5758
| outsideMargin | DpSize | 底部抽屉外部边距 | SuperBottomSheetDefaults.outsideMargin ||
5859
| insideMargin | DpSize | 底部抽屉内部内容的边距 | SuperBottomSheetDefaults.insideMargin ||
@@ -69,6 +70,7 @@ SuperBottomSheetDefaults 对象提供了 SuperBottomSheet 组件的默认设置
6970
| 属性名 | 类型 | 说明 |
7071
| ------------- | ------ | --------------------------- |
7172
| cornerRadius | Dp | 默认圆角半径 (28.dp) |
73+
| sheetMaxWidth | Dp | 默认最大宽度 (640.dp) |
7274
| outsideMargin | DpSize | 底部抽屉外部默认边距 |
7375
| insideMargin | DpSize | 底部抽屉内部默认边距 |
7476

iosApp/iosApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0.4</string>
1919
<key>CFBundleVersion</key>
20-
<string>562</string>
20+
<string>563</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>CADisableMinimumFrameDurationOnPhone</key>

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.imePadding
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.foundation.layout.statusBars
2121
import androidx.compose.foundation.layout.width
22+
import androidx.compose.foundation.layout.widthIn
2223
import androidx.compose.foundation.layout.wrapContentHeight
2324
import androidx.compose.runtime.Composable
2425
import 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
*/

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,14 @@ private fun SuperDialogContent(
195195
.then(
196196
// Apply predictive back animation
197197
if (isLargeScreen) {
198-
// Large screen: scale and fade out
198+
// Large screen
199199
Modifier.graphicsLayer {
200200
val scale = 1f - (backProgress * 0.2f)
201201
scaleX = scale
202202
scaleY = scale
203-
alpha = 1f - (backProgress * 0.5f)
204203
}
205204
} else {
206-
// Small screen: slide down
205+
// Small screen
207206
Modifier.graphicsLayer {
208207
translationY = backProgress * 800f
209208
}

0 commit comments

Comments
 (0)