compose-router
compose-router copied to clipboard
0.1.0-dev06 - BottomNavigation Sample
It would be nice to have one. ;)
Have you work in something with BottomNavigation and compose-router?
I have not.
I did this behaviour using Rxjava and JetPack BottonNavigation if you are interested
Hello, I just managed the back stack as necessary for BottomNavigation
, meaning the user always goes back to Home before leaving the app, and all other options than Home are replacing each other:
fun <T> BackStack<T>.pushBottomBar(root: T, others: List<T>, item: T) {
if (item == root || last() != item ) {
when {
root == item -> {
val removeHowMany = elements.size - elements.indexOf(item)
repeat(removeHowMany) { pop() }
}
elements.any(others::contains) -> {
replace(item)
}
else -> push(item)
}
}
}
And here's the BottomNavigation:
BottomNavigation {
menuItems.forEach { item ->
BottomNavigationItem(
icon = { Icon(vectorResource(id = item.iconResId)) },
text = { Text(stringResource(id = item.label)) },
selected = currentRouting == item,
onSelected = { backStack.pushBottomBar(defaultRouting, menuItems - defaultRouting, item) }
)
}
}
Hope this helps!