Display peer address with a hidden button in conversation

This commit is contained in:
Benoit Martins 2026-02-24 17:52:18 +01:00
parent ef09f6c412
commit db9c9f1834
3 changed files with 86 additions and 7 deletions

View file

@ -2,6 +2,6 @@ import Foundation
public enum AppGitInfo {
public static let branch = "master"
public static let commit = "ca9f5ffe1"
public static let commit = "ef09f6c41"
public static let tag = "6.1.0-alpha"
}

View file

@ -18,6 +18,7 @@
*/
import SwiftUI
import UniformTypeIdentifiers
// swiftlint:disable type_body_length
struct ConversationInfoFragment: View {
@ -46,6 +47,7 @@ struct ConversationInfoFragment: View {
@Binding var isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel]
@State private var participantListIsOpen = true
@State private var displayPeerAddress = false
@Binding var isShowConversationInfoPopup: Bool
@Binding var conversationInfoPopupText: String
@ -77,6 +79,13 @@ struct ConversationInfoFragment: View {
}
Spacer()
Rectangle()
.foregroundColor(.white)
.frame(width: 45, height: 45)
.onLongPressGesture(minimumDuration: 0.3) {
displayPeerAddress = true
}
}
.frame(maxWidth: .infinity)
.frame(height: 50)
@ -107,12 +116,53 @@ struct ConversationInfoFragment: View {
.padding(.top, 10)
if !AppServices.corePreferences.hideSipAddresses {
Text(conversationViewModel.participantConversationModel.first?.address ?? "")
.foregroundStyle(Color.grayMain2c700)
.multilineTextAlignment(.center)
.default_text_style(styleSize: 14)
.frame(maxWidth: .infinity)
.padding(.top, 5)
Button {
UIPasteboard.general.setValue(
conversationViewModel.participantConversationModel.first?.address ?? "",
forPasteboardType: UTType.plainText.identifier
)
ToastViewModel.shared.show("Success_address_copied_into_clipboard")
} label: {
HStack {
Text(conversationViewModel.participantConversationModel.first?.address ?? "")
.foregroundStyle(Color.grayMain2c700)
.default_text_style(styleSize: 14)
.padding(.top, 5)
Image("copy")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25)
}
}
.padding(.horizontal, 10)
}
if displayPeerAddress {
Button {
UIPasteboard.general.setValue(
conversationViewModel.peerAddress,
forPasteboardType: UTType.plainText.identifier
)
ToastViewModel.shared.show("Success_address_copied_into_clipboard")
} label: {
HStack {
Text(conversationViewModel.peerAddress)
.foregroundStyle(Color.grayMain2c700)
.default_text_style(styleSize: 14)
.padding(.top, 5)
Image("copy")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
}
}
.padding(.horizontal, 10)
}
if !SharedMainViewModel.shared.displayedConversation!.avatarModel.lastPresenceInfo.isEmpty {
@ -160,6 +210,31 @@ struct ConversationInfoFragment: View {
}
}
.padding(.leading, conversationViewModel.isUserAdmin ? 20 : 0)
if displayPeerAddress {
Button {
UIPasteboard.general.setValue(
conversationViewModel.peerAddress,
forPasteboardType: UTType.plainText.identifier
)
ToastViewModel.shared.show("Success_address_copied_into_clipboard")
} label: {
HStack {
Text(conversationViewModel.peerAddress)
.foregroundStyle(Color.grayMain2c700)
.default_text_style(styleSize: 14)
.padding(.top, 5)
Image("copy")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c500)
.frame(width: 25, height: 25, alignment: .leading)
}
}
.padding(.horizontal, 10)
}
}
}
.frame(minHeight: 150)

View file

@ -112,6 +112,8 @@ class ConversationViewModel: ObservableObject {
@Published var searchInProgress = false
@Published var highlightedMessageID: String?
@Published var peerAddress = ""
var latestMatch: EventLogMessage?
struct SheetCategory: Identifiable {
@ -689,6 +691,8 @@ class ConversationViewModel: ObservableObject {
self.computeComposingLabel()
self.getEphemeralTime()
self.peerAddress = self.sharedMainViewModel.displayedConversation!.chatRoom.peerAddress?.asStringUriOnly() ?? ""
if self.sharedMainViewModel.displayedConversation != nil {
let historyEvents = self.sharedMainViewModel.displayedConversation!.chatRoom.getHistoryRangeEvents(begin: 0, end: 30)