Skip to content

Magellan 1.x Navigation

Ryan Moelter edited this page Jul 18, 2021 · 1 revision

In order to navigate from Screen to Screen, you need to use the Navigator.

The Navigator needs to be implemented in a way that survives rotation, and is responsible for:

  • Screen navigation
  • Backstack control (and you get full control of it)
  • Animations between Screens (there are defaults, and you can override them if necessary)

Creating a Navigator

Navigator.withRoot(new HomeScreen()).build();

Configuring advanced options

Navigator.withRoot(new HomeScreen())
  .transition(transition)
  .maxEventTracked(100)
  .loggingEnabled(BuildConfig.DEBUG)
  .build();

Navigation basics

goTo(screen) goBack()

Advanced navigation

Build-in complex navigation

replace(screen)

goBackTo(screen) goBackBefore(screen)

Rewriting history

navigator.navigate(new HistoryRewriter() {
  @Override
  public void rewriteHistory(Deque<Screen> history) {
    // Change history
  }
});

Overriding the default transition

navigator.overrideTransition(new TransitionToUseInsteadOfDefault()).goTo(new Screen());