I am using Accompanist Bottom Sheet Destinations in my project. The setup is exactly the same as shown in docs.
@Composable
fun MyApp() {
val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
ModalBottomSheetLayout(bottomSheetNavigator) {
NavHost(navController, Destinations.Home) {
composable(route = "home") {
HomeScreen(
openBottomSheet = { navController.navigate("sheet") }
)
}
bottomSheet(route = "sheet") {
MyBottonSheet(
navigateToSomeRoute = { navController.navigate("some_route") }
)
}
composable(route = "some_route") {
SomeComposable(
onBackPress = { navController.navigateUp() }
)
}
}
}
}
Here I have a button in MyBottomSheet
which opens the SomeComposable
screen. But when I navigateUp from there, I reach HomeScreen
i.e. the bottom sheet was popped off the backstack when I navigated away from it. How can I keep my bottom sheet in the backstack so that when I press Back in SomeComposable
I go back to the previous state with MyBottonSheet
open (on top of HomeScreen
)?