Replies: 4 comments 4 replies
-
Multiple backstack support would be awesome! This is really impressive @erawhctim! Would love to hear from the Circuit team if there are plans to add something like this or if it would be possible to get feedback on your solution to move it forward. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing! Sorry for the delay in getting to this, turned out I didn't have any notifications for discussions. I think the way you've implemented it is more or less how we'd recommend it, and it's by design that it's easy to layer :). The only thing I suspect you'd need to tweak (and this is more of a compose thing) is this line, just to remember the final mapping. |
Beta Was this translation helpful? Give feedback.
-
@erawhctim, thanks for sharing this! I've tried to implement same approach, but faced an issue with state management. E.g. in the star sample if I select some pet, swipe through photos, or scroll down and then switch bottom tabs back and forth, the screen state is reset. Is there any way to persist it? @ZacSweers any ideas? |
Beta Was this translation helpful? Give feedback.
-
As of version 0.19, Circuit supports multiple backstacks out-of-the-box. Anyone looking for multiple back stack support can just upgrade to v0.19, and ignore everything else here 🙂 |
Beta Was this translation helpful? Give feedback.
-
I've been poking around with Circuit & the sample app and I was curious what it would take to support multiple backstacks (so each bottom navigation item could "own" its own backstack and swap between them on navigation item clicks).
I built out a small edit to the sample app on my fork (branch link here) to try and enable this. Much to my surprise, it was fairly straightforward! I'm sure there are holes in my solution, and edge cases that need to be tested to make it foolproof, but figured I'd share here in case anyone was interested in the multi-backstack concept 🙂
Here's a small screen recording of the sample in action:
circuit-sample-multibackstack.mp4
High-level summary of the changes:
MainActivity
to a plainCircuitContent
HomeContent
to use aNavigableCircuitContent
instead, and create a list ofSaveableBackStack
s matching the list of bottom navigation itemsrememberCircuitNavigator
call in akey()
(based on the bottom nav. item index), otherwise the sameNavigator
and backstack would be re-used across bottom nav. items.About
content to add a button + Event so we can push new About screens onto the stackSome closing thoughts/questions:
NavigatorImpl
that accepted multiple backstacks (and managed the "active" state itself), which didn't really make complete sense in my head (how would the "active" backstack state get updated?).Circuit is really enjoyable to use and build upon, even in its early state 🎉
Congrats to the team for building something so polished (and huge shoutout to y'all building this in the open for others to learn from 🙏🏻)
Beta Was this translation helpful? Give feedback.
All reactions