I am trying to display a modal BottomSheet, which requires a parameter. This is how I show BottomSheet: bottomSheetState.animateTo(ModalBottomSheetValue.Expanded)
And this is my set-up:
@Composable
fun MainView() {
val navController = rememberNavController()
val modalBottomSheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
confirmStateChange = {
it != ModalBottomSheetValue.HalfExpanded
}
)
ModalBottomSheetLayout(
sheetState = modalBottomSheetState,
sheetContent = {
AnimationScreen()
},
sheetShape = RoundedCornerShape(topStart = Radius.l, topEnd = Radius.l)
) {
Scaffold(
bottomBar = {
BottomBar(navController)
}
) {
BottomBarMain(navController, modalBottomSheetState)
}
}
}
So, my question is: what is a good way to pass a parameter to this ModalBottomSheet.
I have a possible solution, but I don't know if it is a proper way to do it. Here how it looks like:
var animationId by remember { mutableStateOf(-1L) }
...
sheetContent = {
AnimationScreen(animationId)
}
...
BottomBarMain(navController, modalBottomSheetState) {
animationId = it
}