mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-20 02:30:53 -05:00
TVT-56: All Account Tabs Say 'No Rated Content' When Empty
This commit is contained in:
@@ -14,6 +14,7 @@ import kotlin.reflect.KClass
|
|||||||
sealed class AccountTabNavItem(
|
sealed class AccountTabNavItem(
|
||||||
stringRes: Int,
|
stringRes: Int,
|
||||||
route: String,
|
route: String,
|
||||||
|
noContentStringRes: Int,
|
||||||
val mediaType: MediaViewType,
|
val mediaType: MediaViewType,
|
||||||
val screen: AccountNavComposableFun,
|
val screen: AccountNavComposableFun,
|
||||||
val listFetchFun: ListFetchFun,
|
val listFetchFun: ListFetchFun,
|
||||||
@@ -23,6 +24,7 @@ sealed class AccountTabNavItem(
|
|||||||
private val resourceUtils: ResourceUtils by inject()
|
private val resourceUtils: ResourceUtils by inject()
|
||||||
|
|
||||||
override val name = resourceUtils.getString(stringRes)
|
override val name = resourceUtils.getString(stringRes)
|
||||||
|
val noContentText = resourceUtils.getString(noContentStringRes)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val GuestItems
|
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 }
|
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 RatedMovies: AccountTabNavItem(
|
||||||
object RatedTvShows: AccountTabNavItem(R.string.nav_rated_shows_title, "rated_shows_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.ratedTvShows ?: emptyList() }, RatedTv::class, 1)
|
R.string.nav_rated_movies_title,
|
||||||
object RatedTvEpisodes: AccountTabNavItem(R.string.nav_rated_episodes_title, "rated_episodes_route", MediaViewType.EPISODE, screenContent, { SessionManager.currentSession?.ratedTvEpisodes ?: emptyList() }, RatedEpisode::class, 2)
|
"rated_movies_route",
|
||||||
object FavoriteMovies: AccountTabNavItem(R.string.nav_favorite_movies_title, "favorite_movies_route", MediaViewType.MOVIE, screenContent, { SessionManager.currentSession?.favoriteMovies ?: emptyList() }, FavoriteMovie::class, 3)
|
R.string.no_rated_movies,
|
||||||
object FavoriteTvShows: AccountTabNavItem(R.string.nav_favorite_tv_show_title, "favorite_shows_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.favoriteTvShows ?: emptyList() }, FavoriteTvSeries::class, 4)
|
MediaViewType.MOVIE,
|
||||||
object MovieWatchlist: AccountTabNavItem(R.string.nav_movie_watchlist_title, "movie_watchlist_route", MediaViewType.MOVIE, screenContent, { SessionManager.currentSession?.movieWatchlist ?: emptyList() }, WatchlistMovie::class, 5)
|
screenContent, { SessionManager.currentSession?.ratedMovies ?: emptyList() },
|
||||||
object TvWatchlist: AccountTabNavItem(R.string.nav_tv_watchlist_title, "tv_watchlist_route", MediaViewType.TV, screenContent, { SessionManager.currentSession?.tvWatchlist ?: emptyList() }, WatchlistTvSeries::class, 6)
|
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 ->
|
private val screenContent: AccountNavComposableFun = { noContentText, appNavController, mediaViewType, listFetchFun, clazz ->
|
||||||
AccountTabContent(appNavController = appNavController, mediaViewType = mediaViewType, listFetchFun = listFetchFun, clazz = clazz)
|
AccountTabContent(noContentText = noContentText, appNavController = appNavController, mediaViewType = mediaViewType, listFetchFun = listFetchFun, clazz = clazz)
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias ListFetchFun = () -> List<Any>
|
typealias ListFetchFun = () -> List<Any>
|
||||||
|
|
||||||
typealias AccountNavComposableFun = @Composable (NavHostController, MediaViewType, ListFetchFun, KClass<*>) -> Unit
|
typealias AccountNavComposableFun = @Composable (String, NavHostController, MediaViewType, ListFetchFun, KClass<*>) -> Unit
|
||||||
@@ -156,6 +156,7 @@ private fun getAccountName(accountDetails: AccountDetails?): String {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T: Any> AccountTabContent(
|
fun <T: Any> AccountTabContent(
|
||||||
|
noContentText: String,
|
||||||
appNavController: NavHostController,
|
appNavController: NavHostController,
|
||||||
mediaViewType: MediaViewType,
|
mediaViewType: MediaViewType,
|
||||||
listFetchFun: ListFetchFun,
|
listFetchFun: ListFetchFun,
|
||||||
@@ -163,24 +164,26 @@ fun <T: Any> AccountTabContent(
|
|||||||
) {
|
) {
|
||||||
val contentItems = listFetchFun()
|
val contentItems = listFetchFun()
|
||||||
|
|
||||||
LazyColumn(modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.padding(12.dp),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
|
||||||
if (contentItems.isEmpty()) {
|
if (contentItems.isEmpty()) {
|
||||||
item {
|
Column {
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth(),
|
||||||
.padding(horizontal = 20.dp, vertical = 15.dp),
|
text = noContentText,
|
||||||
text = stringResource(R.string.no_rated_content_message),
|
|
||||||
color = MaterialTheme.colorScheme.onBackground,
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
fontSize = 22.sp,
|
fontSize = 22.sp,
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(12.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
|
) {
|
||||||
items(contentItems.size) { i ->
|
items(contentItems.size) { i ->
|
||||||
when (clazz) {
|
when (clazz) {
|
||||||
RatedTv::class, RatedMovie::class -> {
|
RatedTv::class, RatedMovie::class -> {
|
||||||
@@ -475,6 +478,6 @@ fun AccountTabs(
|
|||||||
appNavController: NavHostController
|
appNavController: NavHostController
|
||||||
) {
|
) {
|
||||||
HorizontalPager(count = tabs.size, state = pagerState) { page ->
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,4 +173,11 @@
|
|||||||
<string name="last_episode_to_air_title">Last Episode to Air</string>
|
<string name="last_episode_to_air_title">Last Episode to Air</string>
|
||||||
<string name="original_country_title">Original Country</string>
|
<string name="original_country_title">Original Country</string>
|
||||||
<string name="tv_type_title">Type</string>
|
<string name="tv_type_title">Type</string>
|
||||||
|
<string name="no_rated_movies">No Rated Movies</string>
|
||||||
|
<string name="no_rated_tv">No Rated TV</string>
|
||||||
|
<string name="no_rated_episodes">No Rated TV Episodes</string>
|
||||||
|
<string name="no_favorite_movies">No Favorite Movies</string>
|
||||||
|
<string name="no_favorite_tv">No Favorite TV</string>
|
||||||
|
<string name="no_watchlist_movies">No Watchlisted Movies</string>
|
||||||
|
<string name="no_watchlist_tv">No Watchlisted TV</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user