Skip to content

Commit

Permalink
Update to AndroidX Navigation 2.8.0 (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored Sep 16, 2024
1 parent c7a7167 commit 8199adc
Show file tree
Hide file tree
Showing 20 changed files with 419 additions and 486 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ androidx-datastore = "1.1.1"
androidx-fragment = "1.8.3"
androidx-lifecycle = "2.8.5"
androidx-media3 = "1.4.1"
androidx-navigation = "2.7.7"
androidx-navigation = "2.8.0"
androidx-paging = "3.3.2"
androidx-test-core = "1.6.1"
androidx-test-ext-junit = "1.2.1"
Expand Down
4 changes: 3 additions & 1 deletion pillarbox-demo-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
plugins {
alias(libs.plugins.pillarbox.android.library)
alias(libs.plugins.pillarbox.android.library.compose)
alias(libs.plugins.kotlin.serialization)
}

dependencies {
Expand All @@ -31,10 +32,11 @@ dependencies {
api(libs.androidx.lifecycle.viewmodel)
api(libs.androidx.media3.common)
implementation(libs.androidx.media3.exoplayer)
api(libs.androidx.navigation.common)
implementation(libs.androidx.navigation.common)
api(libs.androidx.navigation.runtime)
implementation(libs.androidx.paging.common)
api(libs.kotlinx.coroutines.core)
api(libs.kotlinx.serialization.core)
implementation(libs.okhttp)
api(libs.srg.data)
api(libs.srg.dataprovider.paging)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ import ch.srgssr.pillarbox.demo.shared.R
* @property imageVector image vector
*/
sealed class HomeDestination(
val route: String,
val route: NavigationRoutes,
@StringRes val labelResId: Int,
val imageVector: ImageVector
) {
/**
* Examples home page containing all kinds of streams
*/
data object Examples : HomeDestination(NavigationRoutes.homeSamples, R.string.examples, Icons.Default.Home)
data object Examples : HomeDestination(NavigationRoutes.HomeSamples, R.string.examples, Icons.Default.Home)

/**
* Streams home page
*/
data object ShowCases : HomeDestination(NavigationRoutes.homeShowcases, R.string.showcases, Icons.Default.Movie)
data object ShowCases : HomeDestination(NavigationRoutes.HomeShowcases, R.string.showcases, Icons.Default.Movie)

/**
* Integration layer list home page
*/
data object Lists : HomeDestination(NavigationRoutes.homeLists, R.string.lists, Icons.AutoMirrored.Filled.ViewList)
data object Lists : HomeDestination(NavigationRoutes.HomeLists, R.string.lists, Icons.AutoMirrored.Filled.ViewList)

/**
* Info home page
*/
data object Search : HomeDestination(NavigationRoutes.searchHome, R.string.search, Icons.Default.Search)
data object Search : HomeDestination(NavigationRoutes.SearchHome, R.string.search, Icons.Default.Search)

/**
* Settings home page
*/
data object Settings : HomeDestination(NavigationRoutes.settingsHome, R.string.settings, Icons.Default.Settings)
data object Settings : HomeDestination(NavigationRoutes.SettingsHome, R.string.settings, Icons.Default.Settings)
}

/**
* Navigate as a top level destination.
*
* @param destination The [HomeDestination] to navigate to.
* @param route The [NavigationRoutes] to navigate to.
*/
fun NavController.navigate(destination: HomeDestination) {
navigate(destination.route) {
fun NavController.navigateTopLevel(route: NavigationRoutes) {
navigate(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,74 @@
*/
package ch.srgssr.pillarbox.demo.shared.ui

import kotlinx.serialization.Serializable

/**
* Navigation stores all routes available
*/
@Suppress("UndocumentedPublicProperty")
object NavigationRoutes {
const val homeSamples = "home_samples"
const val homeSample = "home_sample"
const val homeShowcases = "home_showcases"
const val showcaseList = "showcase_list"
const val showcasePlaybackSettings = "showcase_playback_settings"
const val story = "story"
const val simplePlayer = "simple_player"
const val adaptive = "adaptive"
const val playerSwap = "player_swap"
const val exoPlayerSample = "exoplayer_sample"
const val trackingSample = "tracking_sample"
const val updatableSample = "updatable_sample"
const val smoothSeeking = "smoothSeeking_sample"
const val startAtGivenTime = "start_given_time_sample"
const val video360 = "video_360"
const val chapters = "chapters"

const val homeLists = "home_lists"
const val contentLists = "content_lists"
const val contentList = "content_list"
const val searchHome = "search_home"
const val settingsHome = "settings_home"
@Serializable
@Suppress("UndocumentedPublicClass", "UndocumentedPublicProperty")
sealed interface NavigationRoutes {
@Serializable
data object HomeSamples : NavigationRoutes

@Serializable
data class HomeSample(val index: Int) : NavigationRoutes

@Serializable
data object HomeShowcases : NavigationRoutes

@Serializable
data object ShowcaseList : NavigationRoutes

@Serializable
data object ShowcasePlaybackSettings : NavigationRoutes

@Serializable
data object Story : NavigationRoutes

@Serializable
data object SimplePlayer : NavigationRoutes

@Serializable
data object Adaptive : NavigationRoutes

@Serializable
data object PlayerSwap : NavigationRoutes

@Serializable
data object ExoPlayerSample : NavigationRoutes

@Serializable
data object TrackingSample : NavigationRoutes

@Serializable
data object UpdatableSample : NavigationRoutes

@Serializable
data object SmoothSeeking : NavigationRoutes

@Serializable
data object StartAtGivenTime : NavigationRoutes

@Serializable
data object Video360 : NavigationRoutes

@Serializable
data object Chapters : NavigationRoutes

@Serializable
data object HomeLists : NavigationRoutes

@Serializable
data object ContentLists : NavigationRoutes

@Serializable
data class ContentList(val index: Int) : NavigationRoutes

@Serializable
data object SearchHome : NavigationRoutes

@Serializable
data object SettingsHome : NavigationRoutes
}
Loading

0 comments on commit 8199adc

Please sign in to comment.