Fix nested navigation graphs

Change-Id: I2c3ad0a0f6c132230b821d3621389913cf37247c
pull/58/head
Simona Stojanovic 3 years ago
parent 8992953a4d
commit 1475e3e8f9

@ -54,13 +54,11 @@ fun NiaNavHost(
) )
interestsGraph( interestsGraph(
navigateToTopic = { navController.navigate("${TopicDestination.route}/$it") }, navigateToTopic = { navController.navigate("${TopicDestination.route}/$it") },
navigateToAuthor = { navController.navigate("${AuthorDestination.route}/$it") } navigateToAuthor = { navController.navigate("${AuthorDestination.route}/$it") },
) nestedGraphs = {
topicGraph( topicGraph(onBackClick = { navController.popBackStack() })
onBackClick = { navController.popBackStack() } authorGraph(onBackClick = { navController.popBackStack() })
) }
authorGraph(
onBackClick = { navController.popBackStack() }
) )
} }
} }

@ -18,6 +18,7 @@ package com.google.samples.apps.nowinandroid.feature.interests.navigation
import androidx.navigation.NavGraphBuilder import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.google.samples.apps.nowinandroid.core.navigation.NiaNavigationDestination import com.google.samples.apps.nowinandroid.core.navigation.NiaNavigationDestination
import com.google.samples.apps.nowinandroid.feature.interests.InterestsRoute import com.google.samples.apps.nowinandroid.feature.interests.InterestsRoute
@ -28,12 +29,20 @@ object InterestsDestination : NiaNavigationDestination {
fun NavGraphBuilder.interestsGraph( fun NavGraphBuilder.interestsGraph(
navigateToTopic: (String) -> Unit, navigateToTopic: (String) -> Unit,
navigateToAuthor: (String) -> Unit navigateToAuthor: (String) -> Unit,
nestedGraphs: NavGraphBuilder.() -> Unit
) {
navigation(
route = InterestsDestination.route,
startDestination = InterestsDestination.destination
) { ) {
composable(route = InterestsDestination.route) { composable(route = InterestsDestination.destination) {
InterestsRoute( InterestsRoute(
navigateToTopic = navigateToTopic, navigateToTopic = navigateToTopic,
navigateToAuthor = navigateToAuthor, navigateToAuthor = navigateToAuthor,
) )
} }
nestedGraphs()
}
} }

Loading…
Cancel
Save