mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-24 03:36:51 +00:00
refactor: Use MediaUiModel instead of SuggestedItem
This commit is contained in:
@@ -14,7 +14,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||
import hu.bbara.purefin.feature.browse.home.LibraryItem
|
||||
import hu.bbara.purefin.feature.browse.home.SuggestedItem
|
||||
import hu.bbara.purefin.ui.screen.AppBottomBar
|
||||
import hu.bbara.purefin.ui.screen.home.components.HomeContent
|
||||
import hu.bbara.purefin.ui.screen.home.components.HomeTopBar
|
||||
@@ -26,7 +25,7 @@ import java.util.UUID
|
||||
fun HomeScreen(
|
||||
libraries: List<LibraryItem>,
|
||||
libraryContent: Map<UUID, List<MediaUiModel>>,
|
||||
suggestions: List<SuggestedItem>,
|
||||
suggestions: List<MediaUiModel>,
|
||||
continueWatching: List<MediaUiModel>,
|
||||
nextUp: List<MediaUiModel>,
|
||||
isRefreshing: Boolean,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package hu.bbara.purefin.ui.screen.home.components
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -22,10 +21,11 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import hu.bbara.purefin.core.model.MediaKind
|
||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||
import hu.bbara.purefin.core.ui.model.MovieUiModel
|
||||
import hu.bbara.purefin.core.ui.model.SeriesUiModel
|
||||
import hu.bbara.purefin.feature.browse.home.LibraryItem
|
||||
import hu.bbara.purefin.feature.browse.home.SuggestedItem
|
||||
import hu.bbara.purefin.ui.screen.home.components.continuewatching.ContinueWatchingSection
|
||||
import hu.bbara.purefin.ui.screen.home.components.featured.SuggestionsSection
|
||||
import hu.bbara.purefin.ui.screen.home.components.library.LibraryPosterSection
|
||||
@@ -37,7 +37,7 @@ import java.util.UUID
|
||||
fun HomeContent(
|
||||
libraries: List<LibraryItem>,
|
||||
libraryContent: Map<UUID, List<MediaUiModel>>,
|
||||
suggestions: List<SuggestedItem>,
|
||||
suggestions: List<MediaUiModel>,
|
||||
continueWatching: List<MediaUiModel>,
|
||||
nextUp: List<MediaUiModel>,
|
||||
isRefreshing: Boolean,
|
||||
@@ -102,13 +102,10 @@ fun HomeContent(
|
||||
SuggestionsSection(
|
||||
items = suggestions,
|
||||
onItemOpen = { item ->
|
||||
when (item.type) {
|
||||
MediaKind.MOVIE -> onMovieSelected(item.id)
|
||||
MediaKind.SERIES -> onSeriesSelected(item.id)
|
||||
MediaKind.EPISODE -> onEpisodeSelected(item.id, item.id, item.id)
|
||||
else -> {
|
||||
Log.e("HomeContent", "Unsupported item type: ${item.type}")
|
||||
}
|
||||
when (item) {
|
||||
is MovieUiModel -> onMovieSelected(item.id)
|
||||
is SeriesUiModel -> onSeriesSelected(item.id)
|
||||
is EpisodeUiModel -> onEpisodeSelected(item.id, item.id, item.id)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -24,13 +24,13 @@ import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||
import hu.bbara.purefin.feature.browse.home.SuggestedItem
|
||||
|
||||
@Composable
|
||||
internal fun SuggestionCard(
|
||||
item: SuggestedItem,
|
||||
item: MediaUiModel,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -51,8 +51,8 @@ internal fun SuggestionCard(
|
||||
.aspectRatio(16f / 11f)
|
||||
) {
|
||||
PurefinAsyncImage(
|
||||
model = item.imageUrl,
|
||||
contentDescription = item.title,
|
||||
model = item.primaryImageUrl,
|
||||
contentDescription = item.primaryText,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
@@ -77,32 +77,28 @@ internal fun SuggestionCard(
|
||||
) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text(
|
||||
text = item.title,
|
||||
text = item.primaryText,
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
color = Color.White,
|
||||
fontWeight = FontWeight.Bold,
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
if (item.metadata.isNotEmpty()) {
|
||||
Text(
|
||||
text = item.metadata.joinToString(" • "),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = Color.White.copy(alpha = 0.88f),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
if (description.isNotBlank()) {
|
||||
Text(
|
||||
text = description,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = Color.White.copy(alpha = 0.88f),
|
||||
maxLines = 3,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.widthIn(max = 520.dp)
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = item.secondaryText,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = Color.White.copy(alpha = 0.88f),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Text(
|
||||
text = description,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = Color.White.copy(alpha = 0.88f),
|
||||
maxLines = 3,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.widthIn(max = 520.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (item.progress != null && item.progress!! > 0f) {
|
||||
|
||||
@@ -22,12 +22,12 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
import hu.bbara.purefin.feature.browse.home.SuggestedItem
|
||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||
|
||||
@Composable
|
||||
fun SuggestionsSection(
|
||||
items: List<SuggestedItem>,
|
||||
onItemOpen: (SuggestedItem) -> Unit,
|
||||
items: List<MediaUiModel>,
|
||||
onItemOpen: (MediaUiModel) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
if (items.isEmpty()) return
|
||||
|
||||
Reference in New Issue
Block a user