admin管理员组

文章数量:1314514

So I'm trying to define BottomSheet as navigation routes using compose.material.navigation.bottomSheet based on the example from official docs:

val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)

ModalBottomSheetLayout(bottomSheetNavigator) {
    NavHost(navController, Destinations.Home) {
        composable(Destinations.Home) {
            HomeScreen(
                showSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=From Home Screen")
                },
                showFeed = { navController.navigate(Destinations.Feed) }
            )
        }
        composable(Destinations.Feed) { Text("Feed!") }
        bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry ->
            val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :("
            BottomSheet(
                showFeed = { navController.navigate(Destinations.Feed) },
                showAnotherSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}")
                },
                arg = arg
            )
        }
    }
}

but it gives this warning

Using a material import while also using the material3 library

and I can't find out if such functionality available withing material3 libraries

So I'm trying to define BottomSheet as navigation routes using compose.material.navigation.bottomSheet based on the example from official docs:

val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)

ModalBottomSheetLayout(bottomSheetNavigator) {
    NavHost(navController, Destinations.Home) {
        composable(Destinations.Home) {
            HomeScreen(
                showSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=From Home Screen")
                },
                showFeed = { navController.navigate(Destinations.Feed) }
            )
        }
        composable(Destinations.Feed) { Text("Feed!") }
        bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry ->
            val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :("
            BottomSheet(
                showFeed = { navController.navigate(Destinations.Feed) },
                showAnotherSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}")
                },
                arg = arg
            )
        }
    }
}

but it gives this warning

Using a material import while also using the material3 library

and I can't find out if such functionality available withing material3 libraries

Share Improve this question edited Jan 30 at 13:33 user924 asked Jan 30 at 13:13 user924user924 12.3k12 gold badges88 silver badges190 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Please have a look at Ticket #328949006 at the Google Issue Tracker. It seems that this functionality is currently not supported with Material3, but there are some alternatives:

  • Library by Hrach on GitHub
  • Library by EyGraber on GitHub
  • Snippet by FlaringApp on GitHub (only supports navigating to one BottomSheet at a time)

You can star the issue in the Issue Tracker and leave a comment to draw more attention to it.

This just means you are mixing Material2 and Material3 components.

本文标签: