ayodele
02/13/2023, 8:37 PMCasey Brooks
02/13/2023, 9:09 PMIf I’m not mistaken, it’s built ontop on the redo and undo lib
ballast-navigation
only depends on ballast-core
, not ballast-undo
. The backstack functionality is part of the navigation module itself. Out of the box, it allows you to do forward/lateral navigation to a specific destination, and to go backward to the previous destination. https://copper-leaf.github.io/ballast/wiki/modules/ballast-navigation/#step-4-navigate
Adding the undo/redo module to the Router allows you to handle returning to a screen after going backward, without referencing the Router itself. Normally, you can go back, but you cannot restore to the screen you just “went back from”. It adds the “forward” button of a browser’s address bar, which is not available in the base ballast-navigation
module.
This might help illustrate the difference:
Without Undo/Redo module:
1. RouterContract.Inputs.GoToDestination(A)
- Backstack: [A]
2. RouterContract.Inputs.GoToDestination(B)
- Backstack: [A, B]
3. RouterContract.Inputs.GoBack()
- Backstack: [A]
4. Cannot return to B, you have to do GoToDestination(B) again
With Undo/Redo module:
1. RouterContract.Inputs.GoToDestination(A)
- State History:
- Backstack: [A] (current state, destination is B)
2. RouterContract.Inputs.GoToDestination(B)
- State History:
- Backstack: [A]
- Backstack: [A, B] (current state, destination is B)
3. UndoController.undo()
- State History:
- Backstack: [A] (current state, destination is A)
- Backstack: [A, B]
4. UndoController.redo()
- State History:
- Backstack: [A]
- Backstack: [A, B] (current state, destination is B once again)
The Compose Desktop example shows how this works.do I still need compose navigation with Ballast navigationNo, Ballast Navigation is an alternative to
navigation-compose
, and is not compatible with it, nor is it built upon anything from that library. Ballast is a completely separate navigation library which offers a simpler way to do navigation that is not limited to Android or Compose like navigation-compose
is. However, since it isn’t tied directly to Compose, it may take a bit more work from you to get some of the nicer features of navigation-compose
like transition animations and scoping ViewModels to the NavGraph.ayodele
02/13/2023, 9:29 PM