Orhan Tozan
09/29/2021, 7:14 PMnglauber
09/29/2021, 9:56 PMadjpd
09/29/2021, 10:16 PMnglauber
09/29/2021, 10:58 PMIan Lake
09/30/2021, 12:30 AMnglauber
09/30/2021, 2:24 AMappCompatVersion = '1.4.0-beta01'
composeAccompanistVersion = '0.18.1-SNAPSHOT'
composeNavigationVersion = '2.4.0-alpha10'
composeVersion = '1.0.3'
navVersion = '2.4.0-alpha10'
But Iām getting this error š
java.lang.NoSuchMethodError: No static method rememberNavController(Landroidx/compose/runtime/Composer;I)Landroidx/navigation/NavHostController; in class Landroidx/navigation/compose/NavHostControllerKt; or its super classes (declaration of 'androidx.navigation.compose.NavHostControllerKt' appears in /data/app/com.investcorp.mobile-b0FahXhLXqmtLHdJOugYqQ==/base.apk)
at com.google.accompanist.navigation.animation.NavHostControllerKt.rememberAnimatedNavController(NavHostController.kt:36)Ian Lake
09/30/2021, 3:18 AMnglauber
09/30/2021, 11:00 AMIan Lake
09/30/2021, 1:09 PMnglauber
09/30/2021, 11:51 PMParcelable / Serializable as parameters in the navigation? (I know you guys are very opinionated about that)Ian Lake
09/30/2021, 11:54 PMnglauber
09/30/2021, 11:58 PMnglauber
10/01/2021, 3:35 AM*AppNavHost* {
AnimatedNavHost {
composable("onboarding") {
*OnboardingNavHost* {
AnimatedNavHost { my onboarding screens here }
}
}
composable("feature1") {
*Feature1NavHost* {
AnimatedNavHost { my feature1 screens here }
}
}
}
}
Whatās happening is: Iām displaying a screen declared in Feature1NavHost, from there Iām calling a callback declared in AppNavHost which do the following:
val navOptions = NavOptions.Builder()
.setPopUpTo("feature1", true)
.build()
navController.navigate(
"onboarding",
navOptions
)
The idea here is navigate from Feature1 to Onboarding.
However, one of the composables declared in OnboardingNavHost has a deep link declared in it which is always called š event I set a totally different start routeā¦
composable(
"activateAccount",
arguments = ...,
// Removing this line, everything works...
// deepLinks = OnBoardingRoutes.AccountActivation.getDeepLinks()
) { ... }
Any thoughts? šIan Lake
10/01/2021, 3:51 AMnglauber
10/01/2021, 10:25 AMIan Lake
10/01/2021, 2:22 PMnglauber
10/01/2021, 10:28 PMnglauber
10/03/2021, 12:33 AMarguments and deepLinks. I just need the deep links, so when I removed the arguments, it worked. The custom NavType also worked fine.
Everything is working now using nested NavHosts. š
@Ian Lake, Iām genuinely curious about your recommendation against using nested NavHost. You know more than everyone, after all, youāre part of the team that build it. So I really want to hear from youā¦
I tried migrate to nested navigation, but I faced a few problems in comparison with my current approach:
1. How can pass a parameter to a nested graph? For instance: I have a ScreenA in the Module1, this screen load some status and redirect to Module2. But the logic for which screen in Module2 should be displayed should be executed in Module2. How can I do that? Should I have āfakeā route to do this logic and then redirect properly?
2. Based on the problem above (a dynamic start route), how can create a hiltViewModel scoped to a navigation? Currently, Iām using the NavBackStackEntry from the root of my module. How could I do the same?
3. If I use a navigation to represent the tabs of a BottomNavigation, when I select a given tab, should I replace the entire content? So every tab would have a bottom navigation bar? In my current implementation, a NavHost is the content of my Scaffold , so as soon I navigate using the navController, the content is shown properly.
I truly appreciate your help.
Thanks in advance.