Hi everyone. I want to migrate the navigation libr...
# compose
h
Hi everyone. I want to migrate the navigation library of my Jetpack Compose Project what would be some good alternatives? I'm looking for good deeplinks support as well
j
h
what about compose destinations?
c
I recently released Ballast Navigation if URL-based routing is more of your preference
j
@Hyper Novacan you give an example, i have not had problems with compose targets
h
like example of what? Currently I'm using accompanist navigation
j
I didn’t understand your first question
h
I'm just exploring options for navigation in compose because the current accompanist one has many issues.
I was asking thoughts on compose destinations
i
What do you mean by 'has many issues'?
c
Compose Destinations is just a code-gen wrapper over the standard Jetpack Navigation library. And for that matter, Accompanist Navigation is similar, just a layer over Jetpack Navigation. So if your not happy with Jetpack Navigation, neither of those libraries will get you away from it. My experience with the official Jetpack Navigation library is that it’s very opinionated and has a very specific way it wants you to navigate, which are in line with the general Android principles of navigation. If you’re not following the library’s recommendation for navigational patterns, you’ll be fighting an uphill battle. So you should look to adapt your app to those established best practices, or move away to a completely different navigation library that is not a wrapper over Jetpack Navigation.
j
in my experience with appyx it is easier to pass complex objects from one screen to another, the transitions are much easier and the path definitions are only based on a model and not a path
h
Right now I'm facing this issue
Copy code
java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
I have implemented bottom sheet navigation in app and my login screen is not a part of this bottom sheet. So I have a mutable state variable which is set to true when user logs in. I have set an observer on that variable which switches between nav graphs according to its value. Sometimes my app crashes with above error when I logout of the app.
This is the issuetarcker for it Ig: https://issuetracker.google.com/issues/228865698 but I'm not able to understand its solution
i
Changing your navigation graph isn't how you are supposed to handle login anyways, something that's been covered a number of times in this channel, FWIW
h
Can you please link it
s
I use Adam,s Backstack implementation, instead of Navigation Compose https://gist.github.com/adamp/17b4e5cfafc7d44a0023dc2fbdb972e8
s
You can search for “login” in this channel, here’s a few:
None of these really cover the case where an app can not have a fixed start destination, but needs to: • If logged in, show the start destination of being logged in • If logged out, show some screen which lets them login/register etc. I really can say that the vast majority of the apps that I use need this pattern. There’s just no way to have one common screen as a start destination for both logged in and logged out users. And all the proposed solutions make it so that when you go to the login screen you can't really press the back button to get the predictive back animation and exit the app as one would expect. Or maybe it's not what one would expect, really not sure 🤔