Skip to content

Commit

Permalink
Add end marker to final chapters in a series
Browse files Browse the repository at this point in the history
  • Loading branch information
julieminer committed Jul 18, 2024
1 parent ab18c27 commit 7a5a081
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ object Previews {
altTitles = listOf("Test Manga"),
tags = listOf("Comedy", "Slice of Life", "Romance"),
status = "ongoing",
contentRating = "Safe"
contentRating = "Safe",
lastChapter = null,
)

fun previewUIChapters() = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data class UIManga(
val tags: List<String>,
val status: String,
val contentRating: String,
val lastChapter: String?
) :
Parcelable {
@IgnoredOnParcel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MangaRepository(
tags = manga.tags.sortedBy { it.id }.map { it.name },
status = manga.status,
contentRating = manga.contentRating,
lastChapter = manga.lastChapter,
)
}
if (uiManga.isEmpty()) return emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,24 @@ internal fun ChapterListItem(
Column(modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
Text(text = "Chapter ${uiChapter.chapter}",
color = MaterialTheme.colorScheme.onBackground,
fontWeight = FontWeight.Medium,
fontSize = 18.sp)
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(text = "Chapter ${uiChapter.chapter}",
color = MaterialTheme.colorScheme.onBackground,
fontWeight = FontWeight.Medium,
fontSize = 18.sp)

if (uiManga.lastChapter == uiChapter.chapter) {
Text(
text = "End",
color = MaterialTheme.colorScheme.primary,
fontWeight = FontWeight.Medium,
fontSize = 12.sp
)
}
}
Text(text = uiChapter.title ?: "",
fontWeight = FontWeight.Normal,
fontSize = 14.sp
Expand Down Expand Up @@ -83,6 +97,9 @@ private fun ChapterPreview() {
val manga = Previews.previewUIManga()
Column {
ChapterListItem(uiChapter = Previews.previewUIChapters().first(), uiManga = manga, refreshStatus = ReadStatus, onChapterClicked = { _, _ -> }, onChapterLongPressed = { _, _ -> })
ChapterListItem(uiChapter = Previews.previewUIChapters().first().copy(read = false), uiManga = manga, refreshStatus = ReadStatus, onChapterClicked = { _, _ -> }, onChapterLongPressed = { _, _ -> })
ChapterListItem(uiChapter = Previews.previewUIChapters().first().copy(read = false), uiManga = manga, refreshStatus = None, onChapterClicked = { _, _ -> }, onChapterLongPressed = { _, _ -> })
ChapterListItem(uiChapter = Previews.previewUIChapters().first().copy(chapter = "101"), uiManga = manga.copy(lastChapter = "101"), refreshStatus = ReadStatus, onChapterClicked = { _, _ -> }, onChapterLongPressed = { _, _ -> })
ChapterListItem(uiChapter = Previews.previewUIChapters().first().copy(title = "Test Title with an extremely long title that may or may not wrap"), uiManga = manga, refreshStatus = ReadStatus, onChapterClicked = { _, _ -> }, onChapterLongPressed = { _, _ -> })
}
}
Expand Down

0 comments on commit 7a5a081

Please sign in to comment.