mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
update message info view
This commit is contained in:
@@ -450,20 +450,8 @@ struct ChatItemInfoView: View {
|
||||
.foregroundColor(theme.colors.secondary).opacity(0.67)
|
||||
}
|
||||
let v = Group {
|
||||
let (icon, statusColor) = status.statusIcon(theme.colors.secondary, theme.colors.primary)
|
||||
switch status {
|
||||
case .rcvd:
|
||||
ZStack(alignment: .trailing) {
|
||||
Image(systemName: icon)
|
||||
.foregroundColor(statusColor.opacity(0.67))
|
||||
.padding(.trailing, 6)
|
||||
Image(systemName: icon)
|
||||
.foregroundColor(statusColor.opacity(0.67))
|
||||
}
|
||||
default:
|
||||
Image(systemName: icon)
|
||||
.foregroundColor(statusColor)
|
||||
}
|
||||
let statusIcon = status.statusIcon(theme.colors.secondary, theme.colors.primary)
|
||||
statusIcon.image.foregroundColor(statusIcon.color)
|
||||
}
|
||||
|
||||
if let (title, text) = status.statusInfo {
|
||||
|
||||
@@ -2765,6 +2765,27 @@ public func formatTimestampText(_ date: Date) -> Text {
|
||||
Text(verbatim: date.formatted(date: .omitted, time: .shortened))
|
||||
}
|
||||
|
||||
public struct StatusIcon {
|
||||
public enum Source {
|
||||
case system(String)
|
||||
case bundled(String)
|
||||
}
|
||||
public let source: Source
|
||||
public let color: Color
|
||||
|
||||
init(_ source: Source, in color: Color) {
|
||||
self.source = source
|
||||
self.color = color
|
||||
}
|
||||
|
||||
public var image: Image {
|
||||
switch source {
|
||||
case let .system(name): Image(systemName: name)
|
||||
case let .bundled(name): Image(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum CIStatus: Decodable, Hashable {
|
||||
case sndNew
|
||||
case sndSent(sndProgress: SndCIStatusProgress)
|
||||
@@ -2798,35 +2819,21 @@ public enum CIStatus: Decodable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Icon {
|
||||
public enum Source {
|
||||
case system(String)
|
||||
case bundled(String)
|
||||
}
|
||||
public let source: Source
|
||||
public let color: Color
|
||||
|
||||
init(_ source: Source, in color: Color) {
|
||||
self.source = source
|
||||
self.color = color
|
||||
}
|
||||
}
|
||||
|
||||
public func statusIcon(_ metaColor: Color, _ primaryColor: Color = .accentColor) -> Icon? {
|
||||
public func statusIcon(_ metaColor: Color, _ primaryColor: Color = .accentColor) -> StatusIcon? {
|
||||
switch self {
|
||||
case .sndNew: nil
|
||||
case .sndSent: Icon(.bundled("checkmark.space"), in: metaColor)
|
||||
case .sndSent: StatusIcon(.bundled("checkmark.space"), in: metaColor)
|
||||
case let .sndRcvd(msgRcptStatus, _):
|
||||
switch msgRcptStatus {
|
||||
case .ok: Icon(.bundled("checkmark.slash"), in: metaColor)
|
||||
case .badMsgHash: Icon(.bundled("checkmark.slash"), in: .red)
|
||||
case .ok: StatusIcon(.bundled("checkmark.slash"), in: metaColor)
|
||||
case .badMsgHash: StatusIcon(.bundled("checkmark.slash"), in: .red)
|
||||
}
|
||||
case .sndErrorAuth: Icon(.system("multiply"), in: .red)
|
||||
case .sndError: Icon(.system("multiply"), in: .red)
|
||||
case .sndWarning: Icon(.system("exclamationmark.triangle.fill"), in: .orange)
|
||||
case .rcvNew: Icon(.system("circlebadge.fill"), in: primaryColor)
|
||||
case .sndErrorAuth: StatusIcon(.system("multiply"), in: .red)
|
||||
case .sndError: StatusIcon(.system("multiply"), in: .red)
|
||||
case .sndWarning: StatusIcon(.system("exclamationmark.triangle.fill"), in: .orange)
|
||||
case .rcvNew: StatusIcon(.system("circlebadge.fill"), in: primaryColor)
|
||||
case .rcvRead: nil
|
||||
case .invalid: Icon(.system("questionmark"), in: metaColor)
|
||||
case .invalid: StatusIcon(.system("questionmark"), in: metaColor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2921,20 +2928,20 @@ public enum GroupSndStatus: Decodable, Hashable {
|
||||
case warning(agentError: SndError)
|
||||
case invalid(text: String)
|
||||
|
||||
public func statusIcon(_ metaColor: Color/* = .secondary*/, _ primaryColor: Color = .accentColor) -> (String, Color) {
|
||||
public func statusIcon(_ metaColor: Color/* = .secondary*/, _ primaryColor: Color = .accentColor) -> StatusIcon {
|
||||
switch self {
|
||||
case .new: return ("ellipsis", metaColor)
|
||||
case .forwarded: return ("chevron.forward.2", metaColor)
|
||||
case .inactive: return ("person.badge.minus", metaColor)
|
||||
case .sent: return ("checkmark", metaColor)
|
||||
case .new: StatusIcon(.system("ellipsis"), in: metaColor)
|
||||
case .forwarded: StatusIcon(.system("chevron.forward.2"), in: metaColor)
|
||||
case .inactive: StatusIcon(.system("person.badge.minus"), in: metaColor)
|
||||
case .sent: StatusIcon(.bundled("checkmark.space"), in: metaColor)
|
||||
case let .rcvd(msgRcptStatus):
|
||||
switch msgRcptStatus {
|
||||
case .ok: return ("checkmark", metaColor)
|
||||
case .badMsgHash: return ("checkmark", .red)
|
||||
case .ok: StatusIcon(.bundled("checkmark.slash"), in: metaColor)
|
||||
case .badMsgHash: StatusIcon(.bundled("checkmark.slash"), in: .red)
|
||||
}
|
||||
case .error: return ("multiply", .red)
|
||||
case .warning: return ("exclamationmark.triangle.fill", .orange)
|
||||
case .invalid: return ("questionmark", metaColor)
|
||||
case .error: StatusIcon(.system("multiply"), in: .red)
|
||||
case .warning: StatusIcon(.system("exclamationmark.triangle.fill"), in: .orange)
|
||||
case .invalid: StatusIcon(.system("questionmark"), in: metaColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user