mirror of
https://github.com/bbara04/Purefin.git
synced 2026-07-24 03:36:51 +00:00
Refactor media selection logic to use a unified onMediaSelected callback
Consolidates specific media selection callbacks (`onMovieSelected`, `onSeriesSelected`, `onEpisodeSelected`) into a single `onMediaSelected` handler that accepts a `MediaUiModel`. This simplifies the interface between the ViewModel and UI components across both mobile and TV screens, moving the type-checking logic into `AppViewModel`.
This commit is contained in:
@@ -76,9 +76,7 @@ fun TvAppScreen(
|
|||||||
libraryContent = latestLibraryContent,
|
libraryContent = latestLibraryContent,
|
||||||
continueWatching = continueWatching,
|
continueWatching = continueWatching,
|
||||||
nextUp = nextUp,
|
nextUp = nextUp,
|
||||||
onMovieSelected = viewModel::onMovieSelected,
|
onMediaSelected = viewModel::onMediaSelected,
|
||||||
onSeriesSelected = viewModel::onSeriesSelected,
|
|
||||||
onEpisodeSelected = viewModel::onEpisodeSelected,
|
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ fun TvHomeScreen(
|
|||||||
libraryContent: Map<UUID, List<MediaUiModel>>,
|
libraryContent: Map<UUID, List<MediaUiModel>>,
|
||||||
continueWatching: List<MediaUiModel>,
|
continueWatching: List<MediaUiModel>,
|
||||||
nextUp: List<MediaUiModel>,
|
nextUp: List<MediaUiModel>,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val scheme = MaterialTheme.colorScheme
|
val scheme = MaterialTheme.colorScheme
|
||||||
@@ -53,9 +51,7 @@ fun TvHomeScreen(
|
|||||||
onMediaFocused = {
|
onMediaFocused = {
|
||||||
focusedMediaUiModel.value = it
|
focusedMediaUiModel.value = it
|
||||||
},
|
},
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected,
|
||||||
onSeriesSelected = onSeriesSelected,
|
|
||||||
onEpisodeSelected = onEpisodeSelected,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.weight(1f)
|
.weight(1f)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ fun TvHomeContent(
|
|||||||
continueWatching: List<MediaUiModel>,
|
continueWatching: List<MediaUiModel>,
|
||||||
nextUp: List<MediaUiModel>,
|
nextUp: List<MediaUiModel>,
|
||||||
onMediaFocused: (MediaUiModel) -> Unit,
|
onMediaFocused: (MediaUiModel) -> Unit,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
contentPadding: PaddingValues = PaddingValues(bottom = 32.dp),
|
contentPadding: PaddingValues = PaddingValues(bottom = 32.dp),
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
@@ -81,8 +79,7 @@ fun TvHomeContent(
|
|||||||
TvContinueWatchingSection(
|
TvContinueWatchingSection(
|
||||||
items = continueWatching,
|
items = continueWatching,
|
||||||
onFocusedItem = onMediaFocused,
|
onFocusedItem = onMediaFocused,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected,
|
||||||
onEpisodeSelected = onEpisodeSelected,
|
|
||||||
firstItemFocusRequester = initialFocusRequester,
|
firstItemFocusRequester = initialFocusRequester,
|
||||||
firstItemTestTag = TvHomeInitialFocusTag,
|
firstItemTestTag = TvHomeInitialFocusTag,
|
||||||
rowTestTag = TvHomeContinueWatchingRowTag
|
rowTestTag = TvHomeContinueWatchingRowTag
|
||||||
@@ -95,7 +92,7 @@ fun TvHomeContent(
|
|||||||
TvNextUpSection(
|
TvNextUpSection(
|
||||||
items = nextUp,
|
items = nextUp,
|
||||||
onFocusedItem = onMediaFocused,
|
onFocusedItem = onMediaFocused,
|
||||||
onEpisodeSelected = onEpisodeSelected,
|
onMediaSelected = onMediaSelected,
|
||||||
firstItemFocusRequester = initialFocusRequester.takeIf { !hasContinueWatching },
|
firstItemFocusRequester = initialFocusRequester.takeIf { !hasContinueWatching },
|
||||||
firstItemTestTag = TvHomeInitialFocusTag.takeIf { !hasContinueWatching },
|
firstItemTestTag = TvHomeInitialFocusTag.takeIf { !hasContinueWatching },
|
||||||
rowTestTag = TvHomeNextUpRowTag
|
rowTestTag = TvHomeNextUpRowTag
|
||||||
@@ -115,9 +112,7 @@ fun TvHomeContent(
|
|||||||
!hasContinueWatching && !hasNextUp && library.id == firstLibraryWithItemsId
|
!hasContinueWatching && !hasNextUp && library.id == firstLibraryWithItemsId
|
||||||
},
|
},
|
||||||
firstItemTestTag = tvHomeLibraryFirstItemTag(library.id),
|
firstItemTestTag = tvHomeLibraryFirstItemTag(library.id),
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected
|
||||||
onSeriesSelected = onSeriesSelected,
|
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
||||||
import hu.bbara.purefin.ui.common.card.PosterCard
|
import hu.bbara.purefin.ui.common.card.PosterCardContent
|
||||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@@ -83,8 +82,7 @@ internal fun tvHomeLibraryFirstItemTag(libraryId: UUID): String =
|
|||||||
fun TvContinueWatchingSection(
|
fun TvContinueWatchingSection(
|
||||||
items: List<MediaUiModel>,
|
items: List<MediaUiModel>,
|
||||||
onFocusedItem: (MediaUiModel) -> Unit = {},
|
onFocusedItem: (MediaUiModel) -> Unit = {},
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
firstItemFocusRequester: FocusRequester? = null,
|
firstItemFocusRequester: FocusRequester? = null,
|
||||||
firstItemTestTag: String? = null,
|
firstItemTestTag: String? = null,
|
||||||
rowTestTag: String? = null,
|
rowTestTag: String? = null,
|
||||||
@@ -120,13 +118,7 @@ fun TvContinueWatchingSection(
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
onFocusedItem = { onFocusedItem(item) },
|
onFocusedItem = { onFocusedItem(item) },
|
||||||
onClick = {
|
onClick = { onMediaSelected(item) }
|
||||||
when (item) {
|
|
||||||
//TODO fix this shit
|
|
||||||
is EpisodeUiModel -> onEpisodeSelected(item.seriesId, item.seasonId, item.id)
|
|
||||||
else -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +128,7 @@ fun TvContinueWatchingSection(
|
|||||||
fun TvNextUpSection(
|
fun TvNextUpSection(
|
||||||
items: List<MediaUiModel>,
|
items: List<MediaUiModel>,
|
||||||
onFocusedItem: (MediaUiModel) -> Unit = {},
|
onFocusedItem: (MediaUiModel) -> Unit = {},
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
firstItemFocusRequester: FocusRequester? = null,
|
firstItemFocusRequester: FocusRequester? = null,
|
||||||
firstItemTestTag: String? = null,
|
firstItemTestTag: String? = null,
|
||||||
rowTestTag: String? = null,
|
rowTestTag: String? = null,
|
||||||
@@ -171,12 +163,7 @@ fun TvNextUpSection(
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
onFocusedItem = { onFocusedItem(item) },
|
onFocusedItem = { onFocusedItem(item) },
|
||||||
onClick = {
|
onClick = { onMediaSelected(item) }
|
||||||
//TODO FIX
|
|
||||||
(item as? EpisodeUiModel)?.let { episode ->
|
|
||||||
onEpisodeSelected(episode.seriesId, episode.seasonId, episode.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,9 +178,7 @@ fun TvLibraryPosterSection(
|
|||||||
firstItemTestTag: String? = null,
|
firstItemTestTag: String? = null,
|
||||||
rowTestTag: String? = null,
|
rowTestTag: String? = null,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
) {
|
) {
|
||||||
TvSectionHeader(
|
TvSectionHeader(
|
||||||
title = title,
|
title = title,
|
||||||
@@ -203,8 +188,9 @@ fun TvLibraryPosterSection(
|
|||||||
rowTestTag = rowTestTag
|
rowTestTag = rowTestTag
|
||||||
) {
|
) {
|
||||||
itemsIndexed(items = items, key = { _, item -> item.id }) { index, item ->
|
itemsIndexed(items = items, key = { _, item -> item.id }) { index, item ->
|
||||||
PosterCard(
|
PosterCardContent(
|
||||||
item = item,
|
model = item,
|
||||||
|
onClick = { onMediaSelected(item) },
|
||||||
posterWidth = TvHomePosterCardWidth,
|
posterWidth = TvHomePosterCardWidth,
|
||||||
contentScale = TvHomeMediaCardScale,
|
contentScale = TvHomeMediaCardScale,
|
||||||
showSecondaryText = true,
|
showSecondaryText = true,
|
||||||
@@ -225,10 +211,9 @@ fun TvLibraryPosterSection(
|
|||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
onFocusedItem = onFocusedItem,
|
onFocused = { onFocusedItem(item) },
|
||||||
onMovieSelected = onMovieSelected,
|
focusedScale = 1.07f,
|
||||||
onSeriesSelected = onSeriesSelected,
|
focusedBorderWidth = 2.dp
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ fun AppScreen(
|
|||||||
nextUp = nextUp,
|
nextUp = nextUp,
|
||||||
isRefreshing = isRefreshing,
|
isRefreshing = isRefreshing,
|
||||||
onRefresh = viewModel::onRefresh,
|
onRefresh = viewModel::onRefresh,
|
||||||
onMovieSelected = viewModel::onMovieSelected,
|
onMediaSelected = viewModel::onMediaSelected,
|
||||||
onSeriesSelected = viewModel::onSeriesSelected,
|
|
||||||
onEpisodeSelected = viewModel::onEpisodeSelected,
|
|
||||||
onLibrarySelected = { library ->
|
onLibrarySelected = { library ->
|
||||||
viewModel.onLibrarySelected(
|
viewModel.onLibrarySelected(
|
||||||
library.id,
|
library.id,
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ fun HomeScreen(
|
|||||||
nextUp: List<MediaUiModel>,
|
nextUp: List<MediaUiModel>,
|
||||||
isRefreshing: Boolean,
|
isRefreshing: Boolean,
|
||||||
onRefresh: () -> Unit,
|
onRefresh: () -> Unit,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
onLibrarySelected: (LibraryItem) -> Unit,
|
onLibrarySelected: (LibraryItem) -> Unit,
|
||||||
onProfileClick: () -> Unit,
|
onProfileClick: () -> Unit,
|
||||||
onSettingsClick: () -> Unit,
|
onSettingsClick: () -> Unit,
|
||||||
@@ -72,9 +70,7 @@ fun HomeScreen(
|
|||||||
nextUp = nextUp,
|
nextUp = nextUp,
|
||||||
isRefreshing = isRefreshing,
|
isRefreshing = isRefreshing,
|
||||||
onRefresh = onRefresh,
|
onRefresh = onRefresh,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected,
|
||||||
onSeriesSelected = onSeriesSelected,
|
|
||||||
onEpisodeSelected = onEpisodeSelected,
|
|
||||||
onLibrarySelected = onLibrarySelected,
|
onLibrarySelected = onLibrarySelected,
|
||||||
onBrowseLibrariesClick = { onTabSelected(1) },
|
onBrowseLibrariesClick = { onTabSelected(1) },
|
||||||
modifier = Modifier.padding(innerPadding)
|
modifier = Modifier.padding(innerPadding)
|
||||||
@@ -85,11 +81,12 @@ fun HomeScreen(
|
|||||||
onDismiss = { isSearchVisible = false },
|
onDismiss = { isSearchVisible = false },
|
||||||
onMovieSelected = {
|
onMovieSelected = {
|
||||||
isSearchVisible = false
|
isSearchVisible = false
|
||||||
onMovieSelected(it)
|
//TODO use MediaUiModel as well
|
||||||
|
//onMovieSelected(it)
|
||||||
},
|
},
|
||||||
onSeriesSelected = {
|
onSeriesSelected = {
|
||||||
isSearchVisible = false
|
isSearchVisible = false
|
||||||
onSeriesSelected(it)
|
//onSeriesSelected(it)
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.runtime.snapshotFlow
|
import androidx.compose.runtime.snapshotFlow
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
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.LibraryItem
|
||||||
import hu.bbara.purefin.ui.screen.home.components.continuewatching.ContinueWatchingSection
|
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.featured.SuggestionsSection
|
||||||
@@ -42,9 +39,7 @@ fun HomeContent(
|
|||||||
nextUp: List<MediaUiModel>,
|
nextUp: List<MediaUiModel>,
|
||||||
isRefreshing: Boolean,
|
isRefreshing: Boolean,
|
||||||
onRefresh: () -> Unit,
|
onRefresh: () -> Unit,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
onLibrarySelected: (LibraryItem) -> Unit,
|
onLibrarySelected: (LibraryItem) -> Unit,
|
||||||
onBrowseLibrariesClick: () -> Unit,
|
onBrowseLibrariesClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
@@ -101,13 +96,7 @@ fun HomeContent(
|
|||||||
item(key = "featured") {
|
item(key = "featured") {
|
||||||
SuggestionsSection(
|
SuggestionsSection(
|
||||||
items = suggestions,
|
items = suggestions,
|
||||||
onItemOpen = { item ->
|
onItemOpen = { item -> onMediaSelected(item) }
|
||||||
when (item) {
|
|
||||||
is MovieUiModel -> onMovieSelected(item.id)
|
|
||||||
is SeriesUiModel -> onSeriesSelected(item.id)
|
|
||||||
is EpisodeUiModel -> onEpisodeSelected(item.id, item.id, item.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,8 +105,7 @@ fun HomeContent(
|
|||||||
item(key = "continue-watching") {
|
item(key = "continue-watching") {
|
||||||
ContinueWatchingSection(
|
ContinueWatchingSection(
|
||||||
items = continueWatching,
|
items = continueWatching,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +114,7 @@ fun HomeContent(
|
|||||||
item(key = "next-up") {
|
item(key = "next-up") {
|
||||||
NextUpSection(
|
NextUpSection(
|
||||||
items = nextUp,
|
items = nextUp,
|
||||||
onEpisodeSelected = onEpisodeSelected
|
onMediaSelected = onMediaSelected
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,9 +127,7 @@ fun HomeContent(
|
|||||||
library = library,
|
library = library,
|
||||||
items = libraryContent[library.id].orEmpty(),
|
items = libraryContent[library.id].orEmpty(),
|
||||||
onLibrarySelected = onLibrarySelected,
|
onLibrarySelected = onLibrarySelected,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected
|
||||||
onSeriesSelected = onSeriesSelected,
|
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,14 @@ import androidx.compose.ui.layout.ContentScale
|
|||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.core.ui.model.MovieUiModel
|
|
||||||
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
import hu.bbara.purefin.ui.common.bar.MediaProgressBar
|
||||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ContinueWatchingCard(
|
internal fun ContinueWatchingCard(
|
||||||
item: MediaUiModel,
|
item: MediaUiModel,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val scheme = MaterialTheme.colorScheme
|
val scheme = MaterialTheme.colorScheme
|
||||||
@@ -47,14 +43,7 @@ internal fun ContinueWatchingCard(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable { onMediaSelected(item) }
|
||||||
// TODO fix this shit as well
|
|
||||||
when (item) {
|
|
||||||
is MovieUiModel -> onMovieSelected(item.id)
|
|
||||||
is EpisodeUiModel -> onEpisodeSelected(item.seriesId, item.seasonId, item.id)
|
|
||||||
else -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.ui.common.header.SectionHeader
|
import hu.bbara.purefin.ui.common.header.SectionHeader
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ContinueWatchingSection(
|
fun ContinueWatchingSection(
|
||||||
items: List<MediaUiModel>,
|
items: List<MediaUiModel>,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
if (items.isEmpty()) return
|
if (items.isEmpty()) return
|
||||||
@@ -35,8 +33,7 @@ fun ContinueWatchingSection(
|
|||||||
items(items = items, key = { item -> item.id }) { item ->
|
items(items = items, key = { item -> item.id }) { item ->
|
||||||
ContinueWatchingCard(
|
ContinueWatchingCard(
|
||||||
item = item,
|
item = item,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,17 +26,13 @@ import androidx.compose.ui.unit.dp
|
|||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.core.ui.model.MovieUiModel
|
import hu.bbara.purefin.core.ui.model.MovieUiModel
|
||||||
import hu.bbara.purefin.core.ui.model.SeriesUiModel
|
|
||||||
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
import hu.bbara.purefin.ui.common.badge.WatchStateBadge
|
||||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun HomeBrowseCard(
|
internal fun HomeBrowseCard(
|
||||||
uiModel: MediaUiModel,
|
uiModel: MediaUiModel,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val scheme = MaterialTheme.colorScheme
|
val scheme = MaterialTheme.colorScheme
|
||||||
@@ -49,14 +45,7 @@ internal fun HomeBrowseCard(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable { onMediaSelected(uiModel) }
|
||||||
//TODO fix this shit
|
|
||||||
when (uiModel) {
|
|
||||||
is MovieUiModel -> onMovieSelected(uiModel.id)
|
|
||||||
is SeriesUiModel -> onSeriesSelected(uiModel.id)
|
|
||||||
is EpisodeUiModel -> onEpisodeSelected(uiModel.seriesId, uiModel.seasonId, uiModel.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -12,16 +12,13 @@ import androidx.compose.ui.unit.dp
|
|||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.feature.browse.home.LibraryItem
|
import hu.bbara.purefin.feature.browse.home.LibraryItem
|
||||||
import hu.bbara.purefin.ui.common.header.SectionHeader
|
import hu.bbara.purefin.ui.common.header.SectionHeader
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LibraryPosterSection(
|
fun LibraryPosterSection(
|
||||||
library: LibraryItem,
|
library: LibraryItem,
|
||||||
items: List<MediaUiModel>,
|
items: List<MediaUiModel>,
|
||||||
onLibrarySelected: (LibraryItem) -> Unit,
|
onLibrarySelected: (LibraryItem) -> Unit,
|
||||||
onMovieSelected: (UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
onSeriesSelected: (UUID) -> Unit,
|
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
if (items.isEmpty()) return
|
if (items.isEmpty()) return
|
||||||
@@ -43,9 +40,7 @@ fun LibraryPosterSection(
|
|||||||
items(items = items, key = { item -> item.id }) { item ->
|
items(items = items, key = { item -> item.id }) { item ->
|
||||||
HomeBrowseCard(
|
HomeBrowseCard(
|
||||||
uiModel = item,
|
uiModel = item,
|
||||||
onMovieSelected = onMovieSelected,
|
onMediaSelected = onMediaSelected
|
||||||
onSeriesSelected = onSeriesSelected,
|
|
||||||
onEpisodeSelected = onEpisodeSelected
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,15 +22,13 @@ import androidx.compose.ui.layout.ContentScale
|
|||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
import hu.bbara.purefin.ui.common.image.PurefinAsyncImage
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun NextUpCard(
|
internal fun NextUpCard(
|
||||||
uiModel: MediaUiModel,
|
uiModel: MediaUiModel,
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val scheme = MaterialTheme.colorScheme
|
val scheme = MaterialTheme.colorScheme
|
||||||
@@ -43,13 +41,7 @@ internal fun NextUpCard(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable {
|
.clickable { onMediaSelected(uiModel) }
|
||||||
// TODO fix this shit
|
|
||||||
when (uiModel) {
|
|
||||||
is EpisodeUiModel -> onEpisodeSelected(uiModel.seriesId, uiModel.seasonId, uiModel.id)
|
|
||||||
else -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
import hu.bbara.purefin.core.ui.model.MediaUiModel
|
||||||
import hu.bbara.purefin.ui.common.header.SectionHeader
|
import hu.bbara.purefin.ui.common.header.SectionHeader
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NextUpSection(
|
fun NextUpSection(
|
||||||
items: List<MediaUiModel>,
|
items: List<MediaUiModel>,
|
||||||
onEpisodeSelected: (UUID, UUID, UUID) -> Unit,
|
onMediaSelected: (MediaUiModel) -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
if (items.isEmpty()) return
|
if (items.isEmpty()) return
|
||||||
@@ -34,7 +33,7 @@ fun NextUpSection(
|
|||||||
items(items = items, key = { item -> item.id }) { item ->
|
items(items = items, key = { item -> item.id }) { item ->
|
||||||
NextUpCard(
|
NextUpCard(
|
||||||
uiModel = item,
|
uiModel = item,
|
||||||
onEpisodeSelected = onEpisodeSelected
|
onMediaSelected = onMediaSelected
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import hu.bbara.purefin.core.navigation.NavigationManager
|
|||||||
import hu.bbara.purefin.core.navigation.Route
|
import hu.bbara.purefin.core.navigation.Route
|
||||||
import hu.bbara.purefin.core.navigation.SeriesDto
|
import hu.bbara.purefin.core.navigation.SeriesDto
|
||||||
import hu.bbara.purefin.core.ui.model.EpisodeUiModel
|
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.MovieUiModel
|
||||||
import hu.bbara.purefin.core.ui.model.SeriesUiModel
|
import hu.bbara.purefin.core.ui.model.SeriesUiModel
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
@@ -165,7 +166,15 @@ class AppViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMovieSelected(movieId: UUID) {
|
fun onMediaSelected(mediaUiModel : MediaUiModel) {
|
||||||
|
when (mediaUiModel) {
|
||||||
|
is MovieUiModel -> onMovieSelected(mediaUiModel.id)
|
||||||
|
is SeriesUiModel -> onSeriesSelected(mediaUiModel.id)
|
||||||
|
is EpisodeUiModel -> onEpisodeSelected(mediaUiModel.seriesId, mediaUiModel.seasonId, mediaUiModel.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onMovieSelected(movieId: UUID) {
|
||||||
navigationManager.navigate(Route.MovieRoute(
|
navigationManager.navigate(Route.MovieRoute(
|
||||||
MovieDto(
|
MovieDto(
|
||||||
id = movieId,
|
id = movieId,
|
||||||
@@ -173,7 +182,7 @@ class AppViewModel @Inject constructor(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onSeriesSelected(seriesId: UUID) {
|
private fun onSeriesSelected(seriesId: UUID) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
navigationManager.navigate(Route.SeriesRoute(
|
navigationManager.navigate(Route.SeriesRoute(
|
||||||
SeriesDto(
|
SeriesDto(
|
||||||
@@ -183,7 +192,7 @@ class AppViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onEpisodeSelected(seriesId: UUID, seasonId: UUID, episodeId: UUID) {
|
private fun onEpisodeSelected(seriesId: UUID, seasonId: UUID, episodeId: UUID) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
navigationManager.navigate(Route.EpisodeRoute(
|
navigationManager.navigate(Route.EpisodeRoute(
|
||||||
EpisodeDto(
|
EpisodeDto(
|
||||||
|
|||||||
Reference in New Issue
Block a user