From 3f6c74f97580bc2dc4722007a7507dfc5c96e25c Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Mon, 11 Mar 2024 10:36:36 +0000 Subject: [PATCH] ios: e2e information chat items (#3890) * ios: e2e information chat items * texts --- apps/ios/Shared/Views/Chat/ChatItemView.swift | 25 +++++++++++++++---- apps/ios/SimpleXChat/ChatTypes.swift | 18 ++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatItemView.swift b/apps/ios/Shared/Views/Chat/ChatItemView.swift index d9404547e2..177bbbe1c4 100644 --- a/apps/ios/Shared/Views/Chat/ChatItemView.swift +++ b/apps/ios/Shared/Views/Chat/ChatItemView.swift @@ -111,11 +111,10 @@ struct ChatItemContentView: View { case .rcvModerated: deletedItemView() case .rcvBlocked: deletedItemView() case let .invalidJSON(json): CIInvalidJSONView(json: json) - // TODO proper items - case .sndDirectE2EEInfo: CIEventView(eventText: Text(chatItem.content.text)) - case .rcvDirectE2EEInfo: CIEventView(eventText: Text(chatItem.content.text)) - case .sndGroupE2EEInfo: CIEventView(eventText: Text(chatItem.content.text)) - case .rcvGroupE2EEInfo: CIEventView(eventText: Text(chatItem.content.text)) + case let .sndDirectE2EEInfo(e2eeInfo): CIEventView(eventText: directE2EEInfoText(e2eeInfo)) + case let .rcvDirectE2EEInfo(e2eeInfo): CIEventView(eventText: directE2EEInfoText(e2eeInfo)) + case .sndGroupE2EEInfo: CIEventView(eventText: e2eeInfoNoPQText()) + case .rcvGroupE2EEInfo: CIEventView(eventText: e2eeInfoNoPQText()) } } @@ -175,6 +174,22 @@ struct ChatItemContentView: View { Text(members) } } + + private func directE2EEInfoText(_ info: E2EEInfo) -> Text { + info.pqEnabled + ? Text("Messages, files and calls are protected by **quantum resistant e2e encryption**. It has perfect forward secrecy, repudiation and break-in recovery.") + .font(.caption) + .foregroundColor(.secondary) + .fontWeight(.light) + : e2eeInfoNoPQText() + } + + private func e2eeInfoNoPQText() -> Text { + Text("Messages, files and calls are protected by **end-to-end encryption** with perfect forward secrecy, repudiation and break-in recovery.") + .font(.caption) + .foregroundColor(.secondary) + .fontWeight(.light) + } } func chatEventText(_ text: Text) -> Text { diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index 3463bfca18..4349fc7beb 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -2784,23 +2784,23 @@ public enum CIContent: Decodable, ItemContent { case .sndModerated: return NSLocalizedString("moderated", comment: "moderated chat item") case .rcvModerated: return NSLocalizedString("moderated", comment: "moderated chat item") case .rcvBlocked: return NSLocalizedString("blocked by admin", comment: "blocked chat item") - case let .sndDirectE2EEInfo(e2eeInfo): return directE2EEInfoToText(e2eeInfo) - case let .rcvDirectE2EEInfo(e2eeInfo): return directE2EEInfoToText(e2eeInfo) - case .sndGroupE2EEInfo: return e2eeInfoNoPQText - case .rcvGroupE2EEInfo: return e2eeInfoNoPQText + case let .sndDirectE2EEInfo(e2eeInfo): return directE2EEInfoStr(e2eeInfo) + case let .rcvDirectE2EEInfo(e2eeInfo): return directE2EEInfoStr(e2eeInfo) + case .sndGroupE2EEInfo: return e2eeInfoNoPQStr + case .rcvGroupE2EEInfo: return e2eeInfoNoPQStr case .invalidJSON: return NSLocalizedString("invalid data", comment: "invalid chat item") } } } - private func directE2EEInfoToText(_ e2eeInfo: E2EEInfo) -> String { + private func directE2EEInfoStr(_ e2eeInfo: E2EEInfo) -> String { e2eeInfo.pqEnabled - ? NSLocalizedString("This conversation is protected by quantum resistant end-to-end encryption. It has perfect forward secrecy, repudiation and quantum resistant break-in recovery.", comment: "E2EE info chat item") - : e2eeInfoNoPQText + ? NSLocalizedString("This chat is protected by quantum resistant end-to-end encryption.", comment: "E2EE info chat item") + : e2eeInfoNoPQStr } - private var e2eeInfoNoPQText: String { - NSLocalizedString("This conversation is protected by end-to-end encryption with perfect forward secrecy, repudiation and break-in recovery.", comment: "E2EE info chat item") + private var e2eeInfoNoPQStr: String { + NSLocalizedString("This chat is protected by end-to-end encryption.", comment: "E2EE info chat item") } static func featureText(_ feature: Feature, _ enabled: String, _ param: Int?) -> String {