revert chips (overall concept changed)

show first and last message as thread and only the date

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-07-10 17:00:19 +02:00
parent c5d3aaa2f4
commit 3031bf8c21
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
4 changed files with 76 additions and 136 deletions

View File

@ -51,28 +51,30 @@ fun StandardAppBar(title: String, menuItems: List<Pair<String, () -> Unit>>?) {
} }
}, },
actions = { actions = {
Box { if (!menuItems.isNullOrEmpty()) {
IconButton(onClick = { expanded = true }) { Box {
Icon( IconButton(onClick = { expanded = true }) {
imageVector = Icons.Default.MoreVert, Icon(
contentDescription = stringResource(R.string.nc_common_more_options) imageVector = Icons.Default.MoreVert,
) contentDescription = stringResource(R.string.nc_common_more_options)
}
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier.background(color = colorResource(id = R.color.bg_default))
) {
menuItems?.forEach { (label, action) ->
DropdownMenuItem(
text = { Text(label) },
onClick = {
action()
expanded = false
}
) )
} }
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier.background(color = colorResource(id = R.color.bg_default))
) {
menuItems?.forEach { (label, action) ->
DropdownMenuItem(
text = { Text(label) },
onClick = {
action()
expanded = false
}
)
}
}
} }
} }
} }

View File

@ -32,7 +32,7 @@ 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
import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.colorResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import autodagger.AutoInjector import autodagger.AutoInjector
@ -95,8 +95,7 @@ class ThreadsOverviewActivity : BaseActivity() {
.statusBarsPadding(), .statusBarsPadding(),
topBar = { topBar = {
StandardAppBar( StandardAppBar(
// title = stringResource(R.string.threads_overview), title = stringResource(R.string.recent_threads),
title = "Threads....",
null null
) )
}, },
@ -205,24 +204,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 lastReadMessage = threadInfo.attendee?.lastReadMessage ?: 0
val lastMentionMessage = threadInfo.attendee?.lastMentionMessage ?: 0
val lastMentionDirect = threadInfo.attendee?.lastMentionDirect ?: 0
ThreadRow( ThreadRow(
threadId = threadInfo.thread!!.id,
threadName = threadInfo.first?.actorDisplayName.orEmpty(),
threadMessage = threadInfo.first?.message.toString(),
numReplies = threadInfo.thread?.numReplies ?: 0,
unreadMention = lastMentionMessage > lastReadMessage,
unreadMentionDirect = lastMentionDirect > lastReadMessage,
lastActivityDate = getLastActivityDate(threadInfo), // TODO: replace with value from api when available
imageRequest = imageRequest,
roomToken = roomToken, roomToken = roomToken,
onThreadClick = onThreadClick threadId = threadInfo.thread!!.id,
firstLine = threadInfo.first?.message.toString(),
secondLine = threadInfo.last?.message.toString(),
date = getLastActivityDate(threadInfo), // TODO: replace with value from api when available
imageRequest = imageRequest,
onClick = onThreadClick
) )
} }
} }

View File

