Allow selecting chapter items

This commit is contained in:
Syer10
2021-08-29 12:52:50 -04:00
parent f8b5cccdad
commit af97b31537

View File

@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Card import androidx.compose.material.Card
import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.ContentAlpha import androidx.compose.material.ContentAlpha
@@ -89,15 +90,17 @@ fun ChapterItem(
Column( Column(
Modifier.padding(4.dp).width(this@BoxWithConstraints.maxWidth - 60.dp) Modifier.padding(4.dp).width(this@BoxWithConstraints.maxWidth - 60.dp)
) { ) {
Text( SelectionContainer {
chapter.name, Text(
maxLines = 1, chapter.name,
style = MaterialTheme.typography.h6, maxLines = 1,
color = LocalContentColor.current.copy( style = MaterialTheme.typography.h6,
alpha = if (chapter.read) ContentAlpha.disabled else ContentAlpha.high color = LocalContentColor.current.copy(
), alpha = if (chapter.read) ContentAlpha.disabled else ContentAlpha.high
overflow = TextOverflow.Ellipsis ),
) overflow = TextOverflow.Ellipsis
)
}
val subtitleStr = buildAnnotatedString { val subtitleStr = buildAnnotatedString {
if (chapter.uploadDate > 0) { if (chapter.uploadDate > 0) {
append(format(Instant.ofEpochMilli(chapter.uploadDate))) append(format(Instant.ofEpochMilli(chapter.uploadDate)))
@@ -116,13 +119,15 @@ fun ChapterItem(
append(chapter.scanlator) append(chapter.scanlator)
} }
} }
Text( SelectionContainer {
subtitleStr, Text(
style = MaterialTheme.typography.body2, subtitleStr,
color = LocalContentColor.current.copy( style = MaterialTheme.typography.body2,
alpha = if (chapter.read) ContentAlpha.disabled else ContentAlpha.medium color = LocalContentColor.current.copy(
alpha = if (chapter.read) ContentAlpha.disabled else ContentAlpha.medium
)
) )
) }
} }
val downloadChapter by viewChapter.downloadChapterFlow.collectAsState() val downloadChapter by viewChapter.downloadChapterFlow.collectAsState()
val downloadState by viewChapter.downloadState.collectAsState() val downloadState by viewChapter.downloadState.collectAsState()