I want to make navigation in BottomSheetScaffold that involves constant content change and I wanted the bottom shield to smoothly handle resizing for this in the root composable, I use Modifier.animateContentSize(). In BottomSheetScaffold, I would like to implement the logic of opening one of the Boxes when pulling the BottomSheetScaffold, and then the entire ui begins to display incorrectly, the bottom Box jumps as shown in the video. Without Modifier.animateContentSize(), everything works as it should, but then when changing the content of the BottomSheetScaffold, the state changes dramatically. Are there any ideas on how to fix it? And why is this happening?
BottomSheet
var boxHeight by remember { mutableStateOf(0.dp) }
BottomSheetScaffold(
scaffoldState = rememberBottomSheetScaffoldState(
rememberStandardBottomSheetState(
initialValue = SheetValue.Expanded
)
),
sheetContent = {
Column(
modifier = Modifier
.animateContentSize()
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.Green)
.draggable(
orientation = Orientation.Vertical,
state = rememberDraggableState { delta ->
boxHeight -= delta.dp
}
)
) {
Text(text = "boxHeight $boxHeightn")
}
Box(
modifier = Modifier
.height(boxHeight)
.fillMaxWidth()
.background(Color.Blue)
)
Box(
modifier = Modifier
.fillMaxWidth()
.height(400.dp)
.background(Color.Gray)
)
}
},
) {
}
I tried to use AnimatedVisability, but it seems to be for other tasks.