Satyam G
05/30/2022, 7:36 AMste
05/30/2022, 8:22 AMit is needed just attach to window and display it on any composableNot sure you can do this with material's
BottomSheet
, however this is the idea:
Box {
val customBottomSheetState = rememberCustomBottomSheetState()
CompositionLocalProvider(
LocalCustomBottomSheetState provides customBottomSheetState
) {
// or whatever, this is the entry point of your UI
HostScreen()
}
CustomBottomSheet(customBottomSheetState)
}
@Composable
fun CustomBottomSheet(state: CustomBottomSheetState) {
if (state.isDisplayed) {
state.content()
}
}
class CustomBottomSheetState {
var isDisplayed by mutableStateOf(false)
var content: @Composable () -> Unit = {}
fun display(content: @Composable () -> Unit) {
this.content = content
isDisplayed = true
}
}
However I'm not quite sure this is a good practice. Also, you'd need your own logic to handle configuration changes.Satyam G
05/30/2022, 8:24 AM