Modal Bottom sheets
Use these Jetpack Compose Modal Bottom Sheets to prompt the user to make a decision when needed
Simple Modal Bottom Sheet
/** * Add the following dependency to your build.gradle.kts: * * dependencies { * implementation("com.composables:core:1.11.2") * implementation("com.composables:icons-lucide:1.0.0") * } */ val Peek = remember { SheetDetent("peek") { containerHeight, sheetHeight -> containerHeight * 0.6f } } BoxWithConstraints(modifier = Modifier.fillMaxSize()) { val state = rememberModalBottomSheetState( initialDetent = Peek, detents = listOf(Hidden, Peek, FullyExpanded) ) val isCompact = maxWidth < 600.dp LaunchedEffect(state.isIdle) { if (state.isIdle && state.targetDetent == Hidden) { delay(500) state.currentDetent = Peek } } ModalBottomSheet(state = state) { Scrim(scrimColor = Color.Black.copy(0.3f), enter = fadeIn(), exit = fadeOut()) Sheet( modifier = Modifier .padding(top = 12.dp) .let { if (isCompact) it else it.padding(horizontal = 56.dp) } .statusBarsPadding() .padding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal).asPaddingValues()) .shadow(4.dp, RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp)) .clip(RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp)) .background(Color.White) .widthIn(max = 640.dp) .fillMaxWidth() .imePadding(), ) { Box(Modifier.fillMaxWidth().height(600.dp), contentAlignment = Alignment.TopCenter) { DragIndication( modifier = Modifier.padding(top = 22.dp) .background(Color.Black.copy(0.4f), ComposeTheme.shapes.roundFull) .width(32.dp) .height(4.dp) ) } } } }
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
Phone
Sit tight. We are loading your preview
Simple Modal Bottom Sheet