Skip to content

Commit

Permalink
Fix Programme Reminder Item Icon mistake.
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jul 21, 2024
1 parent c8ea7b2 commit 8d51a52
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun ChannelRoute(
val programmes = viewModel.programmes.collectAsLazyPagingItems()
val programmeRange by viewModel.programmeRange.collectAsStateWithLifecycle()

val programmeIdsInReminder by viewModel.programmeIdsInReminder.collectAsStateWithLifecycle()
val programmeReminderIds by viewModel.programmeReminderIds.collectAsStateWithLifecycle()

var brightness by remember { mutableFloatStateOf(helper.brightness) }
var isPipMode by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -180,7 +180,7 @@ fun ChannelRoute(
channels = channels,
programmes = programmes,
programmeRange = programmeRange,
programmeIdsInReminder = programmeIdsInReminder,
programmeReminderIds = programmeReminderIds,
onRemindProgramme = viewModel::onRemindProgramme,
onCancelRemindProgramme = viewModel::onCancelRemindProgramme
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class ChannelViewModel @Inject constructor(
playerManager.pauseOrContinue(isContinued)
}

internal val programmeIdsInReminder: StateFlow<List<Int>> = workManager.getWorkInfosFlow(
internal val programmeReminderIds: StateFlow<List<Int>> = workManager.getWorkInfosFlow(
WorkQuery.fromStates(
WorkInfo.State.ENQUEUED
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal fun PlayerPanel(
programmes: LazyPagingItems<Programme>,
programmeRange: ProgrammeRange,
modifier: Modifier = Modifier,
programmeIdsInReminder: List<Int>,
programmeReminderIds: List<Int>,
onRemindProgramme: (Programme) -> Unit,
onCancelRemindProgramme: (Programme) -> Unit,
) {
Expand Down Expand Up @@ -134,6 +134,7 @@ internal fun PlayerPanel(
channels = channels,
programmes = programmes,
programmeRange = programmeRange,
programmeReminderIds = programmeReminderIds,
onProgrammePressed = {
programme = it
animProgramme = it
Expand Down Expand Up @@ -203,9 +204,7 @@ internal fun PlayerPanel(
) {
Text(
text = "${start.formatEOrSh(false)} - ${
end.formatEOrSh(
false
)
end.formatEOrSh(false)
}",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
Expand All @@ -224,9 +223,9 @@ internal fun PlayerPanel(
val isReminderShowing = Clock.System.now()
.toEpochMilliseconds() < currentProgramme.start
if (isReminderShowing) {
val inReminder = currentProgramme.id in programmeIdsInReminder
val inReminder = currentProgramme.id in programmeReminderIds
IconButton(
icon = if (inReminder) Icons.Outlined.Notifications
icon = if (!inReminder) Icons.Outlined.Notifications
else Icons.Rounded.NotificationsActive,
contentDescription = null,
onClick = {
Expand Down Expand Up @@ -281,6 +280,7 @@ fun PlayerPanelImpl(
channels: LazyPagingItems<Channel>,
programmes: LazyPagingItems<Programme>,
programmeRange: ProgrammeRange,
programmeReminderIds: List<Int>,
modifier: Modifier = Modifier,
onProgrammePressed: (Programme) -> Unit
) {
Expand Down Expand Up @@ -335,6 +335,7 @@ fun PlayerPanelImpl(
isPanelExpanded = isPanelExpanded,
programmes = programmes,
range = programmeRange,
programmeReminderIds = programmeReminderIds,
onProgrammePressed = onProgrammePressed,
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.m3u.feature.channel.components

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring
Expand Down Expand Up @@ -97,6 +98,7 @@ internal fun ProgramGuide(
isPanelExpanded: Boolean,
programmes: LazyPagingItems<Programme>,
range: ProgrammeRange,
programmeReminderIds: List<Int>,
modifier: Modifier = Modifier,
minaBoxState: MinaBoxState = rememberMinaBoxState(),
height: Float = 256f,
Expand Down Expand Up @@ -186,6 +188,7 @@ internal fun ProgramGuide(
if (programme != null) {
ProgrammeCell(
programme = programme,
inReminder = programme.id in programmeReminderIds,
onPressed = { onProgrammePressed(programme) }
)
} else {
Expand Down Expand Up @@ -299,6 +302,7 @@ private fun TimelineCell(
@Composable
private fun ProgrammeCell(
programme: Programme,
inReminder: Boolean,
modifier: Modifier = Modifier,
onPressed: () -> Unit
) {
Expand Down Expand Up @@ -354,8 +358,19 @@ private fun ProgrammeCell(
stiffness = Spring.StiffnessMediumLow
)
)
val currentColor by animateColorAsState(
targetValue = if(inReminder) MaterialTheme.colorScheme.tertiary
else MaterialTheme.colorScheme.tertiaryContainer,
label = "programme-cell-color"
)
val currentContentColor by animateColorAsState(
targetValue = if(inReminder) MaterialTheme.colorScheme.onTertiary
else MaterialTheme.colorScheme.onTertiaryContainer,
label = "programme-cell-color"
)
Surface(
color = MaterialTheme.colorScheme.tertiaryContainer,
color = currentColor,
contentColor = currentContentColor,
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline),
shape = AbsoluteRoundedCornerShape(4.dp),
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ private fun NewReleaseContent(spec: Recommend.NewRelease) {
maxLines = 5,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
fontFamily = FontFamilies.LexendExa
fontFamily = FontFamilies.LexendExa,
modifier = Modifier.weight(1f)
)
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down

0 comments on commit 8d51a52

Please sign in to comment.