mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 08:01:50 +01:00
Adjust missing chapters UI
This commit is contained in:
parent
ee45f46193
commit
1ff78173f7
@ -394,7 +394,7 @@ private fun MangaScreenSmallImpl(
|
|||||||
ChapterHeader(
|
ChapterHeader(
|
||||||
enabled = chapters.fastAll { !it.selected },
|
enabled = chapters.fastAll { !it.selected },
|
||||||
chapterCount = chapters.size,
|
chapterCount = chapters.size,
|
||||||
missingChapters = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
|
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
|
||||||
onClick = onFilterClicked,
|
onClick = onFilterClicked,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -606,7 +606,7 @@ fun MangaScreenLargeImpl(
|
|||||||
ChapterHeader(
|
ChapterHeader(
|
||||||
enabled = chapters.fastAll { !it.selected },
|
enabled = chapters.fastAll { !it.selected },
|
||||||
chapterCount = chapters.size,
|
chapterCount = chapters.size,
|
||||||
missingChapters = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
|
missingChapterCount = countMissingChapters(chapters.map { it.chapter.chapterNumber }),
|
||||||
onClick = onFilterButtonClicked,
|
onClick = onFilterButtonClicked,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
package eu.kanade.presentation.manga.components
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.AssistChip
|
|
||||||
import androidx.compose.material3.AssistChipDefaults.assistChipColors
|
|
||||||
import androidx.compose.material3.AssistChipDefaults.assistChipElevation
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.pluralStringResource
|
import androidx.compose.ui.res.pluralStringResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChapterHeader(
|
fun ChapterHeader(
|
||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
chapterCount: Int?,
|
chapterCount: Int?,
|
||||||
missingChapters: Int?,
|
missingChapterCount: Int?,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(
|
.clickable(
|
||||||
@ -33,7 +31,7 @@ fun ChapterHeader(
|
|||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
)
|
)
|
||||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = if (chapterCount == null) {
|
text = if (chapterCount == null) {
|
||||||
@ -42,45 +40,29 @@ fun ChapterHeader(
|
|||||||
pluralStringResource(id = R.plurals.manga_num_chapters, count = chapterCount, chapterCount)
|
pluralStringResource(id = R.plurals.manga_num_chapters, count = chapterCount, chapterCount)
|
||||||
},
|
},
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
color = MaterialTheme.colorScheme.onBackground,
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Missing chapters
|
MissingChaptersWarning(missingChapterCount)
|
||||||
if (missingChapters == null) {
|
|
||||||
DrawWarning(
|
|
||||||
text = stringResource(R.string.missing_chapters_unknown),
|
|
||||||
)
|
|
||||||
} else if (missingChapters > 0) {
|
|
||||||
DrawWarning(
|
|
||||||
text = pluralStringResource(
|
|
||||||
id = R.plurals.missing_chapters,
|
|
||||||
count = missingChapters,
|
|
||||||
missingChapters,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DrawWarning(text: String) {
|
private fun MissingChaptersWarning(count: Int?) {
|
||||||
AssistChip(
|
val text = when {
|
||||||
onClick = {
|
count == null -> stringResource(R.string.missing_chapters_unknown)
|
||||||
// TODO Show missing chapters
|
count > 0 -> pluralStringResource(id = R.plurals.missing_chapters, count = count, count)
|
||||||
},
|
else -> null
|
||||||
label = {
|
}
|
||||||
|
|
||||||
|
if (text != null) {
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
text = text,
|
text = text,
|
||||||
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
color = MaterialTheme.colorScheme.primary,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
)
|
color = MaterialTheme.colorScheme.error,
|
||||||
},
|
|
||||||
shape = MaterialTheme.shapes.small,
|
|
||||||
border = null,
|
|
||||||
colors = assistChipColors(
|
|
||||||
containerColor = MaterialTheme.colorScheme.surface,
|
|
||||||
),
|
|
||||||
elevation = assistChipElevation(1.dp),
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ fun countMissingChapters(chaptersInput: List<Float>): Int? {
|
|||||||
.map { floor(it.toDouble()).toInt() }
|
.map { floor(it.toDouble()).toInt() }
|
||||||
// Only keep unique chapters so that -1 or 16 are not counted multiple times
|
// Only keep unique chapters so that -1 or 16 are not counted multiple times
|
||||||
.distinct()
|
.distinct()
|
||||||
.sortedBy { it }
|
.sorted()
|
||||||
|
|
||||||
if (chapters.isEmpty()) {
|
if (chapters.isEmpty()) {
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user