Comments (4)
I have not.
from compose-router.
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!
from compose-router.
Have you work in something with BottomNavigation and compose-router?
from compose-router.
I did this behaviour using Rxjava and JetPack BottonNavigation if you are interested
from compose-router.
Related Issues (20)
- Back stack is not in order
- Router crashes when using compose `0.1.0-dev08` HOT 1
- Make example apps independent of library version
- Unable to import when built with com.android.tools.build:gradle > 4.1.0-alpha05 HOT 3
- Crash with 0.11.1
- Please update to dev12 HOT 1
- Top of Stack HOT 5
- Off by one error in replace HOT 1
- [Proposal] Expose read access for BackStack#elements HOT 3
- [Question] Integration with ViewModelStore? HOT 1
- Crash with Jetpack Compose Alpha07 HOT 4
- How to handle TopAppBar navigation back event?
- Second launch icon HOT 1
- Open source license HOT 1
- Multiplatform support
- How do I save the state in a previous view? HOT 9
- Support for Dynamic Features?
- ViewModels not cleared when navigation out
- Navigation screens seem to be duplicated HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-router.