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 = {
Box {
IconButton(onClick = { expanded = true }) {
Icon(
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
}
if (!menuItems.isNullOrEmpty()) {
Box {
IconButton(onClick = { expanded = true }) {
Icon(
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
}
)
}
}
}
}
}

View File

@ -32,7 +32,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
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.lifecycle.ViewModelProvider
import autodagger.AutoInjector
@ -95,8 +95,7 @@ class ThreadsOverviewActivity : BaseActivity() {
.statusBarsPadding(),
topBar = {
StandardAppBar(
// title = stringResource(R.string.threads_overview),
title = "Threads....",
title = stringResource(R.string.recent_threads),
null
)
},
@ -205,24 +204,14 @@ fun ThreadsList(
val errorPlaceholderImage: Int = R.drawable.account_circle_96dp
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(
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,
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
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
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.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
@ -35,22 +31,19 @@ import com.nextcloud.talk.R
@Composable
fun ThreadRow(
threadId: Int,
threadName: String,
threadMessage: String,
lastActivityDate: String,
numReplies: Int?,
unreadMention: Boolean,
unreadMentionDirect: Boolean,
imageRequest: ImageRequest?,
roomToken: String,
onThreadClick: ((String, Int) -> Unit?)?
threadId: Int,
firstLine: String,
secondLine: String,
date: String,
imageRequest: ImageRequest?,
onClick: ((String, Int) -> Unit?)?
) {
Row(
modifier = Modifier.Companion
.fillMaxWidth()
.clickable(enabled = onThreadClick != null) {
onThreadClick?.invoke(roomToken, threadId)
.clickable(enabled = onClick != null) {
onClick?.invoke(roomToken, threadId)
}
.padding(vertical = 8.dp, horizontal = 8.dp),
verticalAlignment = Alignment.Companion.CenterVertically
@ -63,63 +56,31 @@ fun ThreadRow(
Spacer(modifier = Modifier.Companion.width(12.dp))
Column(modifier = Modifier.Companion.weight(1f)) {
Column {
Text(
text = threadName,
text = firstLine,
style = MaterialTheme.typography.titleMedium,
maxLines = 1,
overflow = TextOverflow.Companion.Ellipsis
)
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))
Column(horizontalAlignment = Alignment.Companion.End) {
Text(
text = lastActivityDate,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.Companion.height(4.dp))
if ((numReplies ?: 0) > 0) {
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
)
}
Row {
Text(
modifier = Modifier.Companion.weight(1f),
text = secondLine,
style = MaterialTheme.typography.bodyMedium,
maxLines = 2,
overflow = TextOverflow.Companion.Ellipsis
)
Text(
text = date,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
Spacer(modifier = Modifier.Companion.width(16.dp))
@ -130,15 +91,12 @@ fun ThreadRow(
@Composable
fun ThreadRowPreview() {
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",
onThreadClick = null,
threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null
)
}
@ -147,15 +105,12 @@ fun ThreadRowPreview() {
@Composable
fun ThreadRowUnreadMessagePreview() {
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",
onThreadClick = null,
threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null
)
}
@ -164,15 +119,12 @@ fun ThreadRowUnreadMessagePreview() {
@Composable
fun ThreadRowMentionPreview() {
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",
onThreadClick = null,
threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null
)
}
@ -181,15 +133,12 @@ fun ThreadRowMentionPreview() {
@Composable
fun ThreadRowDirectMentionPreview() {
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",
onThreadClick = null,
threadId = 123,
firstLine = "first message",
secondLine = "last message",
date = "14 sec ago",
onClick = null,
imageRequest = null
)
}

View File

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