mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-01 00:04:36 +00:00
refactor
This commit is contained in:
+4
-4
@@ -2423,11 +2423,11 @@ data class CITimed(
|
||||
val deleteAt: Instant?
|
||||
)
|
||||
|
||||
fun getDateText(t: Instant): String {
|
||||
fun getTimestampDateText(t: Instant): String {
|
||||
val tz = TimeZone.currentSystemDefault()
|
||||
val time = t.toLocalDateTime(tz)
|
||||
val weekday = time.toJavaLocalDateTime().format(DateTimeFormatter.ofPattern("EEE", Locale.getDefault()))
|
||||
val dayMonthYear = time.toJavaLocalDateTime().format(DateTimeFormatter.ofPattern(
|
||||
val time = t.toLocalDateTime(tz).toJavaLocalDateTime()
|
||||
val weekday = time.format(DateTimeFormatter.ofPattern("EEE", Locale.getDefault()))
|
||||
val dayMonthYear = time.format(DateTimeFormatter.ofPattern(
|
||||
if (Clock.System.now().toLocalDateTime(tz).year == time.year) "d MMM" else "d MMM YYYY",
|
||||
Locale.getDefault())
|
||||
)
|
||||
|
||||
+3
-4
@@ -43,7 +43,6 @@ import kotlinx.coroutines.flow.*
|
||||
import kotlinx.datetime.*
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.time.format.DateTimeFormatter
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.sign
|
||||
|
||||
@@ -1518,8 +1517,8 @@ private fun ButtonRow(horizontalArrangement: Arrangement.Horizontal, content: @C
|
||||
@Composable
|
||||
fun DateSeparator(date: Instant) {
|
||||
Text(
|
||||
text = getDateText(date),
|
||||
fontSize = 16.sp,
|
||||
text = getTimestampDateText(date),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colors.secondary
|
||||
)
|
||||
@@ -1912,7 +1911,7 @@ private fun getItemSeparation(chatItem: ChatItem, nextItem: ChatItem?): ItemSepa
|
||||
return ItemSeparation(
|
||||
timestamp = largeGap || chatItem.meta.timestampText != nextItem.meta.timestampText,
|
||||
largeGap = largeGap,
|
||||
date = if (getDateText(chatItem.meta.itemTs) != getDateText(nextItem.meta.itemTs)) nextItem.meta.itemTs else null
|
||||
date = if (getTimestampDateText(chatItem.meta.itemTs) != getTimestampDateText(nextItem.meta.itemTs)) nextItem.meta.itemTs else null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user