diff --git a/ConversationsClassic/Helpers/String+Extensions.swift b/ConversationsClassic/Helpers/String+Extensions.swift index 0c17952..23eaf66 100644 --- a/ConversationsClassic/Helpers/String+Extensions.swift +++ b/ConversationsClassic/Helpers/String+Extensions.swift @@ -25,6 +25,14 @@ extension String { let lon = Double(parts[1]) ?? 0.0 return CLLocationCoordinate2D(latitude: lat, longitude: lon) } + + var isContact: Bool { + hasPrefix("contact:") + } + + var getContactJid: String { + components(separatedBy: ":")[1] + } } extension String { diff --git a/ConversationsClassic/View/Screens/Conversation/ConversationMessageContainer.swift b/ConversationsClassic/View/Screens/Conversation/ConversationMessageContainer.swift index 6cbda05..bbff7de 100644 --- a/ConversationsClassic/View/Screens/Conversation/ConversationMessageContainer.swift +++ b/ConversationsClassic/View/Screens/Conversation/ConversationMessageContainer.swift @@ -10,6 +10,8 @@ struct ConversationMessageContainer: View { var body: some View { if let msgText = message.body, msgText.isLocation { EmbededMapView(location: msgText.getLatLon) + } else if let msgText = message.body, msgText.isContact { + ContactView(message: message) } else if message.attachmentType != nil { AttachmentView(message: message) } else { @@ -67,6 +69,31 @@ private struct EmbededMapView: View { } } +private struct ContactView: View { + let message: Message + + var body: some View { + VStack { + ZStack { + Circle() + .frame(width: 44, height: 44) + .foregroundColor(.red) + Text(message.body?.getContactJid.firstLetter ?? "?") + .foregroundColor(.white) + .font(.body1) + } + Text(message.body?.getContactJid ?? "...") + .font(.body2) + .foregroundColor(.Material.Text.main) + .multilineTextAlignment(.leading) + } + .padding() + .onTapGesture { + // TODO: Jump to add roster from here + } + } +} + private struct AttachmentView: View { let message: Message