Skip to content

Instantly share code, notes, and snippets.

@PriyaSindkar
Created June 26, 2023 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PriyaSindkar/de4d9ed0ece8a42a7448ff2cc9d84130 to your computer and use it in GitHub Desktop.
Save PriyaSindkar/de4d9ed0ece8a42a7448ff2cc9d84130 to your computer and use it in GitHub Desktop.
Modal BottomSheet Demo
var openModalBottomSheet by rememberSaveable { mutableStateOf(false) }
// Modal Sheet content
if (openModalBottomSheet) {
ModalBottomSheet(
onDismissRequest = { openModalBottomSheet = false },
sheetState = bottomSheetState,
scrimColor = Purple40Alpha30,
) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
Button(
// Note: If you provide logic outside of onDismissRequest to remove the sheet,
// you must additionally handle intended state cleanup, if any.
onClick = {
scope.launch { bottomSheetState.hide() }.invokeOnCompletion {
if (!bottomSheetState.isVisible) {
openModalBottomSheet = false
}
}
}
) {
Text("Hide Bottom Sheet")
}
}
LazyColumn(
modifier = Modifier.fillMaxWidth(),
content = {
items(6) {
Text(
"Info Item ${it + 1}",
modifier = Modifier.fillMaxWidth().padding(8.dp),
)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment