Created
June 26, 2023 11:23
-
-
Save PriyaSindkar/de4d9ed0ece8a42a7448ff2cc9d84130 to your computer and use it in GitHub Desktop.
Modal BottomSheet Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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