diff --git a/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt b/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt index 0baa1c8ee1..f01b8a369c 100644 --- a/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt +++ b/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt @@ -1,23 +1,31 @@ package mihon.feature.upcoming import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.HelpOutline +import androidx.compose.material3.Badge import androidx.compose.material3.Icon import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.text.font.FontWeight import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.relativeDateText import eu.kanade.presentation.util.isTabletUi +import eu.kanade.tachiyomi.util.lang.toLocalDate import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableMap import kotlinx.coroutines.launch @@ -27,9 +35,9 @@ import tachiyomi.core.common.Constants import tachiyomi.domain.manga.model.Manga import tachiyomi.i18n.MR import tachiyomi.presentation.core.components.FastScrollLazyColumn -import tachiyomi.presentation.core.components.ListGroupHeader import tachiyomi.presentation.core.components.TwoPanelBox import tachiyomi.presentation.core.components.material.Scaffold +import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.i18n.stringResource import java.time.LocalDate import java.time.YearMonth @@ -99,6 +107,37 @@ private fun UpcomingToolbar() { ) } +@Composable +private fun DateHeading( + date: LocalDate, + mangaCount: Int, +) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth() + ) { + Text( + text = relativeDateText(date), + modifier = Modifier + .padding( + start = MaterialTheme.padding.medium, + end = MaterialTheme.padding.small, + top = MaterialTheme.padding.small, + bottom = MaterialTheme.padding.small, + ), + color = MaterialTheme.colorScheme.onSurfaceVariant, + fontWeight = FontWeight.SemiBold, + style = MaterialTheme.typography.bodyMedium, + ) + Badge( + containerColor = MaterialTheme.colorScheme.primary, + contentColor = MaterialTheme.colorScheme.onPrimary, + ) { + Text("$mangaCount") + } + } +} + @Composable private fun UpcomingScreenSmallImpl( listState: LazyListState, @@ -140,7 +179,13 @@ private fun UpcomingScreenSmallImpl( ) } is UpcomingUIModel.Header -> { - ListGroupHeader(text = relativeDateText(item.date)) + val mangaCount = items.filterIsInstance() + .count { it.manga.expectedNextUpdate?.toLocalDate() == item.date } + + DateHeading( + date = item.date, + mangaCount = mangaCount, + ) } } } @@ -188,7 +233,13 @@ private fun UpcomingScreenLargeImpl( ) } is UpcomingUIModel.Header -> { - ListGroupHeader(text = relativeDateText(item.date)) + val mangaCount = items.filterIsInstance() + .count { it.manga.expectedNextUpdate?.toLocalDate() == item.date } + + DateHeading( + date = item.date, + mangaCount = mangaCount, + ) } } }