Skip to content

Commit 72112db

Browse files
committed
Add ability to show description by tapping the manga
1 parent 826a66b commit 72112db

File tree

6 files changed

+75
-6
lines changed

6 files changed

+75
-6
lines changed

app/src/main/java/com/melonhead/mangadexfollower/extensions/PreviewExtensions.kt

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ object Previews {
1818
status = "ongoing",
1919
contentRating = "Safe",
2020
lastChapter = null,
21+
description = " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
2122
)
2223

2324
fun previewUIChapters() = listOf(

app/src/main/java/com/melonhead/mangadexfollower/models/ui/UIManga.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ data class UIManga(
1717
val tags: List<String>,
1818
val status: String,
1919
val contentRating: String,
20-
val lastChapter: String?
20+
val lastChapter: String?,
21+
val description: String?,
2122
) :
2223
Parcelable {
2324
@IgnoredOnParcel

app/src/main/java/com/melonhead/mangadexfollower/repositories/MangaRepository.kt

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class MangaRepository(
8282
status = manga.status,
8383
contentRating = manga.contentRating,
8484
lastChapter = manga.lastChapter,
85+
description = manga.description,
8586
)
8687
}
8788
if (uiManga.isEmpty()) return emptyList()

app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/home/HomeScreen.kt

+16-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.melonhead.mangadexfollower.models.ui.None
2626
import com.melonhead.mangadexfollower.models.ui.UIChapter
2727
import com.melonhead.mangadexfollower.models.ui.UIManga
2828
import com.melonhead.mangadexfollower.ui.scenes.home.dialogs.MarkChapterReadDialog
29+
import com.melonhead.mangadexfollower.ui.scenes.home.dialogs.ShowMangaDescriptionDialog
2930
import com.melonhead.mangadexfollower.ui.scenes.home.dialogs.TitleChangeDialog
3031
import com.melonhead.mangadexfollower.ui.scenes.home.dialogs.ToggleRenderTypeDialog
3132
import com.melonhead.mangadexfollower.ui.scenes.home.list.ChapterListItem
@@ -64,6 +65,12 @@ internal fun HomeScreen(
6465
onDismissed = { showTitleChangeDialogForManga = null }
6566
)
6667

68+
var showDescriptionDialogForManga by remember { mutableStateOf<UIManga?>(null) }
69+
ShowMangaDescriptionDialog(
70+
showDescriptionDialogForManga,
71+
onDismissed = { showDescriptionDialogForManga = null }
72+
)
73+
6774
val isRefreshing = rememberSwipeRefreshState(isRefreshing = false)
6875
var justPulledRefresh by remember { mutableStateOf(false) }
6976
val context = LocalContext.current
@@ -152,9 +159,15 @@ internal fun HomeScreen(
152159
}
153160
}) {
154161
if (it is UIManga) {
155-
MangaCoverListItem(modifier = Modifier.padding(top = if (itemState.first() == it) 0.dp else 12.dp), uiManga = it, onLongPress = { mangaWebviewToggleDialog = it }, onTitleLongPress = {
156-
showTitleChangeDialogForManga = it
157-
})
162+
MangaCoverListItem(
163+
modifier = Modifier.padding(top = if (itemState.first() == it) 0.dp else 12.dp),
164+
uiManga = it,
165+
onLongPress = { mangaWebviewToggleDialog = it },
166+
onTapped = { showDescriptionDialogForManga = it },
167+
onTitleLongPress = {
168+
showTitleChangeDialogForManga = it
169+
}
170+
)
158171
}
159172
if (it is Pair<*, *> && it.first is UIChapter) {
160173
ChapterListItem(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.melonhead.mangadexfollower.ui.scenes.home.dialogs
2+
3+
import androidx.compose.material3.AlertDialog
4+
import androidx.compose.material3.Text
5+
import androidx.compose.material3.TextButton
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.ui.tooling.preview.Preview
8+
import com.melonhead.mangadexfollower.extensions.Previews
9+
import com.melonhead.mangadexfollower.models.ui.UIManga
10+
import com.melonhead.mangadexfollower.ui.theme.MangadexFollowerTheme
11+
12+
@Composable
13+
internal fun ShowMangaDescriptionDialog(
14+
uiManga: UIManga?,
15+
onDismissed: () -> Unit,
16+
) {
17+
if (uiManga?.description != null) {
18+
AlertDialog(
19+
onDismissRequest = { onDismissed() },
20+
title = {
21+
Text(text = uiManga.title)
22+
},
23+
text = {
24+
Text(text = uiManga.description)
25+
},
26+
confirmButton = {
27+
TextButton(onClick = {
28+
onDismissed()
29+
}) {
30+
Text("Close")
31+
}
32+
}
33+
)
34+
}
35+
}
36+
37+
@Preview
38+
@Composable
39+
private fun MarkChapterReadPreview() {
40+
MangadexFollowerTheme {
41+
ShowMangaDescriptionDialog(
42+
Previews.previewUIManga(),
43+
onDismissed = { })
44+
}
45+
}

app/src/main/java/com/melonhead/mangadexfollower/ui/scenes/home/list/MangaCoverListItem.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ import com.melonhead.mangadexfollower.ui.theme.MangadexFollowerTheme
3030

3131
@OptIn(ExperimentalFoundationApi::class, ExperimentalLayoutApi::class)
3232
@Composable
33-
internal fun MangaCoverListItem(modifier: Modifier = Modifier, uiManga: UIManga, onLongPress: (uiManga: UIManga) -> Unit, onTitleLongPress: (uiManga: UIManga) -> Unit) {
34-
Row(modifier.combinedClickable(onClick = { }, onLongClick = { onLongPress(uiManga) })) {
33+
internal fun MangaCoverListItem(
34+
modifier: Modifier = Modifier,
35+
uiManga: UIManga,
36+
onTapped: (uiManga: UIManga) -> Unit,
37+
onLongPress: (uiManga: UIManga) -> Unit,
38+
onTitleLongPress: (uiManga: UIManga) -> Unit,
39+
) {
40+
Row(modifier.combinedClickable(onClick = { onTapped(uiManga) }, onLongClick = { onLongPress(uiManga) })) {
3541
Box(
3642
modifier
3743
.padding(horizontal = 10.dp)
@@ -153,11 +159,13 @@ private fun MangaPreview() {
153159
MangaCoverListItem(
154160
uiManga = Previews.previewUIManga(),
155161
onLongPress = { },
162+
onTapped = { },
156163
onTitleLongPress = { }
157164
)
158165
MangaCoverListItem(
159166
uiManga = Previews.previewUIManga().copy(title = "Test Manga with a really long name that causes the name to clip a little"),
160167
onLongPress = { },
168+
onTapped = { },
161169
onTitleLongPress = { }
162170
)
163171
}

0 commit comments

Comments
 (0)