-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display messages count in a conversation (#57)
- display messages count in a conversation
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material3.Divider | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
|
@@ -21,13 +23,16 @@ import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import tech.relaycorp.letro.R | ||
import tech.relaycorp.letro.messages.model.ExtendedConversation | ||
import tech.relaycorp.letro.messages.model.ExtendedMessage | ||
import tech.relaycorp.letro.ui.theme.LargeProminent | ||
import tech.relaycorp.letro.ui.theme.MediumProminent | ||
import tech.relaycorp.letro.ui.theme.SmallProminent | ||
import tech.relaycorp.letro.ui.utils.ConversationsStringsProvider | ||
import java.util.UUID | ||
|
||
@Composable | ||
fun ConversationsListScreen( | ||
|
@@ -84,6 +89,19 @@ private fun Conversation( | |
color = MaterialTheme.colorScheme.onSurface, | ||
maxLines = 1, | ||
) | ||
if (conversation.totalMessagesFormattedText != null) { | ||
Spacer(modifier = Modifier.width(4.dp)) | ||
Text( | ||
text = conversation.totalMessagesFormattedText, | ||
style = MaterialTheme.typography.bodySmall, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
maxLines = 1, | ||
modifier = Modifier | ||
.padding( | ||
top = if (conversation.isRead) 3.dp else 1.dp, | ||
), | ||
) | ||
} | ||
Spacer(modifier = Modifier.weight(1f)) | ||
Text( | ||
text = conversation.lastMessageFormattedTimestamp, | ||
|
@@ -131,3 +149,61 @@ private fun EmptyConversationsView() { | |
) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun Conversation_Preview() { | ||
val conversationId = UUID.randomUUID() | ||
val message = ExtendedMessage( | ||
conversationId = conversationId, | ||
senderVeraId = "[email protected]", | ||
recipientVeraId = "[email protected]", | ||
isOutgoing = true, | ||
contactDisplayName = "Alias", | ||
text = "Hello man!", | ||
sentAtFormatted = "01:03 PM", | ||
) | ||
Column { | ||
Conversation( | ||
conversation = ExtendedConversation( | ||
conversationId = conversationId, | ||
ownerVeraId = "[email protected]", | ||
contactVeraId = "[email protected]", | ||
contactDisplayName = "Alias", | ||
subject = "Subject Preview", | ||
lastMessageTimestamp = System.currentTimeMillis(), | ||
isRead = false, | ||
lastMessageFormattedTimestamp = "01:03 PM", | ||
lastMessage = message, | ||
totalMessagesFormattedText = "(2)", | ||
messages = listOf( | ||
message, | ||
), | ||
), | ||
noSubjectText = "(No subject)", | ||
) { | ||
} | ||
Divider( | ||
modifier = Modifier.height(1.dp), | ||
) | ||
Conversation( | ||
conversation = ExtendedConversation( | ||
conversationId = conversationId, | ||
ownerVeraId = "[email protected]", | ||
contactVeraId = "[email protected]", | ||
contactDisplayName = "Alias", | ||
subject = "Subject Preview", | ||
lastMessageTimestamp = System.currentTimeMillis(), | ||
isRead = true, | ||
lastMessageFormattedTimestamp = "01:03 PM", | ||
lastMessage = message, | ||
totalMessagesFormattedText = "(2)", | ||
messages = listOf( | ||
message, | ||
), | ||
), | ||
noSubjectText = "(No subject)", | ||
) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters