I have navigation graph like this: - A ◦ B ...
# compose
m
I have navigation graph like this: • A ◦ B ◦ C B, C are inside of a nested graph. C should always pop to B. from A user can navigate to both B and C. how to achieve A -> C -> B -> A? point me to a right place to ask this question if this is not right channel
s
By "A -> C -> B -> A?" you mean "A -> C (press back button ->) B (press back button ->) A?" here right? Have you tried when you navigate to C to also just navigate to B at the same time? What does that look like? So going from:
Copy code
onClick {
 navController.navigate(C())
}
to this:
Copy code
onClick {
 navController.navigate(B())
 navController.navigate(C())
}
m
yes but that seemed weird, so I thought there is maybe some other way
s
Weird as in the animation looks wrong, or just that the code looks odd?
m
code
👍 1
i
Multiple calls to navigate is exactly how you add multiple things to the back stack, so that code is correct (you'll note our processing of deep links does the same thing to build up its synthetic back stack)
💯 1
What is weird is injecting a screen that users haven't seen in the back stack as part of your normal app user flow, so I'd look into doing some user research to understand if what you are proposing is expected by users at all or if the whole UX needs to be rethought.
☝🏼 1
m
thank you very much. I also think that it’s weird but that is what our UX came up with 🤷‍♂️.
s
You can always argue against what your UX people say if things feel too weird from your perspective as an experienced developer. Sometimes you'll notice that they don't have a good reason for what they do, and when questioned take back such odd decisions 😄
🤣 1
m
yes, sure. I think that they made the best decision for this flow. it doesn’t make 100% sense in theory but when using it it feels good
👍 1