https://kotlinlang.org logo
#compose
Title
# compose
h

Hyper Nova

01/24/2023, 6:23 PM
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

Jaime

01/24/2023, 6:25 PM
h

Hyper Nova

01/24/2023, 6:28 PM
what about compose destinations?
c

Casey Brooks

01/24/2023, 6:32 PM
I recently released Ballast Navigation if URL-based routing is more of your preference
j

Jaime

01/24/2023, 6:34 PM
@Hyper Novacan you give an example, i have not had problems with compose targets
h

Hyper Nova

01/24/2023, 6:39 PM
like example of what? Currently I'm using accompanist navigation
j

Jaime

01/24/2023, 6:39 PM
I didn’t understand your first question
h

Hyper Nova

01/24/2023, 6:47 PM
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

Ian Lake

01/24/2023, 6:49 PM
What do you mean by 'has many issues'?
c

Casey Brooks

01/24/2023, 6:51 PM
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

Jaime

01/24/2023, 6:54 PM
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

Hyper Nova

01/24/2023, 7:34 PM
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

Ian Lake

01/24/2023, 7:42 PM
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

Hyper Nova

01/24/2023, 8:57 PM
Can you please link it
s

Shakil Karim

01/25/2023, 7:29 AM
I use Adam,s Backstack implementation, instead of Navigation Compose https://gist.github.com/adamp/17b4e5cfafc7d44a0023dc2fbdb972e8
s

Stylianos Gakis

03/18/2023, 10:19 AM
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 🤔
22 Views