mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
Fix buttons for navigation on SeriesScreen
This commit is contained in:
@@ -57,15 +57,10 @@ internal sealed interface EpisodeTopBarShortcut {
|
||||
data class Series(override val onClick: () -> Unit) : EpisodeTopBarShortcut {
|
||||
override val label: String = "Series"
|
||||
}
|
||||
|
||||
data class Home(override val onClick: () -> Unit) : EpisodeTopBarShortcut {
|
||||
override val label: String = "Home"
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun EpisodeTopBar(
|
||||
seriesTitle: String?,
|
||||
shortcut: EpisodeTopBarShortcut?,
|
||||
onBack: () -> Unit,
|
||||
onSeriesClick: () -> Unit,
|
||||
@@ -79,6 +74,9 @@ internal fun EpisodeTopBar(
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
GhostIconButton(
|
||||
icon = Icons.Outlined.ArrowBack,
|
||||
@@ -107,29 +105,8 @@ internal fun EpisodeTopBar(
|
||||
)
|
||||
}
|
||||
}
|
||||
!seriesTitle.isNullOrBlank() -> {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.height(52.dp)
|
||||
.clickable(onClick = onSeriesClick),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = seriesTitle,
|
||||
color = scheme.onBackground,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.background(scheme.background.copy(alpha = 0.65f))
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
else -> Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||
GhostIconButton(icon = Icons.Outlined.Cast, contentDescription = "Cast", onClick = { })
|
||||
GhostIconButton(icon = Icons.Outlined.MoreVert, contentDescription = "More", onClick = { })
|
||||
|
||||
@@ -52,7 +52,6 @@ fun EpisodeScreen(
|
||||
}
|
||||
|
||||
val episode = viewModel.episode.collectAsState()
|
||||
val seriesTitle = viewModel.seriesTitle.collectAsState()
|
||||
val downloadState = viewModel.downloadState.collectAsState()
|
||||
|
||||
val notificationPermissionLauncher = rememberLauncherForActivityResult(
|
||||
@@ -79,12 +78,8 @@ fun EpisodeScreen(
|
||||
|
||||
EpisodeScreenInternal(
|
||||
episode = episode.value!!,
|
||||
seriesTitle = seriesTitle.value,
|
||||
topBarShortcut = remember(previousRoute) {
|
||||
when (previousRoute) {
|
||||
is Route.SeriesRoute -> EpisodeTopBarShortcut.Home {
|
||||
navigationManager.replaceAll(Route.Home)
|
||||
}
|
||||
Route.Home -> EpisodeTopBarShortcut.Series(viewModel::onSeriesClick)
|
||||
else -> null
|
||||
}
|
||||
@@ -100,7 +95,6 @@ fun EpisodeScreen(
|
||||
@Composable
|
||||
private fun EpisodeScreenInternal(
|
||||
episode: Episode,
|
||||
seriesTitle: String?,
|
||||
topBarShortcut: EpisodeTopBarShortcut?,
|
||||
downloadState: DownloadState,
|
||||
onBack: () -> Unit,
|
||||
@@ -114,7 +108,6 @@ private fun EpisodeScreenInternal(
|
||||
containerColor = MaterialTheme.colorScheme.background,
|
||||
topBar = {
|
||||
EpisodeTopBar(
|
||||
seriesTitle = seriesTitle,
|
||||
shortcut = topBarShortcut,
|
||||
onBack = onBack,
|
||||
onSeriesClick = onSeriesClick,
|
||||
@@ -152,7 +145,6 @@ private fun EpisodeScreenPreview() {
|
||||
AppTheme {
|
||||
EpisodeScreenInternal(
|
||||
episode = previewEpisode(),
|
||||
seriesTitle = "Severance",
|
||||
topBarShortcut = EpisodeTopBarShortcut.Series(onClick = {}),
|
||||
downloadState = DownloadState.Downloading(progressPercent = 0.42f),
|
||||
onBack = {},
|
||||
|
||||
@@ -69,7 +69,7 @@ fun SeriesScreen(
|
||||
}
|
||||
},
|
||||
onObserveSeasonDownloadState = viewModel::observeSeasonDownloadState,
|
||||
onBack = viewModel::onBack,
|
||||
onBack = viewModel::onGoHome,
|
||||
modifier = modifier
|
||||
)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user