mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-23 19:26:50 +00:00
feat(libraries): add size property to Library and related models for better content representation
This commit is contained in:
@@ -392,6 +392,7 @@ class TvHomeContentTest {
|
|||||||
name = "Movies",
|
name = "Movies",
|
||||||
type = LibraryKind.MOVIES,
|
type = LibraryKind.MOVIES,
|
||||||
posterUrl = "",
|
posterUrl = "",
|
||||||
|
size = 1,
|
||||||
isEmpty = false
|
isEmpty = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class TvLibrariesOverviewScreenTest {
|
|||||||
name = "Movies",
|
name = "Movies",
|
||||||
type = LibraryKind.MOVIES,
|
type = LibraryKind.MOVIES,
|
||||||
posterUrl = "",
|
posterUrl = "",
|
||||||
|
size = 1,
|
||||||
isEmpty = false
|
isEmpty = false
|
||||||
),
|
),
|
||||||
LibraryUiModel(
|
LibraryUiModel(
|
||||||
@@ -32,6 +33,7 @@ class TvLibrariesOverviewScreenTest {
|
|||||||
name = "Shows",
|
name = "Shows",
|
||||||
type = LibraryKind.SERIES,
|
type = LibraryKind.SERIES,
|
||||||
posterUrl = "",
|
posterUrl = "",
|
||||||
|
size = 1,
|
||||||
isEmpty = false
|
isEmpty = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class TvHomeHeroStateTest {
|
|||||||
name = "Movies",
|
name = "Movies",
|
||||||
type = LibraryKind.MOVIES,
|
type = LibraryKind.MOVIES,
|
||||||
posterUrl = "",
|
posterUrl = "",
|
||||||
|
size = 1,
|
||||||
isEmpty = isEmpty
|
isEmpty = isEmpty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package hu.bbara.purefin.ui.screen.libraries.components
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import hu.bbara.purefin.model.LibraryKind
|
||||||
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
import hu.bbara.purefin.ui.common.card.MediaImageCard
|
||||||
import hu.bbara.purefin.ui.model.LibraryUiModel
|
import hu.bbara.purefin.ui.model.LibraryUiModel
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ fun LibraryListItem(
|
|||||||
MediaImageCard(
|
MediaImageCard(
|
||||||
imageUrl = uiModel.posterUrl,
|
imageUrl = uiModel.posterUrl,
|
||||||
title = uiModel.name,
|
title = uiModel.name,
|
||||||
|
subtitle = "${uiModel.size} ${if (uiModel.type == LibraryKind.SERIES) "series" else "movies"}",
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ data class Library(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val type: LibraryKind,
|
val type: LibraryKind,
|
||||||
val posterUrl: String,
|
val posterUrl: String,
|
||||||
|
val size: Int,
|
||||||
val series: List<Series>? = null,
|
val series: List<Series>? = null,
|
||||||
val movies: List<Movie>? = null,
|
val movies: List<Movie>? = null,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class AppViewModel @Inject constructor(
|
|||||||
name = it.name,
|
name = it.name,
|
||||||
type = it.type,
|
type = it.type,
|
||||||
posterUrl = it.posterUrl,
|
posterUrl = it.posterUrl,
|
||||||
|
size = it.size,
|
||||||
isEmpty = when (it.type) {
|
isEmpty = when (it.type) {
|
||||||
LibraryKind.MOVIES -> mediaCatalogReader.movies.value.isEmpty()
|
LibraryKind.MOVIES -> mediaCatalogReader.movies.value.isEmpty()
|
||||||
LibraryKind.SERIES -> mediaCatalogReader.series.value.isEmpty()
|
LibraryKind.SERIES -> mediaCatalogReader.series.value.isEmpty()
|
||||||
|
|||||||
@@ -8,5 +8,6 @@ data class LibraryUiModel(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val type: LibraryKind,
|
val type: LibraryKind,
|
||||||
val posterUrl: String,
|
val posterUrl: String,
|
||||||
|
val size: Int,
|
||||||
val isEmpty: Boolean
|
val isEmpty: Boolean
|
||||||
)
|
)
|
||||||
@@ -230,9 +230,11 @@ class InMemoryAppContentRepository @Inject constructor(
|
|||||||
return when (library.type) {
|
return when (library.type) {
|
||||||
LibraryKind.MOVIES -> library.copy(
|
LibraryKind.MOVIES -> library.copy(
|
||||||
movies = contentItem.map { it.toMovie(serverUrl()) },
|
movies = contentItem.map { it.toMovie(serverUrl()) },
|
||||||
|
size = contentItem.size,
|
||||||
)
|
)
|
||||||
LibraryKind.SERIES -> library.copy(
|
LibraryKind.SERIES -> library.copy(
|
||||||
series = contentItem.map { it.toSeries(serverUrl()) },
|
series = contentItem.map { it.toSeries(serverUrl()) },
|
||||||
|
size = contentItem.size,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ fun BaseItemDto.toLibrary(serverUrl: String): Library {
|
|||||||
artworkKind = ArtworkKind.PRIMARY
|
artworkKind = ArtworkKind.PRIMARY
|
||||||
),
|
),
|
||||||
type = LibraryKind.MOVIES,
|
type = LibraryKind.MOVIES,
|
||||||
|
size = childCount ?: 0,
|
||||||
movies = emptyList(),
|
movies = emptyList(),
|
||||||
)
|
)
|
||||||
CollectionType.TVSHOWS -> Library(
|
CollectionType.TVSHOWS -> Library(
|
||||||
@@ -38,6 +39,7 @@ fun BaseItemDto.toLibrary(serverUrl: String): Library {
|
|||||||
artworkKind = ArtworkKind.PRIMARY
|
artworkKind = ArtworkKind.PRIMARY
|
||||||
),
|
),
|
||||||
type = LibraryKind.SERIES,
|
type = LibraryKind.SERIES,
|
||||||
|
size = childCount ?: 0,
|
||||||
series = emptyList(),
|
series = emptyList(),
|
||||||
)
|
)
|
||||||
else -> throw UnsupportedOperationException("Unsupported library type: $collectionType")
|
else -> throw UnsupportedOperationException("Unsupported library type: $collectionType")
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ data class CachedLibrary(
|
|||||||
val name: String,
|
val name: String,
|
||||||
val type: String,
|
val type: String,
|
||||||
val posterUrl: String,
|
val posterUrl: String,
|
||||||
|
val size: Int = 0,
|
||||||
val series: List<CachedSeries>? = null,
|
val series: List<CachedSeries>? = null,
|
||||||
val movies: List<CachedMovie>? = null,
|
val movies: List<CachedMovie>? = null,
|
||||||
)
|
)
|
||||||
@@ -100,6 +101,7 @@ fun Library.toCachedLibrary() = CachedLibrary(
|
|||||||
name = name,
|
name = name,
|
||||||
type = type.name,
|
type = type.name,
|
||||||
posterUrl = posterUrl,
|
posterUrl = posterUrl,
|
||||||
|
size = size,
|
||||||
series = series?.map { it.toCachedSeries() },
|
series = series?.map { it.toCachedSeries() },
|
||||||
movies = movies?.map { it.toCachedMovie() },
|
movies = movies?.map { it.toCachedMovie() },
|
||||||
)
|
)
|
||||||
@@ -112,6 +114,7 @@ fun CachedLibrary.toLibrary(): Library? {
|
|||||||
name = name,
|
name = name,
|
||||||
type = LibraryKind.MOVIES,
|
type = LibraryKind.MOVIES,
|
||||||
posterUrl = posterUrl,
|
posterUrl = posterUrl,
|
||||||
|
size = size,
|
||||||
movies = movies?.mapNotNull { it.toMovie() } ?: emptyList(),
|
movies = movies?.mapNotNull { it.toMovie() } ?: emptyList(),
|
||||||
)
|
)
|
||||||
"SERIES" -> Library(
|
"SERIES" -> Library(
|
||||||
@@ -119,6 +122,7 @@ fun CachedLibrary.toLibrary(): Library? {
|
|||||||
name = name,
|
name = name,
|
||||||
type = LibraryKind.SERIES,
|
type = LibraryKind.SERIES,
|
||||||
posterUrl = posterUrl,
|
posterUrl = posterUrl,
|
||||||
|
size = size,
|
||||||
series = series?.mapNotNull { it.toSeries() } ?: emptyList(),
|
series = series?.mapNotNull { it.toSeries() } ?: emptyList(),
|
||||||
)
|
)
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
Reference in New Issue
Block a user