mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
MangaInfoHeader: Add description placeholder (#7398)
To always show summary view for expanding tags
This commit is contained in:
parent
e44bb30996
commit
0c856438fa
2 changed files with 21 additions and 18 deletions
|
@ -82,6 +82,8 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE))
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MangaInfoHeader(
|
fun MangaInfoHeader(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
@ -205,25 +207,25 @@ fun MangaInfoHeader(
|
||||||
val (expanded, onExpanded) = rememberSaveable {
|
val (expanded, onExpanded) = rememberSaveable {
|
||||||
mutableStateOf(fromSource || windowWidthSizeClass != WindowWidthSizeClass.Compact)
|
mutableStateOf(fromSource || windowWidthSizeClass != WindowWidthSizeClass.Compact)
|
||||||
}
|
}
|
||||||
if (!description.isNullOrBlank()) {
|
val desc =
|
||||||
val trimmedDescription = remember(description) {
|
description.takeIf { !it.isNullOrBlank() } ?: stringResource(id = R.string.description_placeholder)
|
||||||
description
|
val trimmedDescription = remember(desc) {
|
||||||
.replace(Regex(" +\$", setOf(RegexOption.MULTILINE)), "")
|
desc
|
||||||
.replace(Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)), "\n")
|
.replace(whitespaceLineRegex, "\n")
|
||||||
}
|
.trimEnd()
|
||||||
MangaSummary(
|
|
||||||
expandedDescription = description,
|
|
||||||
shrunkDescription = trimmedDescription,
|
|
||||||
expanded = expanded,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(top = 8.dp)
|
|
||||||
.padding(horizontal = 16.dp)
|
|
||||||
.clickableNoIndication(
|
|
||||||
onLongClick = { context.copyToClipboard(description, description) },
|
|
||||||
onClick = { onExpanded(!expanded) },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
MangaSummary(
|
||||||
|
expandedDescription = desc,
|
||||||
|
shrunkDescription = trimmedDescription,
|
||||||
|
expanded = expanded,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(top = 8.dp)
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.clickableNoIndication(
|
||||||
|
onLongClick = { context.copyToClipboard(desc, desc) },
|
||||||
|
onClick = { onExpanded(!expanded) },
|
||||||
|
),
|
||||||
|
)
|
||||||
val tags = tagsProvider()
|
val tags = tagsProvider()
|
||||||
if (!tags.isNullOrEmpty()) {
|
if (!tags.isNullOrEmpty()) {
|
||||||
Box(
|
Box(
|
||||||
|
|
|
@ -603,6 +603,7 @@
|
||||||
<string name="clipboard_copy_error">Failed to copy to clipboard</string>
|
<string name="clipboard_copy_error">Failed to copy to clipboard</string>
|
||||||
<string name="source_not_installed">Source not installed: %1$s</string>
|
<string name="source_not_installed">Source not installed: %1$s</string>
|
||||||
<string name="snack_add_to_library">Add manga to library?</string>
|
<string name="snack_add_to_library">Add manga to library?</string>
|
||||||
|
<string name="description_placeholder">No description</string>
|
||||||
|
|
||||||
<!-- Manga chapters fragment -->
|
<!-- Manga chapters fragment -->
|
||||||
<string name="display_mode_chapter">Chapter %1$s</string>
|
<string name="display_mode_chapter">Chapter %1$s</string>
|
||||||
|
|
Loading…
Reference in a new issue