aartikov / Alligator

Alligator is Android navigation library that will help to organize your navigation code in clean and testable way.
MIT License
298 stars 17 forks source link

It makes sense to have a method returning the current screen (and maybe the activity/fragment) on AndroidNavigator? #19

Open emanzanoaxa opened 6 years ago

emanzanoaxa commented 6 years ago

It can be useful for example for knowing which screen is being displayed when receiving a notification, to know if you must resume that activity in case is already on the stack or if you need to recreate that screen.

And another question, there are plans to implement some sort of navigation stack using screens? Like the one you can create on a notification using intents, to preserve the navigation stack when navigating to a hierarchically deep screen.

aartikov commented 6 years ago

There is no such method as getCurrentScreen in Navigator. You can only pass commands to a navigator but not query it for something. The reason is that NavigationContext may be not bound yet when you call methods of a navigator. I am thinking about some kind of conditional/composite commands, but I am not ready to say how it would look like.

What about the second question, you can call several navigation methods in sequence to build a screen stack. For example:

navigator.reset(new ScreenA());
navigator.goForward(new ScreenB());
navigator.goForward(new ScreenC());