Add tests for MissingChapters function

(cherry picked from commit 8ab7e632936a008d31a87acd335fbd5fb21d818b)

# Conflicts:
#	domain/build.gradle.kts
This commit is contained in:
arkon
2023-04-15 09:51:52 -04:00
committed by Jobobby04
parent 18546e0410
commit 4d1244daef
8 changed files with 51 additions and 25 deletions
@@ -89,7 +89,7 @@ import exh.ui.metadata.adapters.NHentaiDescription
import exh.ui.metadata.adapters.PururinDescription
import exh.ui.metadata.adapters.TsuminoDescription
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.service.countMissingChapters
import tachiyomi.domain.chapter.service.missingChaptersCount
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.model.StubSource
import tachiyomi.presentation.core.components.LazyColumn
@@ -520,7 +520,7 @@ private fun MangaScreenSmallImpl(
ChapterHeader(
enabled = chapters.fastAll { !it.selected },
chapterCount = chapters.size,
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
missingChapterCount = chapters.map { it.chapter.chapterNumber }.missingChaptersCount(),
onClick = onFilterClicked,
)
}
@@ -788,7 +788,7 @@ fun MangaScreenLargeImpl(
ChapterHeader(
enabled = chapters.fastAll { !it.selected },
chapterCount = chapters.size,
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
missingChapterCount = chapters.map { it.chapter.chapterNumber }.missingChaptersCount(),
onClick = onFilterButtonClicked,
)
}
@@ -14,13 +14,13 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.R
import tachiyomi.presentation.core.util.secondaryItemAlpha
import tachiyomi.presentation.core.components.material.SecondaryItemAlpha
@Composable
fun ChapterHeader(
enabled: Boolean,
chapterCount: Int?,
missingChapterCount: Int?,
missingChapterCount: Int,
onClick: () -> Unit,
) {
Column(
@@ -48,19 +48,16 @@ fun ChapterHeader(
}
@Composable
private fun MissingChaptersWarning(count: Int?) {
val text = when {
count == null -> stringResource(R.string.missing_chapters_unknown)
count > 0 -> pluralStringResource(id = R.plurals.missing_chapters, count = count, count)
else -> return
private fun MissingChaptersWarning(count: Int) {
if (count == 0) {
return
}
Text(
modifier = Modifier.secondaryItemAlpha(),
text = text,
text = pluralStringResource(id = R.plurals.missing_chapters, count = count, count),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.error,
color = MaterialTheme.colorScheme.error.copy(alpha = SecondaryItemAlpha),
)
}