diff --git a/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/AccountTabNavItem.kt b/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/AccountTabNavItem.kt index 71883cd..acc2972 100644 --- a/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/AccountTabNavItem.kt +++ b/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/AccountTabNavItem.kt @@ -14,6 +14,7 @@ import kotlin.reflect.KClass sealed class AccountTabNavItem( stringRes: Int, route: String, + noContentStringRes: Int, val mediaType: MediaViewType, val screen: AccountNavComposableFun, val listFetchFun: ListFetchFun, @@ -23,6 +24,7 @@ sealed class AccountTabNavItem( private val resourceUtils: ResourceUtils by inject() override val name = resourceUtils.getString(stringRes) + val noContentText = resourceUtils.getString(noContentStringRes) companion object { val GuestItems @@ -32,19 +34,75 @@ sealed class AccountTabNavItem( get() = listOf(RatedMovies, RatedTvShows, RatedTvEpisodes, FavoriteMovies, FavoriteTvShows, MovieWatchlist, TvWatchlist).filter { it.ordinal > -1 }.sortedBy { it.ordinal } } - object RatedMovies: AccountTabNavItem(R.string.nav_rated_movies_title, "rated_movies_route", MediaViewType.MOVIE, screenContent, { SessionManager.currentSession?.ratedMovies ?: emptyList() }, RatedMovie::class, 0) - object RatedTvShows: AccountTabNavItem(R.string.nav_rated_shows_title, "rated_shows_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.ratedTvShows ?: emptyList() }, RatedTv::class, 1) - object RatedTvEpisodes: AccountTabNavItem(R.string.nav_rated_episodes_title, "rated_episodes_route", MediaViewType.EPISODE, screenContent, { SessionManager.currentSession?.ratedTvEpisodes ?: emptyList() }, RatedEpisode::class, 2) - object FavoriteMovies: AccountTabNavItem(R.string.nav_favorite_movies_title, "favorite_movies_route", MediaViewType.MOVIE, screenContent, { SessionManager.currentSession?.favoriteMovies ?: emptyList() }, FavoriteMovie::class, 3) - object FavoriteTvShows: AccountTabNavItem(R.string.nav_favorite_tv_show_title, "favorite_shows_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.favoriteTvShows ?: emptyList() }, FavoriteTvSeries::class, 4) - object MovieWatchlist: AccountTabNavItem(R.string.nav_movie_watchlist_title, "movie_watchlist_route", MediaViewType.MOVIE, screenContent, { SessionManager.currentSession?.movieWatchlist ?: emptyList() }, WatchlistMovie::class, 5) - object TvWatchlist: AccountTabNavItem(R.string.nav_tv_watchlist_title, "tv_watchlist_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.tvWatchlist ?: emptyList() }, WatchlistTvSeries::class, 6) + object RatedMovies: AccountTabNavItem( + R.string.nav_rated_movies_title, + "rated_movies_route", + R.string.no_rated_movies, + MediaViewType.MOVIE, + screenContent, { SessionManager.currentSession?.ratedMovies ?: emptyList() }, + RatedMovie::class, + 0 + ) + object RatedTvShows: AccountTabNavItem( + R.string.nav_rated_shows_title, + "rated_shows_route", + R.string.no_rated_tv, + MediaViewType.TV, + screenContent, { SessionManager.currentSession?.ratedTvShows ?: emptyList() }, + RatedTv::class, + 1 + ) + object RatedTvEpisodes: AccountTabNavItem( + R.string.nav_rated_episodes_title, + "rated_episodes_route", + R.string.no_rated_episodes, + MediaViewType.EPISODE, + screenContent, { SessionManager.currentSession?.ratedTvEpisodes ?: emptyList() }, + RatedEpisode::class, + 2 + ) + object FavoriteMovies: AccountTabNavItem( + R.string.nav_favorite_movies_title, + "favorite_movies_route", + R.string.no_favorite_movies, + MediaViewType.MOVIE, + screenContent, { SessionManager.currentSession?.favoriteMovies ?: emptyList() }, + FavoriteMovie::class, + 3 + ) + object FavoriteTvShows: AccountTabNavItem( + R.string.nav_favorite_tv_show_title, + "favorite_shows_route", + R.string.no_favorite_tv, + MediaViewType.TV, + screenContent, { SessionManager.currentSession?.favoriteTvShows ?: emptyList() }, + FavoriteTvSeries::class, + 4 + ) + object MovieWatchlist: AccountTabNavItem( + R.string.nav_movie_watchlist_title, + "movie_watchlist_route", + R.string.no_watchlist_movies, + MediaViewType.MOVIE, + screenContent, { SessionManager.currentSession?.movieWatchlist ?: emptyList() }, + WatchlistMovie::class, + 5 + ) + object TvWatchlist: AccountTabNavItem( + R.string.nav_tv_watchlist_title, + "tv_watchlist_route", + R.string.no_watchlist_tv, + MediaViewType.TV, + screenContent, { SessionManager.currentSession?.tvWatchlist ?: emptyList() }, + WatchlistTvSeries::class, + 6 + ) } -private val screenContent: AccountNavComposableFun = { appNavController, mediaViewType, listFetchFun, clazz -> - AccountTabContent(appNavController = appNavController, mediaViewType = mediaViewType, listFetchFun = listFetchFun, clazz = clazz) +private val screenContent: AccountNavComposableFun = { noContentText, appNavController, mediaViewType, listFetchFun, clazz -> + AccountTabContent(noContentText = noContentText, appNavController = appNavController, mediaViewType = mediaViewType, listFetchFun = listFetchFun, clazz = clazz) } typealias ListFetchFun = () -> List -typealias AccountNavComposableFun = @Composable (NavHostController, MediaViewType, ListFetchFun, KClass<*>) -> Unit \ No newline at end of file +typealias AccountNavComposableFun = @Composable (String, NavHostController, MediaViewType, ListFetchFun, KClass<*>) -> Unit \ No newline at end of file diff --git a/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AccountTab.kt b/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AccountTab.kt index aaf73a8..0a569c9 100644 --- a/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AccountTab.kt +++ b/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AccountTab.kt @@ -156,6 +156,7 @@ private fun getAccountName(accountDetails: AccountDetails?): String { @Composable fun AccountTabContent( + noContentText: String, appNavController: NavHostController, mediaViewType: MediaViewType, listFetchFun: ListFetchFun, @@ -163,24 +164,26 @@ fun AccountTabContent( ) { val contentItems = listFetchFun() - LazyColumn(modifier = Modifier - .fillMaxSize() - .padding(12.dp), - verticalArrangement = Arrangement.spacedBy(8.dp) - ) { - if (contentItems.isEmpty()) { - item { - Text( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 15.dp), - text = stringResource(R.string.no_rated_content_message), - color = MaterialTheme.colorScheme.onBackground, - fontSize = 22.sp, - textAlign = TextAlign.Center - ) - } - } else { + if (contentItems.isEmpty()) { + Column { + Spacer(modifier = Modifier.weight(1f)) + Text( + modifier = Modifier + .fillMaxWidth(), + text = noContentText, + color = MaterialTheme.colorScheme.onBackground, + fontSize = 22.sp, + textAlign = TextAlign.Center + ) + Spacer(modifier = Modifier.weight(1f)) + } + } else { + LazyColumn( + modifier = Modifier + .fillMaxSize() + .padding(12.dp), + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { items(contentItems.size) { i -> when (clazz) { RatedTv::class, RatedMovie::class -> { @@ -475,6 +478,6 @@ fun AccountTabs( appNavController: NavHostController ) { HorizontalPager(count = tabs.size, state = pagerState) { page -> - tabs[page].screen(appNavController, tabs[page].mediaType, tabs[page].listFetchFun, tabs[page].listType) + tabs[page].screen(tabs[page].noContentText, appNavController, tabs[page].mediaType, tabs[page].listFetchFun, tabs[page].listType) } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2ea2a84..a5c193d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -173,4 +173,11 @@ Last Episode to Air Original Country Type + No Rated Movies + No Rated TV + No Rated TV Episodes + No Favorite Movies + No Favorite TV + No Watchlisted Movies + No Watchlisted TV \ No newline at end of file