add actor names to thread overview

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

View File

@ -157,6 +157,7 @@ fun ThreadsOverviewScreen(
is ThreadsOverviewViewModel.ThreadsListUiState.None -> {
LoadingIndicator()
}
is ThreadsOverviewViewModel.ThreadsListUiState.Success -> {
ThreadsList(
threads = state.threadsList!!,
@ -165,6 +166,7 @@ fun ThreadsOverviewScreen(
threadsOverviewViewModel
)
}
is ThreadsOverviewViewModel.ThreadsListUiState.Error -> {
Log.e(TAG, "Error when retrieving threads", uiState.exception)
ErrorView(message = stringResource(R.string.nc_common_error_sorry))
@ -209,11 +211,16 @@ fun ThreadsList(
val errorPlaceholderImage: Int = R.drawable.account_circle_96dp
val imageRequest = loadImage(imageUri, context, errorPlaceholderImage)
val secondLineText =
threadInfo.last?.message ?: (String.format(stringResource(R.string.thread_replies_amount, 0)))
ThreadRow(
roomToken = roomToken,
threadId = threadInfo.thread!!.id,
firstLineTitle = threadInfo.first?.actorDisplayName.orEmpty(),
firstLine = threadInfo.first?.message.orEmpty(),
secondLine = threadInfo.last?.message.orEmpty(),
secondLineTitle = threadInfo.last?.actorDisplayName?.let { "$it:" }.orEmpty(),
secondLine = secondLineText,
date = getLastActivityDate(threadInfo), // TODO: replace with value from api when available
imageRequest = imageRequest,
onClick = onThreadClick

View File

@ -22,6 +22,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@ -33,7 +34,9 @@ import com.nextcloud.talk.R
fun ThreadRow(
roomToken: String,
threadId: Int,
firstLineTitle: String,
firstLine: String,
secondLineTitle: String,
secondLine: String,
date: String,
imageRequest: ImageRequest?,
@ -57,20 +60,45 @@ fun ThreadRow(
Spacer(modifier = Modifier.Companion.width(12.dp))
Column {
Text(
text = firstLine,
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
Row {
Text(
text = firstLineTitle,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
Spacer(modifier = Modifier.Companion.width(4.dp))
Text(
text = firstLine,
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontWeight = FontWeight.Thin,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
}
Spacer(modifier = Modifier.Companion.height(2.dp))
Row {
Row (
verticalAlignment = Alignment.Companion.CenterVertically
){
Text(
text = secondLineTitle,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
Spacer(modifier = Modifier.Companion.width(4.dp))
Text(
modifier = Modifier.Companion.weight(1f),
text = secondLine,
style = MaterialTheme.typography.bodyMedium,
maxLines = 2,
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Thin,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
Text(
@ -95,6 +123,8 @@ fun ThreadRowPreview() {
threadId = 123,
firstLine = "first message",
secondLine = "last message",
firstLineTitle = "Marsellus",
secondLineTitle = "Mia:",
date = "14 sec ago",
onClick = null,
imageRequest = null
@ -109,6 +139,8 @@ fun ThreadRowUnreadMessagePreview() {
threadId = 123,
firstLine = "first message",
secondLine = "last message",
firstLineTitle = "Marsellus",
secondLineTitle = "Mia:",
date = "14 sec ago",
onClick = null,
imageRequest = null
@ -123,6 +155,8 @@ fun ThreadRowMentionPreview() {
threadId = 123,
firstLine = "first message",
secondLine = "last message",
firstLineTitle = "Marsellus",
secondLineTitle = "Mia:",
date = "14 sec ago",
onClick = null,
imageRequest = null
@ -137,6 +171,8 @@ fun ThreadRowDirectMentionPreview() {
threadId = 123,
firstLine = "first message",
secondLine = "last message",
firstLineTitle = "Marsellus",
secondLineTitle = "Mia:",
date = "14 sec ago",
onClick = null,
imageRequest = null