|
|
@ -20,30 +20,45 @@ import androidx.navigation.NavController
|
|
|
|
import androidx.navigation.NavGraphBuilder
|
|
|
|
import androidx.navigation.NavGraphBuilder
|
|
|
|
import androidx.navigation.NavOptions
|
|
|
|
import androidx.navigation.NavOptions
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
|
|
|
|
import androidx.navigation.compose.navigation
|
|
|
|
import androidx.navigation.navDeepLink
|
|
|
|
import androidx.navigation.navDeepLink
|
|
|
|
import com.google.samples.apps.nowinandroid.core.notifications.DEEP_LINK_URI_PATTERN
|
|
|
|
import com.google.samples.apps.nowinandroid.core.notifications.DEEP_LINK_URI_PATTERN
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.ForYouScreen
|
|
|
|
import com.google.samples.apps.nowinandroid.feature.foryou.ForYouScreen
|
|
|
|
import kotlinx.serialization.Serializable
|
|
|
|
import kotlinx.serialization.Serializable
|
|
|
|
|
|
|
|
|
|
|
|
@Serializable data object ForYouRoute
|
|
|
|
@Serializable data object ForYouRoute // route to ForYou screen
|
|
|
|
|
|
|
|
@Serializable data object ForYouBaseRoute // route to base navigation graph
|
|
|
|
|
|
|
|
|
|
|
|
fun NavController.navigateToForYou(navOptions: NavOptions) = navigate(route = ForYouRoute, navOptions)
|
|
|
|
fun NavController.navigateToForYou(navOptions: NavOptions) = navigate(route = ForYouRoute, navOptions)
|
|
|
|
|
|
|
|
|
|
|
|
fun NavGraphBuilder.forYouScreen(onTopicClick: (String) -> Unit) {
|
|
|
|
/**
|
|
|
|
composable<ForYouRoute>(
|
|
|
|
* The ForYou section of the app. It can also display information about topics.
|
|
|
|
deepLinks = listOf(
|
|
|
|
* This should be supplied from a separate module.
|
|
|
|
navDeepLink {
|
|
|
|
*
|
|
|
|
/**
|
|
|
|
* @param onTopicClick - Called when a topic is clicked, contains the ID of the topic
|
|
|
|
* This destination has a deep link that enables a specific news resource to be
|
|
|
|
* @param topicDestination - Destination for topic content
|
|
|
|
* opened from a notification (@see SystemTrayNotifier for more). The news resource
|
|
|
|
*/
|
|
|
|
* ID is sent in the URI rather than being modelled in the route type because it's
|
|
|
|
fun NavGraphBuilder.forYouSection(
|
|
|
|
* transient data (stored in SavedStateHandle) that is cleared after the user has
|
|
|
|
onTopicClick: (String) -> Unit,
|
|
|
|
* opened the news resource.
|
|
|
|
topicDestination: NavGraphBuilder.() -> Unit
|
|
|
|
*/
|
|
|
|
) {
|
|
|
|
uriPattern = DEEP_LINK_URI_PATTERN
|
|
|
|
navigation<ForYouBaseRoute>(startDestination = ForYouRoute) {
|
|
|
|
},
|
|
|
|
composable<ForYouRoute>(
|
|
|
|
),
|
|
|
|
deepLinks = listOf(
|
|
|
|
) {
|
|
|
|
navDeepLink {
|
|
|
|
ForYouScreen(onTopicClick)
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This destination has a deep link that enables a specific news resource to be
|
|
|
|
|
|
|
|
* opened from a notification (@see SystemTrayNotifier for more). The news resource
|
|
|
|
|
|
|
|
* ID is sent in the URI rather than being modelled in the route type because it's
|
|
|
|
|
|
|
|
* transient data (stored in SavedStateHandle) that is cleared after the user has
|
|
|
|
|
|
|
|
* opened the news resource.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
uriPattern = DEEP_LINK_URI_PATTERN
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
ForYouScreen(onTopicClick)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
topicDestination()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|