voyager
voyager copied to clipboard
Navigation to Screen from bottom sheet
How can we navigate to a screen from a bottom sheet? if I do bottomSheetNavigator.show(ScreenA()) and then navigator.push(ScreenB()) it will be another bottom sheet. How can i do the opposite?
Hey, sorry the delay!
Don't know if I understand your question properly, do you want to navigate to another Screen inside the BottomSheet or you want to navigate to Screen of the a Navigator that is the Content of the Scaffold? Can you give me some examples?
Hey! Sorry for the delay, consider this glow when moving from a bottom sheet to a non-bottom sheet screen.
@Kashif-E same problem, have you found any solution?
@DevSrSouza is there a recommended solution for such a case?
Same here. Does anyone have some solutions?
👋 We're also looking for a solution to this. The structure we adopt is the root composable of our application hosts the BottomSheetNavigator
. For example:
@Composable
fun App() {
BottomSheetNavigator {
Navigator(screen = MainScreen())
}
}
When in a bottom sheet screen, LocalNavigator.currentOrThrow
is thus the BottomSheetNavigator
, which explains why all screens launched from this context open as bottom sheets. LocalNavigator.currentOrThrow.parent
is, of course, null.
I think BottomSheetNavigator
needs a variant where BottomSheetNavigatorContent
is a Navigator
, where such Navigator
is made available via a CompositionLocal
?
you can pass a navigator to the bottom sheet and then use that inside the bottom sheet to open a new screen instead of the bottom sheet
you can pass a navigator to the bottom sheet and then use that inside the bottom sheet to open a new screen instead of the bottom sheet
This solution worked for me. Thank you @Kashif-E
you can pass a navigator to the bottom sheet and then use that inside the bottom sheet to open a new screen instead of the bottom sheet
if you put the app in the background while bottom sheet is open, app will crash because of Parcelable IOException. I can repeat the crash continuously.
@akardas16 yes you are right, the navigator is not parcelable/serializable. Another option is to pass a result to the original bottom sheet caller; upon receiving the result, you can navigate to the next screen. you can use one of the ways mentioned in this repo for result passing.
navigate to the bottom sheet from screen A-> hide the bottom sheet with the result -> get the result in screen A and navigate to screen B
@akardas16 yes you are right, the navigator is not parcelable/serializable. Another option is to pass a result to the original bottom sheet caller; upon receiving the result, you can navigate to the next screen. you can use one of the ways mentioned in this repo for result passing.
navigate to the bottom sheet from screen A-> hide the bottom sheet with the result -> get the result in screen A and navigate to screen B
I have tried a few options which mentioned but looks like they are not working as expected. there is no reason to not using ModalBottomSheet if needs result from bottom sheet. it works like a charm
Can you explain?