ms
07/17/2021, 2:55 AMBottomSheetScaffold
it closes right away
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetContent = {
LazyColumn {
items(count = 10) {
Text(
text = "Item $it",
modifier = Modifier.padding(vertical = 8.dp)
)
}
}
},
) {
Box(
modifier = Modifier.fillMaxSize().padding(it),
contentAlignment = Alignment.Center
) {
Button(
onClick = {
coroutineScope.launch {
bottomSheetScaffoldState.bottomSheetState.expand()
}
},
) {
Text(text = "Open sheet")
}
}
}
Albert Chang
07/17/2021, 3:01 AMbottomSheetScaffoldState
?Albert Chang
07/17/2021, 3:01 AMms
07/17/2021, 3:03 AMrememberBottomSheetScaffoldState(
bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed),
)
Albert Chang
07/17/2021, 3:04 AMBottomSheetState
so it is a new instance on every recomposition. Use rememberBottomSheetState
.ms
07/17/2021, 3:07 AMms
07/17/2021, 3:09 AMModalBottomSheetLayout
has a scrimColor whereas BottomSheetScaffold
don't
How to add a scrimColor to BottomSheetScaffold?Albert Chang
07/19/2021, 4:28 AMBottomSheetScaffold
allows interaction with the rest of the screen so scrim color shouldn't be used. If you want to block interaction, just use ModalBottomSheetLayout
.