android: show message time instead of message id in bubbles
Some checks failed
CI / test (push) Failing after 2m10s
Some checks failed
CI / test (push) Failing after 2m10s
This commit is contained in:
@@ -55,6 +55,9 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import coil.compose.AsyncImage
|
||||
import ru.daemonlord.messenger.domain.message.model.MessageItem
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
@Composable
|
||||
fun ChatRoute(
|
||||
@@ -609,7 +612,7 @@ private fun MessageBubble(
|
||||
else -> ""
|
||||
}
|
||||
Text(
|
||||
text = "${message.id}$status",
|
||||
text = "${formatMessageTime(message.createdAt)}$status",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
)
|
||||
}
|
||||
@@ -617,6 +620,17 @@ private fun MessageBubble(
|
||||
}
|
||||
}
|
||||
|
||||
private val messageTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm")
|
||||
|
||||
private fun formatMessageTime(createdAt: String): String {
|
||||
return runCatching {
|
||||
Instant.parse(createdAt)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalTime()
|
||||
.format(messageTimeFormatter)
|
||||
}.getOrElse { "--:--" }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AudioAttachmentPlayer(url: String) {
|
||||
var isPlaying by remember(url) { mutableStateOf(false) }
|
||||
|
||||
Reference in New Issue
Block a user