Hey, I’m using voyager for navigation, and I’m not...
# multiplatform
r
Hey, I’m using voyager for navigation, and I’m not sure if I’m doing this right I have a bottom navigation bar, with 4 tabs, each tab screen is implementing
Tab
interface, now those tabs can navigate to other screens inside the tab, for this I wasn’t able to get
LocalNavigator.current
and had to separate the tab from the screen, e.g. instead of
HomeScreen
now I have
HomeTab
that have this code
Copy code
@Composable
override fun Content() {
    Navigator(HomeScreen)
}
which allows the Home screen to navigate to other child screens, is this correct? with this approach now I have multiple navigators inside the app instead of one its working fine so far but when I wanted to listen to navigations following this person’s code it didn’t work because I have more than one navigator and I can’t listen to all navigations from the main one so if you have suggestions for different navigation listener I would be happy to hear
b
My Airbnb sample (as well as Code with a slightly modified/updated use case) has a combine navigator for sheets and tabs. https://github.com/sponsors/bmcreations https://github.com/code-payments/code-android-app
r
Great! thanks for sharing, will check it out
do you have some kind of navigation listener ?
b
What’s the use case? You need to know what screen you came from?
r
no, tracking screens usages, I wanna know what screens are most used by users
b
Oh we have our screens tracking themselves to analytics
OnLifecycleEffect I think it’s called in voyager
Check AnalyticsScreenWatcher
r
alright will check, I was hoping there would be an automatic way instead of doing it manually in each screen but that will do too
b
its per screen atm since I need the analytics event for it and didnt wanna call a super.Content() in content (but reconsidering that)
then my base Screen could handle it
would just need to add my
event
as an overridable val for base screen
You could though LaunchedEffect lastItem though and track that way
1