Piotr Prus
08/03/2022, 10:24 AMPiotr Prus
08/03/2022, 10:25 AM@OptIn(ExperimentalMaterialNavigationApi::class, ExperimentalMaterialApi::class)
@Composable
fun NavigationTest() {
val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
com.google.accompanist.navigation.material.ModalBottomSheetLayout(
scrimColor = Color.Unspecified,
bottomSheetNavigator = bottomSheetNavigator
) {
NavHost(navController = navController, startDestination = "home") {
composable("home") {
Scaffold { paddingValues ->
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Gray)
.padding(paddingValues)
) {
Button(onClick = { navController.navigate("detail") }) {
Text(text = "Open detail")
}
}
}
}
bottomSheet("detail") {
Column {
Button(onClick = { navController.navigate("test") }) {
Text(text = "Navigate to screen")
}
repeat(20) {
Text(modifier = Modifier.padding(8.dp), text = "This is detail: $it")
}
}
}
composable("test") {
Scaffold { paddingValues ->
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.Blue)
.padding(paddingValues)
)
}
}
}
}
}
Colton Idle
08/03/2022, 12:39 PMPiotr Prus
08/03/2022, 12:41 PMColton Idle
08/03/2022, 12:59 PMColton Idle
08/03/2022, 12:59 PMPiotr Prus
08/03/2022, 1:34 PMPiotr Prus
08/03/2022, 8:22 PMjossiwolf
08/05/2022, 8:46 AMDestinations that implement this interface will automatically be popped off the back stack when you navigate to a new destination.UX-wise it feels a bit weird to go from a non-floating destination back to a floating destination. We don't support it, sorry!
Piotr Prus
08/05/2022, 9:05 AMDiscover
, the bottomSheet will appear with a lot of content. After clicking in one of items the app opens new destination, but when you go back, the discover(bottomSheet) is still opened. I am looking for such behaviour.jossiwolf
08/05/2022, 10:27 AMPiotr Prus
08/05/2022, 10:38 AMBottomSheetScaffold
, but I found navigation with modal bottom sheet way more convenient to use. Also, the BottomSheet from scaffold do not have the halfExpanded
state which is very important for me. Probably I need something hybrid, but basically I would like to mimc the behaviour of the discover
panel from google maps. What is the recommended way to do that with Compose?jossiwolf
08/05/2022, 10:59 AMBottomSheetScaffold
. Material has set rules for the states that standard bottom sheets can be in. If you want to have custom states I would recommend building your own sheet using Swipeable🙂 This is an area we're looking to improve so if you miss any building blocks let us know!Piotr Prus
08/05/2022, 1:14 PM