I want to reduce BottomSheet height smoothly. When increasing, it increase its height smoothly, but when decreasing, it decreases not smoothly. (as you can see from the video at the down part) Is there any way to decrease the height of bottom sheet smoothly?
val scaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = sheetState
)
val scope = rememberCoroutineScope()
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetContent = {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// I am changing the visibility at this part.
AnimatedVisibility(
visible = viewModel.sheetState.isIconVisible,
exit = scaleOut()
) {
Image(
painter = painterResource(R.drawable.ic_sunny),
contentDescription = null
)
}
Text(
text = viewModel.sheetState.firstQuestion,
fontSize = 20.sp
)
if (viewModel.sheetState.secondQuestion.isNotEmpty()) {
Text(
text = viewModel.sheetState.firstQuestion,
fontSize = 20.sp
)
}
}
},
sheetBackgroundColor = Color.Green,
sheetPeekHeight = 0.dp
) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Button(onClick = { viewModel.changeVisibility() }) {
Text(text = "Change Visibility")
}
Button(onClick = {
scope.launch {
if (sheetState.isCollapsed) {
sheetState.expand()
} else {
sheetState.collapse()
}
}
}) {
Text(text = "Bottom sheet fraction: ${sheetState.progress.fraction}")
}
}
}
Edit
The image is going smaller but the bottom sheet isn't getting smaller as the image decrease. Whenever the image gets smaller, I want the bottom sheet to get smaller at the same time.
