In Jetpack Compose, I have a BottomSheetScaffold with some content. This content is observed from the ViewModel, like this:
BottomSheetScaffold(
sheetContent = { SheetContent(sheetData = viewModel.sheetData) }
) {}
So whenever viewModel.sheetData changes, a recomposition is triggered. Whenever this happens, the bottom sheet automatically expands. Is this a bug or a feature? Can I disable this? I am using the newest version: 1.1.0-alpha01
Edit: Here is an example using LaunchedEffect instead of a ViewModel.
@OptIn(ExperimentalMaterialApi::class)
@Preview
@Composable
fun HomeScreen() {
var addSheetData by remember { mutableStateOf(false) }
LaunchedEffect(true) {
delay(2000)
addSheetData = true
}
BottomSheetScaffold(sheetContent = {
if (addSheetData) {
Column {
Text(text = "Text1", fontSize = 36.sp)
Text(text = "Text2", fontSize = 36.sp)
Text(text = "Text3", fontSize = 36.sp)
Text(text = "Text4", fontSize = 36.sp)
Text(text = "Text5", fontSize = 36.sp)
}
}
}, sheetBackgroundColor = Color.LightGray) {}
}
The sheet with the 5 texts expands automatically.