Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
3399880621
commit
ecd223df64
1 file changed
+14
-8
@@ -1,5 +1,6 @@
|
|||||||
package com.m57.hermescontrol.ui.chat
|
package com.m57.hermescontrol.ui.chat
|
||||||
|
|
||||||
|
import android.text.format.DateFormat
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.animation.core.Spring
|
import androidx.compose.animation.core.Spring
|
||||||
@@ -55,6 +56,7 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.luminance
|
import androidx.compose.ui.graphics.luminance
|
||||||
import androidx.compose.ui.platform.LocalClipboardManager
|
import androidx.compose.ui.platform.LocalClipboardManager
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -224,7 +226,7 @@ private fun UserBubble(
|
|||||||
}
|
}
|
||||||
if (!message.isStreaming) {
|
if (!message.isStreaming) {
|
||||||
Text(
|
Text(
|
||||||
text = formatTimestamp(message.timestamp),
|
text = formatTimestamp(message.timestamp, DateFormat.is24HourFormat(LocalContext.current)),
|
||||||
color = userBubbleTextColor.copy(alpha = 0.6f),
|
color = userBubbleTextColor.copy(alpha = 0.6f),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
modifier =
|
modifier =
|
||||||
@@ -354,7 +356,7 @@ private fun AssistantBubble(
|
|||||||
}
|
}
|
||||||
if (!message.isStreaming) {
|
if (!message.isStreaming) {
|
||||||
Text(
|
Text(
|
||||||
text = formatTimestamp(message.timestamp),
|
text = formatTimestamp(message.timestamp, DateFormat.is24HourFormat(LocalContext.current)),
|
||||||
color = textColor.copy(alpha = 0.5f),
|
color = textColor.copy(alpha = 0.5f),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
modifier =
|
modifier =
|
||||||
@@ -856,7 +858,7 @@ private fun ToolBubble(
|
|||||||
|
|
||||||
// ── Timestamp ──
|
// ── Timestamp ──
|
||||||
Text(
|
Text(
|
||||||
text = formatTimestamp(message.timestamp),
|
text = formatTimestamp(message.timestamp, DateFormat.is24HourFormat(LocalContext.current)),
|
||||||
color = contentColor.copy(alpha = 0.5f),
|
color = contentColor.copy(alpha = 0.5f),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
modifier = Modifier.align(Alignment.End).padding(top = 4.dp),
|
modifier = Modifier.align(Alignment.End).padding(top = 4.dp),
|
||||||
@@ -1074,12 +1076,16 @@ private fun RichText(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val TIMESTAMP_FORMATTER =
|
private fun formatTimestamp(
|
||||||
DateTimeFormatter
|
timestamp: Long,
|
||||||
.ofPattern("HH:mm")
|
is24Hour: Boolean,
|
||||||
|
): String {
|
||||||
|
val pattern = if (is24Hour) "HH:mm" else "h:mm a"
|
||||||
|
return DateTimeFormatter
|
||||||
|
.ofPattern(pattern)
|
||||||
.withZone(ZoneId.systemDefault())
|
.withZone(ZoneId.systemDefault())
|
||||||
|
.format(Instant.ofEpochMilli(timestamp))
|
||||||
private fun formatTimestamp(timestamp: Long): String = TIMESTAMP_FORMATTER.format(Instant.ofEpochMilli(timestamp))
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an AnnotatedString with search matches highlighted.
|
* Build an AnnotatedString with search matches highlighted.
|
||||||
|
|||||||
Reference in new issue
Block a user