Enable phone number calls in contact details

This commit is contained in:
Benoit Martins 2025-10-30 10:59:46 +01:00
parent 8cd322ff0e
commit bb4134ede0
2 changed files with 81 additions and 43 deletions

View file

@ -81,6 +81,7 @@ struct ContactInnerActionsFragment: View {
.lineLimit(1)
.fixedSize(horizontal: false, vertical: true)
}
Spacer()
Image("phone")
@ -95,15 +96,15 @@ struct ContactInnerActionsFragment: View {
}
.background(.white)
.onTapGesture {
CoreContext.shared.doOnCoreQueue { core in
do {
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.addresses[index])
withAnimation {
telecomManager.doCallOrJoinConf(address: address)
}
} catch {
Log.error("[ContactInnerActionsFragment] unable to create address for a new outgoing call : \(contactAvatarModel.addresses[index]) \(error) ")
}
}
}
.onLongPressGesture(minimumDuration: 0.2) {
contactsListViewModel.stringToCopy = contactAvatarModel.addresses[index]
showingSheet.toggle()
@ -139,12 +140,28 @@ struct ContactInnerActionsFragment: View {
.lineLimit(1)
.fixedSize(horizontal: false, vertical: true)
}
Spacer()
Image("phone")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.grayMain2c600)
.frame(width: 25, height: 25)
.padding(.all, 10)
}
.padding(.vertical, 15)
.padding(.horizontal, 20)
}
.background(.white)
.onTapGesture {
CoreContext.shared.doOnCoreQueue { core in
let address = core.interpretUrl(url: contactAvatarModel.phoneNumbersWithLabel[index].phoneNumber, applyInternationalPrefix: true)
if address != nil {
TelecomManager.shared.doCallOrJoinConf(address: address!)
}
}
}
.onLongPressGesture(minimumDuration: 0.2) {
contactsListViewModel.stringToCopy = entry.phoneNumber
showingSheet.toggle()

View file

@ -144,103 +144,124 @@ struct ContactInnerFragment: View {
Spacer()
Button(action: {
if contactAvatarModel.addresses.count <= 1 {
CoreContext.shared.doOnCoreQueue { core in
if contactAvatarModel.addresses.count == 1 {
do {
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.address)
telecomManager.doCallOrJoinConf(address: address, isVideo: false)
} catch {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
}
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) {
telecomManager.doCallOrJoinConf(address: address, isVideo: false)
}
} else {
DispatchQueue.main.async {
isShowSipAddressesPopupType = 0
isShowSipAddressesPopup = true
}
}
}
}, label: {
VStack {
HStack(alignment: .center) {
Image("phone")
.renderingMode(.template)
.resizable()
.foregroundStyle(contactAvatarModel.address.isEmpty ? Color.grayMain2c400 : Color.grayMain2c600)
.foregroundStyle(Color.grayMain2c600)
.frame(width: 25, height: 25)
}
.padding(16)
.background(contactAvatarModel.address.isEmpty ? Color.grayMain2c100 : Color.grayMain2c200)
.background(Color.grayMain2c200)
.cornerRadius(40)
Text("contact_call_action")
.default_text_style(styleSize: 14)
}
})
.disabled(contactAvatarModel.address.isEmpty)
if !CorePreferences.disableChatFeature {
Spacer()
Button(action: {
if contactAvatarModel.addresses.count <= 1 {
CoreContext.shared.doOnCoreQueue { core in
if contactAvatarModel.addresses.count == 1 {
do {
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.address)
contactsListViewModel.createOneToOneChatRoomWith(remote: address)
} catch {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
}
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) {
contactsListViewModel.createOneToOneChatRoomWith(remote: address)
}
} else {
DispatchQueue.main.async {
isShowSipAddressesPopupType = 1
isShowSipAddressesPopup = true
}
}
}
}, label: {
VStack {
HStack(alignment: .center) {
Image("chat-teardrop-text")
.renderingMode(.template)
.resizable()
.foregroundStyle(contactAvatarModel.address.isEmpty ? Color.grayMain2c400 : Color.grayMain2c600)
.foregroundStyle(Color.grayMain2c600)
.frame(width: 25, height: 25)
}
.padding(16)
.background(contactAvatarModel.address.isEmpty ? Color.grayMain2c100 : Color.grayMain2c200)
.background(Color.grayMain2c200)
.cornerRadius(40)
Text("contact_message_action")
.default_text_style(styleSize: 14)
}
})
.disabled(contactAvatarModel.address.isEmpty)
}
Spacer()
Button(action: {
if contactAvatarModel.addresses.count <= 1 {
CoreContext.shared.doOnCoreQueue { core in
if contactAvatarModel.addresses.count == 1 {
do {
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.address)
telecomManager.doCallOrJoinConf(address: address, isVideo: true)
} catch {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
}
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) {
telecomManager.doCallOrJoinConf(address: address, isVideo: true)
}
} else {
DispatchQueue.main.async {
isShowSipAddressesPopupType = 2
isShowSipAddressesPopup = true
}
}
}
}, label: {
VStack {
HStack(alignment: .center) {
Image("video-camera")
.renderingMode(.template)
.resizable()
.foregroundStyle(contactAvatarModel.address.isEmpty ? Color.grayMain2c400 : Color.grayMain2c600)
.foregroundStyle(Color.grayMain2c600)
.frame(width: 25, height: 25)
}
.padding(16)
.background(contactAvatarModel.address.isEmpty ? Color.grayMain2c100 : Color.grayMain2c200)
.background(Color.grayMain2c200)
.cornerRadius(40)
Text("contact_video_call_action")
.default_text_style(styleSize: 14)
}
})
.disabled(contactAvatarModel.address.isEmpty)
Spacer()
}