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 {
|
data class Series(override val onClick: () -> Unit) : EpisodeTopBarShortcut {
|
||||||
override val label: String = "Series"
|
override val label: String = "Series"
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Home(override val onClick: () -> Unit) : EpisodeTopBarShortcut {
|
|
||||||
override val label: String = "Home"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun EpisodeTopBar(
|
internal fun EpisodeTopBar(
|
||||||
seriesTitle: String?,
|
|
||||||
shortcut: EpisodeTopBarShortcut?,
|
shortcut: EpisodeTopBarShortcut?,
|
||||||
onBack: () -> Unit,
|
onBack: () -> Unit,
|
||||||
onSeriesClick: () -> Unit,
|
onSeriesClick: () -> Unit,
|
||||||
@@ -80,55 +75,37 @@ internal fun EpisodeTopBar(
|
|||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
GhostIconButton(
|
Row(
|
||||||
icon = Icons.Outlined.ArrowBack,
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
contentDescription = "Back",
|
) {
|
||||||
onClick = onBack
|
GhostIconButton(
|
||||||
)
|
icon = Icons.Outlined.ArrowBack,
|
||||||
when {
|
contentDescription = "Back",
|
||||||
shortcut != null -> {
|
onClick = onBack
|
||||||
Box(
|
)
|
||||||
modifier = Modifier
|
when {
|
||||||
.height(52.dp)
|
shortcut != null -> {
|
||||||
.clickable(onClick = shortcut.onClick),
|
Box(
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = shortcut.label,
|
|
||||||
color = scheme.onBackground,
|
|
||||||
fontSize = 16.sp,
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(CircleShape)
|
.height(52.dp)
|
||||||
.background(scheme.background.copy(alpha = 0.65f))
|
.clickable(onClick = shortcut.onClick),
|
||||||
.padding(horizontal = 16.dp, vertical = 10.dp)
|
contentAlignment = Alignment.Center
|
||||||
)
|
) {
|
||||||
|
Text(
|
||||||
|
text = shortcut.label,
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
!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)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||||
GhostIconButton(icon = Icons.Outlined.Cast, contentDescription = "Cast", onClick = { })
|
GhostIconButton(icon = Icons.Outlined.Cast, contentDescription = "Cast", onClick = { })
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ fun EpisodeScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val episode = viewModel.episode.collectAsState()
|
val episode = viewModel.episode.collectAsState()
|
||||||
val seriesTitle = viewModel.seriesTitle.collectAsState()
|
|
||||||
val downloadState = viewModel.downloadState.collectAsState()
|
val downloadState = viewModel.downloadState.collectAsState()
|
||||||
|
|
||||||
val notificationPermissionLauncher = rememberLauncherForActivityResult(
|
val notificationPermissionLauncher = rememberLauncherForActivityResult(
|
||||||
@@ -79,12 +78,8 @@ fun EpisodeScreen(
|
|||||||
|
|
||||||
EpisodeScreenInternal(
|
EpisodeScreenInternal(
|
||||||
episode = episode.value!!,
|
episode = episode.value!!,
|
||||||
seriesTitle = seriesTitle.value,
|
|
||||||
topBarShortcut = remember(previousRoute) {
|
topBarShortcut = remember(previousRoute) {
|
||||||
when (previousRoute) {
|
when (previousRoute) {
|
||||||
is Route.SeriesRoute -> EpisodeTopBarShortcut.Home {
|
|
||||||
navigationManager.replaceAll(Route.Home)
|
|
||||||
}
|
|
||||||
Route.Home -> EpisodeTopBarShortcut.Series(viewModel::onSeriesClick)
|
Route.Home -> EpisodeTopBarShortcut.Series(viewModel::onSeriesClick)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
@@ -100,7 +95,6 @@ fun EpisodeScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun EpisodeScreenInternal(
|
private fun EpisodeScreenInternal(
|
||||||
episode: Episode,
|
episode: Episode,
|
||||||
seriesTitle: String?,
|
|
||||||
topBarShortcut: EpisodeTopBarShortcut?,
|
topBarShortcut: EpisodeTopBarShortcut?,
|
||||||
downloadState: DownloadState,
|
downloadState: DownloadState,
|
||||||
onBack: () -> Unit,
|
onBack: () -> Unit,
|
||||||
@@ -114,7 +108,6 @@ private fun EpisodeScreenInternal(
|
|||||||
containerColor = MaterialTheme.colorScheme.background,
|
containerColor = MaterialTheme.colorScheme.background,
|
||||||
topBar = {
|
topBar = {
|
||||||
EpisodeTopBar(
|
EpisodeTopBar(
|
||||||
seriesTitle = seriesTitle,
|
|
||||||
shortcut = topBarShortcut,
|
shortcut = topBarShortcut,
|
||||||
onBack = onBack,
|
onBack = onBack,
|
||||||
onSeriesClick = onSeriesClick,
|
onSeriesClick = onSeriesClick,
|
||||||
@@ -152,7 +145,6 @@ private fun EpisodeScreenPreview() {
|
|||||||
AppTheme {
|
AppTheme {
|
||||||
EpisodeScreenInternal(
|
EpisodeScreenInternal(
|
||||||
episode = previewEpisode(),
|
episode = previewEpisode(),
|
||||||
seriesTitle = "Severance",
|
|
||||||
topBarShortcut = EpisodeTopBarShortcut.Series(onClick = {}),
|
topBarShortcut = EpisodeTopBarShortcut.Series(onClick = {}),
|
||||||
downloadState = DownloadState.Downloading(progressPercent = 0.42f),
|
downloadState = DownloadState.Downloading(progressPercent = 0.42f),
|
||||||
onBack = {},
|
onBack = {},
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ fun SeriesScreen(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onObserveSeasonDownloadState = viewModel::observeSeasonDownloadState,
|
onObserveSeasonDownloadState = viewModel::observeSeasonDownloadState,
|
||||||
onBack = viewModel::onBack,
|
onBack = viewModel::onGoHome,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user