Add dot beside unread chapter names

Closes #4261
Also includes changes that might help with #9043
This commit is contained in:
arkon 2023-03-05 17:47:27 -05:00
parent 737a303df7
commit e458de5e9c
2 changed files with 43 additions and 14 deletions

View File

@ -1,16 +1,17 @@
package eu.kanade.presentation.manga.components package eu.kanade.presentation.manga.components
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bookmark import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.filled.Circle
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -62,9 +63,25 @@ fun MangaChapterListItem(
) )
.padding(start = 16.dp, top = 12.dp, end = 8.dp, bottom = 12.dp), .padding(start = 16.dp, top = 12.dp, end = 8.dp, bottom = 12.dp),
) { ) {
Column(modifier = Modifier.weight(1f)) { Column(
Row(verticalAlignment = Alignment.CenterVertically) { modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Row(
horizontalArrangement = Arrangement.spacedBy(2.dp),
verticalAlignment = Alignment.CenterVertically,
) {
var textHeight by remember { mutableStateOf(0) } var textHeight by remember { mutableStateOf(0) }
if (!read) {
Icon(
imageVector = Icons.Filled.Circle,
contentDescription = stringResource(R.string.unread),
modifier = Modifier
.height(8.dp)
.padding(end = 4.dp),
tint = MaterialTheme.colorScheme.primary,
)
}
if (bookmark) { if (bookmark) {
Icon( Icon(
imageVector = Icons.Filled.Bookmark, imageVector = Icons.Filled.Bookmark,
@ -73,23 +90,23 @@ fun MangaChapterListItem(
.sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }), .sizeIn(maxHeight = with(LocalDensity.current) { textHeight.toDp() - 2.dp }),
tint = MaterialTheme.colorScheme.primary, tint = MaterialTheme.colorScheme.primary,
) )
Spacer(modifier = Modifier.width(2.dp))
} }
Text( Text(
text = title, text = title,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = LocalContentColor.current.copy(alpha = textAlpha),
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
onTextLayout = { textHeight = it.size.height }, onTextLayout = { textHeight = it.size.height },
modifier = Modifier.alpha(textAlpha),
) )
} }
Spacer(modifier = Modifier.height(6.dp)) Row {
Row(modifier = Modifier.alpha(textSubtitleAlpha)) {
ProvideTextStyle( ProvideTextStyle(
value = MaterialTheme.typography.bodyMedium.copy(fontSize = 12.sp), value = MaterialTheme.typography.bodyMedium.copy(
fontSize = 12.sp,
color = LocalContentColor.current.copy(alpha = textSubtitleAlpha),
),
) { ) {
if (date != null) { if (date != null) {
Text( Text(

View File

@ -15,7 +15,9 @@ import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bookmark import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.filled.Circle
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
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
@ -191,12 +193,22 @@ fun UpdatesUiItem(
text = update.mangaTitle, text = update.mangaTitle,
maxLines = 1, maxLines = 1,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = LocalContentColor.current.copy(alpha = textAlpha),
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = Modifier.alpha(textAlpha),
) )
Row(verticalAlignment = Alignment.CenterVertically) { Row(verticalAlignment = Alignment.CenterVertically) {
var textHeight by remember { mutableStateOf(0) } var textHeight by remember { mutableStateOf(0) }
if (!update.read) {
Icon(
imageVector = Icons.Filled.Circle,
contentDescription = stringResource(R.string.unread),
modifier = Modifier
.height(8.dp)
.padding(end = 4.dp),
tint = MaterialTheme.colorScheme.primary,
)
}
if (update.bookmark) { if (update.bookmark) {
Icon( Icon(
imageVector = Icons.Filled.Bookmark, imageVector = Icons.Filled.Bookmark,
@ -211,19 +223,19 @@ fun UpdatesUiItem(
text = update.chapterName, text = update.chapterName,
maxLines = 1, maxLines = 1,
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = LocalContentColor.current.copy(alpha = textAlpha),
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
onTextLayout = { textHeight = it.size.height }, onTextLayout = { textHeight = it.size.height },
modifier = Modifier modifier = Modifier
.weight(weight = 1f, fill = false) .weight(weight = 1f, fill = false),
.alpha(textAlpha),
) )
if (readProgress != null) { if (readProgress != null) {
DotSeparatorText() DotSeparatorText()
Text( Text(
text = readProgress, text = readProgress,
maxLines = 1, maxLines = 1,
color = LocalContentColor.current.copy(alpha = ReadItemAlpha),
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = Modifier.alpha(ReadItemAlpha),
) )
} }
} }