Jordi Saumell
02/04/2021, 10:12 PMKD
02/04/2021, 10:14 PMJordi Saumell
02/04/2021, 10:15 PMKD
02/04/2021, 10:16 PMnavigate()
function?KD
02/04/2021, 10:17 PMpopUpTo
that supports a string
Jordi Saumell
02/04/2021, 10:18 PMKD
02/04/2021, 10:19 PMpath
is in question correct?KD
02/04/2021, 10:19 PMpath
as a string rather than int
?Jordi Saumell
02/04/2021, 10:20 PMKD
02/04/2021, 10:21 PMString
. In my opinion, it only takes a @IdRes Int
value.KD
02/04/2021, 10:22 PMKD
02/04/2021, 10:22 PMnavController.navigate(bottomNavigationitem.route) {
popUpTo = navController.graph.startDestination
launchSingleTop = true
}
Jordi Saumell
02/04/2021, 10:23 PMJordi Saumell
02/04/2021, 10:26 PMKD
02/04/2021, 10:26 PMDeepLinkMatch matchDeepLink(@NonNull NavDeepLinkRequest request) {
// First search through any deep links directly added to this NavGraph
DeepLinkMatch bestMatch = super.matchDeepLink(request);
// Then search through all child destinations for a matching deep link
for (NavDestination child : this) {
DeepLinkMatch childBestMatch = child.matchDeepLink(request);
if (childBestMatch != null && (bestMatch == null
|| childBestMatch.compareTo(bestMatch) > 0)) {
bestMatch = childBestMatch;
}
}
return bestMatch;
}
KD
02/04/2021, 10:27 PMstring
cant be passedKD
02/04/2021, 10:29 PMString
version does:
fun NavOptionsBuilder.popUpTo(route: String, popUpToBuilder: PopUpToBuilder.() -> Unit) {
popUpTo(createRoute(route).hashCode(), popUpToBuilder)
}
KD
02/04/2021, 10:29 PMcreateRoute
simply appends the route
and returns the string
internal fun createRoute(route: String) = "<android-app://androidx.navigation.compose/$route>"
KD
02/04/2021, 10:30 PMhashCode
Jordi Saumell
02/04/2021, 10:34 PMKD
02/04/2021, 10:34 PMinternal fun createRoute(route: String) = "<android-app://androidx.navigation.compose/$route>"
either the popUpTo
function that takes a String
argument and a lambda
is deprecated or somehow the navbackStack
assigned this randomly generated Int
via hashCode()
to the respective composable
entry?KD
02/04/2021, 10:37 PMpopUpTo
always takes an Int
. Even the String
is being converted to an Int
. The question is, how does this String
gets matched to the correct composable
.Ian Lake
02/04/2021, 10:38 PMimport androidx.navigation.compose.popUpTo
, you can pass a route to popUpTo
, not just an Int. That route needs to exactly match the route
you've used when constructing your composable
in your NavHost
Ian Lake
02/04/2021, 10:39 PMKD
02/04/2021, 10:40 PMString
into an Int
no? via
createRoute(route: String) = "<android-app://androidx.navigation.compose/$route>"
Ian Lake
02/04/2021, 10:41 PMKD
02/04/2021, 10:41 PMInt
after hashing would point to that destination.Ian Lake
02/04/2021, 10:42 PMJordi Saumell
02/04/2021, 10:43 PMKD
02/04/2021, 10:43 PMInt
generated via hash would match correctly. But that’s an implementation detail.Jordi Saumell
02/04/2021, 10:43 PMIan Lake
02/04/2021, 10:47 PMJordi Saumell
02/04/2021, 10:48 PMJordi Saumell
02/04/2021, 10:49 PMKD
02/04/2021, 10:49 PMimporting
properly yet. I simply manually import.Ian Lake
02/04/2021, 10:49 PMKD
02/04/2021, 10:50 PMonClick = {
navController.navigate(screen.route) {
// Pop up to the start destination of the graph to
// avoid building up a large stack of destinations
// on the back stack as users select items
popUpTo = navController.graph.startDestination
// Avoid multiple copies of the same destination when
// reselecting the same item
launchSingleTop = true
}
}
Ian Lake
02/04/2021, 10:51 PMcomposable("profile")
, it should be popUpTo("profile")
, same with composable("profile/{userId}")
and popUpTo("profile/{userId}")
KD
02/04/2021, 10:52 PMInt
. Btw where is that implementation 👀 ?Jordi Saumell
02/04/2021, 10:52 PMJordi Saumell
02/04/2021, 10:54 PMIan Lake
02/04/2021, 10:54 PMB
isn't on the back stack, popUpTo(B)
does nothingJordi Saumell
02/04/2021, 10:55 PMKD
02/04/2021, 10:56 PMIan Lake
02/04/2021, 10:56 PMIan Lake
02/04/2021, 10:58 PMIan Lake
02/04/2021, 10:58 PMJordi Saumell
02/04/2021, 11:01 PMDeepak Gahlot
03/29/2021, 9:54 AMIan Lake
03/29/2021, 1:00 PM