mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-29 12:49:53 +00:00
iOS: show dates in older messages
This commit is contained in:
parent
b7fda194c8
commit
c81bb0f15d
2 changed files with 5 additions and 11 deletions
|
@ -571,7 +571,11 @@ struct CIMeta: Decodable {
|
||||||
|
|
||||||
|
|
||||||
func timestampText(_ date: Date) -> String {
|
func timestampText(_ date: Date) -> String {
|
||||||
date.formatted(date: .omitted, time: .shortened)
|
let now = Calendar.current.dateComponents([.day, .hour], from: .now)
|
||||||
|
let dc = Calendar.current.dateComponents([.day, .hour], from: date)
|
||||||
|
return now.day == dc.day || ((now.day ?? 0) - (dc.day ?? 0) == 1 && (dc.hour ?? 0) >= 18 && (now.hour ?? 0) < 12)
|
||||||
|
? date.formatted(date: .omitted, time: .shortened)
|
||||||
|
: String(date.formatted(date: .numeric, time: .omitted).prefix(5))
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CIStatus: Decodable {
|
enum CIStatus: Decodable {
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
private var dateFormatter: DateFormatter?
|
|
||||||
|
|
||||||
struct ChatItemView: View {
|
struct ChatItemView: View {
|
||||||
var chatItem: ChatItem
|
var chatItem: ChatItem
|
||||||
var width: CGFloat
|
var width: CGFloat
|
||||||
|
@ -23,14 +21,6 @@ struct ChatItemView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDateFormatter() -> DateFormatter {
|
|
||||||
if let df = dateFormatter { return df }
|
|
||||||
let df = DateFormatter()
|
|
||||||
df.dateFormat = "HH:mm"
|
|
||||||
dateFormatter = df
|
|
||||||
return df
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ChatItemView_Previews: PreviewProvider {
|
struct ChatItemView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group{
|
Group{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue