From 5f34539525f93a92ca80f3b1fb9e71953b6758a1 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:15:51 +0700 Subject: [PATCH] MangaScreen: Adjust "missing chapter count" item list styling (#10105) Text style to labelMedium and set secondary alpha to the whole row --- .../kanade/presentation/manga/MangaScreen.kt | 28 +--------- .../components/MissingChapterCountListItem.kt | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/eu/kanade/presentation/manga/components/MissingChapterCountListItem.kt diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 38e8b78143..698db525be 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -5,11 +5,9 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.asPaddingValues @@ -28,9 +26,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayArrow -import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text @@ -48,7 +44,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.util.fastAll import androidx.compose.ui.util.fastAny @@ -62,6 +57,7 @@ import eu.kanade.presentation.manga.components.MangaBottomActionMenu import eu.kanade.presentation.manga.components.MangaChapterListItem import eu.kanade.presentation.manga.components.MangaInfoBox import eu.kanade.presentation.manga.components.MangaToolbar +import eu.kanade.presentation.manga.components.MissingChapterCountListItem import eu.kanade.presentation.util.formatChapterNumber import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download @@ -80,10 +76,8 @@ import tachiyomi.presentation.core.components.VerticalFastScroller import tachiyomi.presentation.core.components.material.ExtendedFloatingActionButton import tachiyomi.presentation.core.components.material.PullRefresh import tachiyomi.presentation.core.components.material.Scaffold -import tachiyomi.presentation.core.components.material.padding import tachiyomi.presentation.core.util.isScrolledToEnd import tachiyomi.presentation.core.util.isScrollingUp -import tachiyomi.presentation.core.util.secondaryItemAlpha import java.text.DateFormat import java.util.Date @@ -789,25 +783,7 @@ private fun LazyListScope.sharedChapterItems( when (item) { is ChapterList.MissingCount -> { - Row( - modifier = Modifier.padding( - horizontal = MaterialTheme.padding.medium, - vertical = MaterialTheme.padding.small, - ), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.medium), - ) { - HorizontalDivider(modifier = Modifier.weight(1f)) - Text( - text = pluralStringResource( - id = R.plurals.missing_chapters, - count = item.count, - item.count, - ), - modifier = Modifier.secondaryItemAlpha(), - ) - HorizontalDivider(modifier = Modifier.weight(1f)) - } + MissingChapterCountListItem(count = item.count) } is ChapterList.Item -> { MangaChapterListItem( diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MissingChapterCountListItem.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MissingChapterCountListItem.kt new file mode 100644 index 0000000000..deebaf8e33 --- /dev/null +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MissingChapterCountListItem.kt @@ -0,0 +1,52 @@ +package eu.kanade.presentation.manga.components + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.tooling.preview.PreviewLightDark +import eu.kanade.presentation.theme.TachiyomiTheme +import eu.kanade.tachiyomi.R +import tachiyomi.presentation.core.components.material.padding +import tachiyomi.presentation.core.util.secondaryItemAlpha + +@Composable +fun MissingChapterCountListItem( + count: Int, + modifier: Modifier = Modifier, +) { + Row( + modifier = modifier + .padding( + horizontal = MaterialTheme.padding.medium, + vertical = MaterialTheme.padding.small, + ) + .secondaryItemAlpha(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.medium), + ) { + HorizontalDivider(modifier = Modifier.weight(1f)) + Text( + text = pluralStringResource(id = R.plurals.missing_chapters, count = count, count), + style = MaterialTheme.typography.labelMedium, + ) + HorizontalDivider(modifier = Modifier.weight(1f)) + } +} + +@PreviewLightDark +@Composable +private fun Preview() { + TachiyomiTheme { + Surface { + MissingChapterCountListItem(count = 42) + } + } +}