Closed nhaarman closed 5 years ago
The Material "Bottom Navigation" component allows movement between primary destinations in an app:
Each of the 'primary destinations' is represented by a tab in the bottom navigation bar, and each of them has their own navigational state.
In Acorn, this could be represented by a CompositeParallelNavigator type, which allows for such a component.
A quick sketch-up of the API could be:
enum class MyDestination { Favorites, Music, Places, News } class MyNavigator( savedState: NavigatorState? = null ) : CompositeParallelNavigator<MyDestination>(savedState) { override fun createNavigator(destination: MyDestination) : Navigator { return when(destination) { Favorites -> FavoritesNavigator() /* ... */ } } override fun instantiateNavigator( navigatorClass: KClass<out Navigator>, state: NavigatorState? ) : Navigator { return when(navigatorClass) { is FavoritesNavigator::class -> FavoritesNavigator(state) /* ... */ } } }
The CompositeParallelNavigator<T> class could expose methods like select(T) to switch between the nested child Navigators, and provide a way to listen to changes in the selected T type.
CompositeParallelNavigator<T>
select(T)
T
A draft pull request has been made in #146
The Material "Bottom Navigation" component allows movement between primary destinations in an app:
Each of the 'primary destinations' is represented by a tab in the bottom navigation bar, and each of them has their own navigational state.
In Acorn, this could be represented by a CompositeParallelNavigator type, which allows for such a component.
A quick sketch-up of the API could be:
The
CompositeParallelNavigator<T>
class could expose methods likeselect(T)
to switch between the nested child Navigators, and provide a way to listen to changes in the selectedT
type.