@ -7,7 +7,6 @@
package com.nextcloud.talk.threadsoverview.components package com.nextcloud.talk.threadsoverview.components
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -17,14 +16,11 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
@ -35,22 +31,19 @@ import com.nextcloud.talk.R
@Composable @Composable
fun ThreadRow( fun ThreadRow(
threadId: Int,
threadName: String,
threadMessage: String,
lastActivityDate: String,
numReplies: Int?,
unreadMention: Boolean,
unreadMentionDirect: Boolean,
imageRequest: ImageRequest?,
roomToken: String, roomToken: String,
onThreadClick: ((String, Int) -> Unit?)? threadId: Int,
firstLine: String,
secondLine: String,
date: String,
imageRequest: ImageRequest?,
onClick: ((String, Int) -> Unit?)?
) { ) {
Row( Row(
modifier = Modifier.Companion modifier = Modifier.Companion
.fillMaxWidth() .fillMaxWidth()
.clickable(enabled = onThreadClick != null) { .clickable(enabled = onClick != null) {
onThreadClick?.invoke(roomToken, threadId) onClick?.invoke(roomToken, threadId)
} }
.padding(vertical = 8.dp, horizontal = 8.dp), .padding(vertical = 8.dp, horizontal = 8.dp),
verticalAlignment = Alignment.Companion.CenterVertically verticalAlignment = Alignment.Companion.CenterVertically
@ -63,63 +56,31 @@ fun ThreadRow(
Spacer(modifier = Modifier.Companion.width(12.dp)) Spacer(modifier = Modifier.Companion.width(12.dp))
Column(modifier = Modifier.Companion.weight(1f)) { Column {
Text( Text(
text = threadName, text = firstLine,
style = MaterialTheme.typography.titleMedium, style = MaterialTheme.typography.titleMedium,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis overflow = TextOverflow.Companion.Ellipsis
) )
Spacer(modifier = Modifier.Companion.height(2.dp)) Spacer(modifier = Modifier.Companion.height(2.dp))
Text(
text = threadMessage,
style = MaterialTheme.typography.bodyMedium,
maxLines = 2,
overflow = TextOverflow.Companion.Ellipsis
)
}
Spacer(modifier = Modifier.Companion.width(8.dp)) Row {
Text(
Column(horizontalAlignment = Alignment.Companion.End) { modifier = Modifier.Companion.weight(1f),
Text( text = secondLine,
text = lastActivityDate, style = MaterialTheme.typography.bodyMedium,
style = MaterialTheme.typography.bodyMedium, maxLines = 2,
color = MaterialTheme.colorScheme.onSurfaceVariant overflow = TextOverflow.Companion.Ellipsis
) )
Text(
Spacer(modifier = Modifier.Companion.height(4.dp)) text = date,
style = MaterialTheme.typography.bodyMedium,
if ((numReplies ?: 0) > 0) { color = MaterialTheme.colorScheme.onSurfaceVariant,
val isOutlined = unreadMention )
val chipColor = when {
unreadMentionDirect -> MaterialTheme.colorScheme.primary
unreadMention -> Color.Companion.Transparent
else -> MaterialTheme.colorScheme.surfaceVariant
}
val chipTextColor = when {
unreadMentionDirect -> MaterialTheme.colorScheme.onPrimary
unreadMention -> MaterialTheme.colorScheme.primary
else -> MaterialTheme.colorScheme.onSurfaceVariant
}
val border = if (isOutlined)
BorderStroke(1.dp, MaterialTheme.colorScheme.primary)
else
null
Surface(
shape = RoundedCornerShape(12.dp),
color = chipColor,
border = border,
) {
Text(
text = numReplies.toString(),
modifier = Modifier.Companion.padding(horizontal = 8.dp, vertical = 4.dp),
style = MaterialTheme.typography.bodySmall,
color = chipTextColor
)
}
} }
} }
Spacer(modifier = Modifier.Companion.width(16.dp)) Spacer(modifier = Modifier.Companion.width(16.dp))
@ -130,15 +91,12 @@ fun ThreadRow(
@Composable @Composable
fun ThreadRowPreview() { fun ThreadRowPreview() {
ThreadRow( ThreadRow(
threadId = 123,
threadName = "actor name aka. thread name",
threadMessage = "The message of the first message of the thread...",
numReplies = 0,
unreadMention = false,
unreadMentionDirect = false,
lastActivityDate = "14 sec ago",
roomToken = "1234", roomToken = "1234",
onThreadClick = null, threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null imageRequest = null
) )
} }
@ -147,15 +105,12 @@ fun ThreadRowPreview() {
@Composable @Composable
fun ThreadRowUnreadMessagePreview() { fun ThreadRowUnreadMessagePreview() {
ThreadRow( ThreadRow(
threadId = 123,
threadName = "actor name aka. thread name",
threadMessage = "The message of the first message of the thread...",
numReplies = 3,
unreadMention = false,
unreadMentionDirect = false,
lastActivityDate = "14 sec ago",
roomToken = "1234", roomToken = "1234",
onThreadClick = null, threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null imageRequest = null
) )
} }
@ -164,15 +119,12 @@ fun ThreadRowUnreadMessagePreview() {
@Composable @Composable
fun ThreadRowMentionPreview() { fun ThreadRowMentionPreview() {
ThreadRow( ThreadRow(
threadId = 123,
threadName = "actor name aka. thread name",
threadMessage = "The message of the first message of the thread...",
numReplies = 3,
unreadMention = true,
unreadMentionDirect = false,
lastActivityDate = "14 sec ago",
roomToken = "1234", roomToken = "1234",
onThreadClick = null, threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null imageRequest = null
) )
} }
@ -181,15 +133,12 @@ fun ThreadRowMentionPreview() {
@Composable @Composable
fun ThreadRowDirectMentionPreview() { fun ThreadRowDirectMentionPreview() {
ThreadRow( ThreadRow(
threadId = 123,
threadName = "actor name aka. thread name",
threadMessage = "The message of the first message of the thread...",
numReplies = 3,
unreadMention = false,
unreadMentionDirect = true,
lastActivityDate = "14 sec ago",
roomToken = "1234", roomToken = "1234",
onThreadClick = null, threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null imageRequest = null
) )
} }

View File

@ -552,7 +552,7 @@ How to translate with transifex:
<string name="open_thread">See thread</string> <string name="open_thread">See thread</string>
<string name="reply_in_thread">Reply in thread</string> <string name="reply_in_thread">Reply in thread</string>
<string name="show_threads_overview">Show threads</string> <string name="show_threads_overview">Show threads</string>
<string name="threads_overview">Threads</string> <string name="recent_threads">Recent threads</string>
<!-- Upload --> <!-- Upload -->
<string name="nc_add_file">Add to conversation</string> <string name="nc_add_file">Add to conversation</string>