How do I make Bottom Sheet cover whole screen in Jetpack Compose

Viewed 3583

I am using Jetpack Compose and trying to make a Login Screen cover the whole screen when the user clicks the login button in the TopAppBar.

I am using a combination of ModalBottomSheetLayout and a Scaffold so I can have a TopAppBar and a BottomAppBar.

Currently when the login screen is displayed it only covers half of the screen.

                       val coroutineScope = rememberCoroutineScope()
                        val bottomState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
                        ModalBottomSheetLayout(
                            sheetState = bottomState,
                            sheetShape = MaterialTheme.shapes.large,
                            sheetContent = {
                                FullScreen()
                            }
                        ) {

                            Scaffold(
                                topBar = {
                                    TopAppBar(
...
                                content = {

                                    NavHost(navController = navController,
                                        startDestination = "journey") {
                                        composable("journey") { JourneyScreen() }
...
                               bottomBar = {
                                    BottomAppBar(
                                        content = {
                                            BottomNavigation() {

                                                val navBackStackEntry by navController.currentBackStackEntryAsState()
...

@Composable
fun FullScreen() {
    Box(modifier = Modifier
        .fillMaxSize()
    ) {
        Text("Full Screen")
    }
}

Have been stuck on this for way too long and any help is appreciated.

1 Answers

To have a fullscreen ModalBottomSheetLayout, instead of state.show() use:

scope.launch { state.animateTo(ModalBottomSheetValue.Expanded) }
Related