Picture what I am trying to implement. If app is i...
# compose
o
Picture what I am trying to implement. If app is in background for 15..60seconds, user is navigated to a welcomeback screen when onResume() is called. However after successful login, I want to restore the navigation stack the user was on. The navController object is returning a null.
📸 5
p
Have you tried just pushing the login graph and after completion, depending on Success or failure, either just pop the login graph and the user will land in whatever was the previous task. On failure just pop everything to the root graph
o
Thanks for the response. However I do not really understand what you suggested, if you won't mind further explanation. My initial implementation was always to nav to dashboard which isn't smart enough.
p
Basically what I am saying is not to touch the backstack in the navcontroller, let the framework handle that. When you detect the timeout, then push your AuthorizationGraph, you should have a separate graph for this to be able to push it in different destinations of your App. When the AuthorizationGraph is done it will pass the result to the calling destination. Then at that destination, if you just pop the AuthorizationGraph then the stack remains untouched as it was before pushing the AuthorizationGraph. If the user failed login then you can log it out of the App
o
Thanks for the insight. I wasn't looking at it from your pov which is the easier way. I've now implemented it. 👍🏽
p
Anytime 👍 Basically with navigation-compose the idea is decomposing your App in reusable Graphs
o
Yeah. I'm more familiar now
👍 1