Created
March 3, 2021 15:27
-
-
Save agarasul/7bac2d686edbb0dc1e62a9f941273956 to your computer and use it in GitHub Desktop.
BottomSheet Composable
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
@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