Created
December 6, 2022 15:01
-
-
Save MrNtlu/31c9b0aae5de70321bc719b1b62f7732 to your computer and use it in GitHub Desktop.
Bottom Sheet Activity Skeleton
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
@Composable | |
fun BottomSheetLayout() { | |
val coroutineScope = rememberCoroutineScope() | |
val modalSheetState = rememberModalBottomSheetState( | |
initialValue = ModalBottomSheetValue.Hidden, | |
confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded }, | |
skipHalfExpanded = true | |
) | |
ModalBottomSheetLayout( | |
sheetState = modalSheetState, | |
sheetContent = { | |
Column( | |
//... | |
) { | |
Button( | |
onClick = { | |
coroutineScope.launch { modalSheetState.hide() } | |
} | |
) { | |
Text(text = "Hide Sheet") | |
} | |
} | |
} | |
) { | |
Scaffold { | |
Box( | |
modifier = Modifier | |
.fillMaxSize(), | |
contentAlignment = Alignment.Center, | |
) { | |
Button( | |
onClick = { | |
coroutineScope.launch { | |
if (modalSheetState.isVisible) | |
modalSheetState.hide() | |
else | |
modalSheetState.animateTo(ModalBottomSheetValue.Expanded) | |
} | |
}, | |
) { | |
Text(text = "Open Sheet") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment