Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Use explicit navigation argument types #778

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/src/main/java/app/tivi/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navArgument
import androidx.navigation.compose.navigate
import androidx.navigation.compose.popUpTo
import androidx.navigation.compose.rememberNavController
Expand Down Expand Up @@ -91,7 +93,10 @@ internal fun Home(
composable(Screen.Search.route) {
Search(navController)
}
composable(Screen.ShowDetails.route) {
composable(
route = Screen.ShowDetails.route,
arguments = listOf(navArgument("showId") { type = NavType.LongType })
) {
ShowDetails(navController)
}
composable(Screen.RecommendedShows.route) {
Expand All @@ -103,7 +108,10 @@ internal fun Home(
composable(Screen.Popular.route) {
Popular(navController)
}
composable(Screen.EpisodeDetails.route) {
composable(
route = Screen.EpisodeDetails.route,
arguments = listOf(navArgument("episodeId") { type = NavType.LongType })
) {
EpisodeDetails(navController)
}
composable(Screen.Account.route) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class EpisodeDetailsViewModel @Inject constructor(
) : ReduxViewModel<EpisodeDetailsViewState>(
EpisodeDetailsViewState(
// The string "episodeId" is the name of the argument in the route
episodeId = savedStateHandle.get<String>("episodeId")!!.toLong()
episodeId = savedStateHandle.get("episodeId")!!
)
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class ShowDetailsViewModel @Inject constructor(
) : ReduxViewModel<ShowDetailsViewState>(
ShowDetailsViewState(
// The string "showId" is the name of the argument in the route
showId = savedStateHandle.get<String>("showId")!!.toLong()
showId = savedStateHandle.get("showId")!!
)
) {
private val loadingState = ObservableLoadingCounter()
Expand Down