Tlaster / PreCompose

Compose Multiplatform Navigation && State Management
https://tlaster.github.io/PreCompose/
MIT License
868 stars 50 forks source link

Can I use bottom navigation in precompose? #291

Open thanhhoai162963 opened 8 months ago

thanhhoai162963 commented 8 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

Tlaster commented 8 months ago

Yes you can!

thanhhoai162963 commented 8 months ago

Do you have any tutorials on using bottom navigation in precompose? Is there some function I can't find? Thank you

example as : val bottomNavController = rememberNavigator() val navBackStackEntry by bottomNavController.currentBackStackEntryAsState() // not found. val currentDestination = navBackStackEntry?.destination

Tlaster commented 8 months ago

There's a Navigator.currentEntry that you can use as a replacement for currentBackStackEntryAsState

thanhhoai162963 commented 8 months ago

my code in jetpack compose: bottomNavController.navigate(route) {this: navOptionsbuilder popUpTo(bottomNavController.graph.findStartDestination().id) {this:PopUpToBuilder saveState = true }
restoreState = true

Can you help me convert these functions ? Thanks you

bottomNavController.navigate( route, options = NavOptions( launchSingleTop = true, popUpTo = PopUpTo(....)// I don't know ) )

Tlaster commented 8 months ago

There's a doc for popUpTo: https://github.com/Tlaster/PreCompose/blob/master/docs/component/navigation.md#navoptions