Fix preview on View having ModalBottomSheet.
This commit is contained in:
parent
b8b6746582
commit
a616790106
1 changed files with 3 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
|
import androidx.compose.ui.platform.LocalInspectionMode
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
@ -58,10 +59,11 @@ fun ModalBottomSheet(
|
||||||
windowInsets: WindowInsets = BottomSheetDefaults.windowInsets,
|
windowInsets: WindowInsets = BottomSheetDefaults.windowInsets,
|
||||||
content: @Composable ColumnScope.() -> Unit,
|
content: @Composable ColumnScope.() -> Unit,
|
||||||
) {
|
) {
|
||||||
|
val safeSheetState = if (LocalInspectionMode.current) sheetStateForPreview() else sheetState
|
||||||
androidx.compose.material3.ModalBottomSheet(
|
androidx.compose.material3.ModalBottomSheet(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
sheetState = sheetState,
|
sheetState = safeSheetState,
|
||||||
shape = shape,
|
shape = shape,
|
||||||
containerColor = containerColor,
|
containerColor = containerColor,
|
||||||
contentColor = contentColor,
|
contentColor = contentColor,
|
||||||
|
|
@ -102,7 +104,6 @@ private fun ContentToPreview() {
|
||||||
) {
|
) {
|
||||||
ModalBottomSheet(
|
ModalBottomSheet(
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
sheetState = sheetStateForPreview(),
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Sheet Content",
|
text = "Sheet Content",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue