kiwicom / navigation-compose-typed

Type-safe arguments for Jetpack Navigation Compose using Kotlinx.Serialization
MIT License
220 stars 9 forks source link

feature: NavDestination.hasRoute<T>(), NavHostController.popBackStack<T> and remove createRoutePattern #143

Open sonatard opened 3 weeks ago

sonatard commented 3 weeks ago

This is not a request for navigation-compose-types to support navigation-compose:2.8.0. Rather, it’s the opposite—having the API in place before supporting navigation-compose:2.8.0 would make transitioning between navigation-compose:2.8.0 and navigation-compose-types easier.

I have tested navigation-compose:2.8.0, but I found some inconveniences, so I plan to return to navigation-compose-types.

- if (currentDestination?.destination?.hierarchy?.any { it.hasRoute<NavItem.A>() } == true) {
+ if (currentDestination?.destination?.hierarchy?.any { it.route == createRoutePattern<NavItem.A>() } == true) {
-  navController.popBackStack<NavItem.ProductRaffle>(
+ navController.popBackStack(
+    route = createRoutePattern<NavItem.ProductRaffle>(),
-        startDestination = NavItem.Start,
+        startDestination = createRoutePattern<NavItem.Start>(),