Skip to content

Instantly share code, notes, and snippets.

@agarasul
Created March 3, 2021 15:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agarasul/7bac2d686edbb0dc1e62a9f941273956 to your computer and use it in GitHub Desktop.
Save agarasul/7bac2d686edbb0dc1e62a9f941273956 to your computer and use it in GitHub Desktop.
BottomSheet Composable
@ExperimentalMaterialApi
@Composable
fun HomeScreen() {
val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed)
)
val coroutineScope = rememberCoroutineScope()
BottomSheetScaffold(
scaffoldState = bottomSheetScaffoldState,
sheetContent = {
Box(
Modifier
.fillMaxWidth()
.height(200.dp)
) {
Text(text = "Hello from sheet")
}
}, sheetPeekHeight = 0.dp
) {
Button(onClick = {
coroutineScope.launch {
if (bottomSheetScaffoldState.bottomSheetState.isCollapsed) {
bottomSheetScaffoldState.bottomSheetState.expand()
} else {
bottomSheetScaffoldState.bottomSheetState.collapse()
}
}
}) {
Text(text = "Expand/Collapse Bottom Sheet")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment