add replies amount to threads overview items

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-07-12 00:32:32 +02:00
parent 57f4e2de1b
commit 429e38e685
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 13 additions and 7 deletions

View File

@ -25,13 +25,10 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -211,16 +208,14 @@ fun ThreadsList(
val errorPlaceholderImage: Int = R.drawable.account_circle_96dp val errorPlaceholderImage: Int = R.drawable.account_circle_96dp
val imageRequest = loadImage(imageUri, context, errorPlaceholderImage) val imageRequest = loadImage(imageUri, context, errorPlaceholderImage)
val secondLineText =
threadInfo.last?.message ?: (String.format(stringResource(R.string.thread_replies_amount, 0)))
ThreadRow( ThreadRow(
roomToken = roomToken, roomToken = roomToken,
threadId = threadInfo.thread!!.id, threadId = threadInfo.thread!!.id,
firstLineTitle = threadInfo.first?.actorDisplayName.orEmpty(), firstLineTitle = threadInfo.first?.actorDisplayName.orEmpty(),
firstLine = threadInfo.first?.message.orEmpty(), firstLine = threadInfo.first?.message.orEmpty(),
numReplies = String.format(stringResource(R.string.thread_replies_amount, threadInfo.thread?.numReplies ?: 0)),
secondLineTitle = threadInfo.last?.actorDisplayName?.let { "$it:" }.orEmpty(), secondLineTitle = threadInfo.last?.actorDisplayName?.let { "$it:" }.orEmpty(),
secondLine = secondLineText, secondLine = threadInfo.last?.message.orEmpty(),
date = getLastActivityDate(threadInfo), // TODO: replace with value from api when available date = getLastActivityDate(threadInfo), // TODO: replace with value from api when available
imageRequest = imageRequest, imageRequest = imageRequest,
onClick = onThreadClick onClick = onThreadClick

View File

@ -38,6 +38,7 @@ fun ThreadRow(
firstLine: String, firstLine: String,
secondLineTitle: String, secondLineTitle: String,
secondLine: String, secondLine: String,
numReplies: String,
date: String, date: String,
imageRequest: ImageRequest?, imageRequest: ImageRequest?,
onClick: ((String, Int) -> Unit?)? onClick: ((String, Int) -> Unit?)?
@ -71,6 +72,7 @@ fun ThreadRow(
) )
Spacer(modifier = Modifier.Companion.width(4.dp)) Spacer(modifier = Modifier.Companion.width(4.dp))
Text( Text(
modifier = Modifier.Companion.weight(1f),
text = firstLine, text = firstLine,
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
@ -78,6 +80,11 @@ fun ThreadRow(
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis overflow = TextOverflow.Companion.Ellipsis
) )
Text(
text = numReplies,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
} }
Spacer(modifier = Modifier.Companion.height(2.dp)) Spacer(modifier = Modifier.Companion.height(2.dp))
@ -125,6 +132,7 @@ fun ThreadRowPreview() {
secondLine = "last message", secondLine = "last message",
firstLineTitle = "Marsellus", firstLineTitle = "Marsellus",
secondLineTitle = "Mia:", secondLineTitle = "Mia:",
numReplies = "12 replies",
date = "14 sec ago", date = "14 sec ago",
onClick = null, onClick = null,
imageRequest = null imageRequest = null
@ -141,6 +149,7 @@ fun ThreadRowUnreadMessagePreview() {
secondLine = "last message", secondLine = "last message",
firstLineTitle = "Marsellus", firstLineTitle = "Marsellus",
secondLineTitle = "Mia:", secondLineTitle = "Mia:",
numReplies = "12 replies",
date = "14 sec ago", date = "14 sec ago",
onClick = null, onClick = null,
imageRequest = null imageRequest = null
@ -157,6 +166,7 @@ fun ThreadRowMentionPreview() {
secondLine = "last message", secondLine = "last message",
firstLineTitle = "Marsellus", firstLineTitle = "Marsellus",
secondLineTitle = "Mia:", secondLineTitle = "Mia:",
numReplies = "12 replies",
date = "14 sec ago", date = "14 sec ago",
onClick = null, onClick = null,
imageRequest = null imageRequest = null
@ -173,6 +183,7 @@ fun ThreadRowDirectMentionPreview() {
secondLine = "last message", secondLine = "last message",
firstLineTitle = "Marsellus", firstLineTitle = "Marsellus",
secondLineTitle = "Mia:", secondLineTitle = "Mia:",
numReplies = "12 replies",
date = "14 sec ago", date = "14 sec ago",
onClick = null, onClick = null,
imageRequest = null imageRequest = null