2023-09-20 12:26:16 +04:00
|
|
|
//
|
|
|
|
// CIMemberCreatedContactView.swift
|
|
|
|
// SimpleX (iOS)
|
|
|
|
//
|
|
|
|
// Created by spaced4ndy on 19.09.2023.
|
|
|
|
// Copyright © 2023 SimpleX Chat. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import SimpleXChat
|
|
|
|
|
|
|
|
struct CIMemberCreatedContactView: View {
|
2023-10-31 09:44:57 +00:00
|
|
|
@EnvironmentObject var m: ChatModel
|
2024-07-03 22:42:13 +01:00
|
|
|
@EnvironmentObject var theme: AppTheme
|
2023-09-20 12:26:16 +04:00
|
|
|
var chatItem: ChatItem
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack(alignment: .bottom, spacing: 0) {
|
|
|
|
switch chatItem.chatDir {
|
|
|
|
case let .groupRcv(groupMember):
|
|
|
|
if let contactId = groupMember.memberContactId {
|
|
|
|
memberCreatedContactView(openText: "Open")
|
ios: fix XCode 16 regressions (tap not working on files, quotes, images, voice messages, etc.), open link previews on tap (#5880)
* ios: fix XCode 16 regressions (tap not working on files, quotes, images, voice messages, etc.), open link previews on tap
* fix voice recording
* fix video, accepting calls from chat, preference toggles in chat
* WIP message and meta
* handle links in attributed strings
* custom attribute for links to prevent race conditions with default tap handler
2025-05-10 14:37:45 +01:00
|
|
|
.simultaneousGesture(TapGesture().onEnded {
|
2025-03-06 17:31:05 +07:00
|
|
|
ItemsModel.shared.loadOpenChat("@\(contactId)") {
|
|
|
|
dismissAllSheets(animated: true)
|
2023-09-20 12:26:16 +04:00
|
|
|
}
|
ios: fix XCode 16 regressions (tap not working on files, quotes, images, voice messages, etc.), open link previews on tap (#5880)
* ios: fix XCode 16 regressions (tap not working on files, quotes, images, voice messages, etc.), open link previews on tap
* fix voice recording
* fix video, accepting calls from chat, preference toggles in chat
* WIP message and meta
* handle links in attributed strings
* custom attribute for links to prevent race conditions with default tap handler
2025-05-10 14:37:45 +01:00
|
|
|
})
|
2023-09-20 12:26:16 +04:00
|
|
|
} else {
|
|
|
|
memberCreatedContactView()
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
EmptyView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(.leading, 6)
|
|
|
|
.padding(.bottom, 6)
|
|
|
|
.textSelection(.disabled)
|
|
|
|
}
|
|
|
|
|
|
|
|
private func memberCreatedContactView(openText: LocalizedStringKey? = nil) -> some View {
|
|
|
|
var r = eventText()
|
|
|
|
if let openText {
|
|
|
|
r = r
|
|
|
|
+ Text(openText)
|
|
|
|
.fontWeight(.medium)
|
2024-07-03 22:42:13 +01:00
|
|
|
.foregroundColor(theme.colors.primary)
|
2024-11-27 19:01:16 +00:00
|
|
|
+ Text(verbatim: " ")
|
2023-09-20 12:26:16 +04:00
|
|
|
}
|
|
|
|
r = r + chatItem.timestampText
|
|
|
|
.fontWeight(.light)
|
2024-07-03 22:42:13 +01:00
|
|
|
.foregroundColor(theme.colors.secondary)
|
2023-09-20 12:26:16 +04:00
|
|
|
return r.font(.caption)
|
|
|
|
}
|
|
|
|
|
|
|
|
private func eventText() -> Text {
|
|
|
|
if let member = chatItem.memberDisplayName {
|
|
|
|
return Text(member + " " + chatItem.content.text + " ")
|
|
|
|
.fontWeight(.light)
|
2024-07-03 22:42:13 +01:00
|
|
|
.foregroundColor(theme.colors.secondary)
|
2023-09-20 12:26:16 +04:00
|
|
|
} else {
|
|
|
|
return Text(chatItem.content.text + " ")
|
|
|
|
.fontWeight(.light)
|
2024-07-03 22:42:13 +01:00
|
|
|
.foregroundColor(theme.colors.secondary)
|
2023-09-20 12:26:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct CIMemberCreatedContactView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
let content = CIContent.rcvGroupEvent(rcvGroupEvent: .memberCreatedContact)
|
|
|
|
let chatItem = ChatItem(
|
|
|
|
chatDir: .groupRcv(groupMember: GroupMember.sampleData),
|
|
|
|
meta: CIMeta.getSample(1, .now, content.text, .rcvRead),
|
|
|
|
content: content,
|
|
|
|
quotedItem: nil,
|
|
|
|
file: nil
|
|
|
|
)
|
|
|
|
CIMemberCreatedContactView(chatItem: chatItem)
|
|
|
|
}
|
|
|
|
}
|