简体   繁体   English

如何在 Jetpack Compose 中使底片覆盖整个屏幕

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

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 .我正在使用 Jetpack Compose 并尝试在用户单击TopAppBar的登录按钮时使登录屏幕覆盖整个屏幕。

I am using a combination of ModalBottomSheetLayout and a Scaffold so I can have a TopAppBar and a BottomAppBar .我正在使用ModalBottomSheetLayoutScaffold的组合,所以我可以有一个TopAppBar和一个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.已经坚持了太久,任何帮助表示赞赏。

要使用全屏ModalBottomSheetLayout而不是state.show()使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM