Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help on using new navigatorViewModel #475

Open
osrl opened this issue Aug 20, 2024 · 2 comments
Open

Help on using new navigatorViewModel #475

osrl opened this issue Aug 20, 2024 · 2 comments

Comments

@osrl
Copy link
Contributor

osrl commented Aug 20, 2024

I have navigation pattern which looks like the screenshot below. I want my ViewModel to stay alive inside the Navigator2.

The initial screen is ChatListScreen. If I want to push a new navigator to the first one, it's not possibile to do so. Instead I wrap the screen into another screen, which has only Navigator(screen) as content it works.

data class NavigatorScreen(val screen: Screen): Screen {
    @Composable
    override fun Content() {
        Navigator(screen)
    }
}

But this breaks the backstack, since the wrapper is also a screen.

What is the best way to achieve the below navigation pattern?

Screenshot 2024-08-20 at 13 48 03

PS: I've achieved this using koin scopes, but I wanted to try the new navigatorViewModel.

@nvkleban
Copy link
Contributor

nvkleban commented Oct 2, 2024

Why do you need navigator 2 in the first place?
Looks like all you screens are opening on top of each other

@osrl
Copy link
Contributor Author

osrl commented Oct 10, 2024

to keep the ViewModel instance when navigating between chat and media screen. It should stay alive inside the navigator 2, but should die when navigating back from chat screen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants