Solvro / mobile-topwr

ToPWR mobile flutter application
https://solvro.pwr.edu.pl/portfolio/to-pwr
GNU Affero General Public License v3.0
14 stars 1 forks source link

Nested-navigator-based TabBar navigation (Back button improvements) #94

Closed simon-the-shark closed 3 weeks ago

simon-the-shark commented 3 weeks ago

Implements this feature requests:

I started with simple custom double linked queue in BottomNavBarController to keep track of tabs history, but then due to our android workaround I couldn't determine if the PopScope blocking the pop is the one that prevents killing the app or is it my custom one in some MapView that prevents pop to include it's own logic. I could have still implement these features in some way, but didn't consider it "nice" or "clean" enough.

That's how I ended up implementing fully Navigator based navigation in TabBarView. Now when we change a tab, what we really do is push new Route onto navigator stack. It has proper slide transitions from left or right and when we pop it slides back in reversed direction as well.

Basically our nested Navigator keeps tracks of routes history and handles any navigation in the app now. We can also block any popping e.g. in MapView when we want to hide a bottom sheet instead or unselect a marker with simple PopScope in this route.

BottomNavBarController is now only listening to these Routes changes with custom RouteObserver and is used to tell the world what the active tab is (e.g. to show proper icon on bottom nav bar). But when we want to make a change, we interact with Navigator

Hopefully, it's not an overkill solution :)

simon-the-shark commented 3 weeks ago

@mikolaj-jalocha I believe I've applied the requirements. Very nice review :) - you're becoming a pro in this already. Thanks for all and let me know if I can merge :)

mikolaj-jalocha commented 3 weeks ago

@mikolaj-jalocha I believe I've applied the requirements. Very nice review :) - you're becoming a pro in this already. Thanks for all and let me know if I can merge :)

LGTM!