Shakil Karim
04/23/2022, 5:04 PMcloseSheet
and openSheet
inside Composable because Main can recompose very often?
@Composable
fun Main() {
val closeSheet: () -> Unit = {
scope.launch {
scaffoldState.bottomSheetState.collapse()
}
}
val openSheet: (BottomSheetScreen) -> Unit = {
currentBottomSheet = it
scope.launch {
delay(100)
scaffoldState.bottomSheetState.expand()
}
}
if (scaffoldState.bottomSheetState.isCollapsed)
currentBottomSheet = null
}
andrew
04/24/2022, 3:41 PMjossiwolf
04/25/2022, 9:36 AMcurrentBottomSheet
(or mutating any state's value as a matter of fact) is a side effect and should be declared as one. Creating the lambdas like that is fine though you could remember
them with the appropriate keys to make it a bit more efficient.