forked from mirrors/linphone-iphone
Fix display of confs in story fragments
This commit is contained in:
parent
ea18eaa3d6
commit
0d210dea6d
6 changed files with 761 additions and 599 deletions
21
Linphone/Assets.xcassets/users-three-square.imageset/Contents.json
vendored
Normal file
21
Linphone/Assets.xcassets/users-three-square.imageset/Contents.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "users-three-square.svg",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
8
Linphone/Assets.xcassets/users-three-square.imageset/users-three-square.svg
vendored
Normal file
8
Linphone/Assets.xcassets/users-three-square.imageset/users-three-square.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.6 KiB |
File diff suppressed because it is too large
Load diff
|
|
@ -38,117 +38,137 @@ struct HistoryListFragment: View {
|
|||
ForEach(0..<historyListViewModel.callLogs.count, id: \.self) { index in
|
||||
HStack {
|
||||
HStack {
|
||||
let fromAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].fromAddress!)
|
||||
let toAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].toAddress!)
|
||||
let addressFriend = historyListViewModel.callLogs[index].dir == .Incoming ? fromAddressFriend : toAddressFriend
|
||||
|
||||
let contactAvatarModel = addressFriend != nil
|
||||
? ContactsManager.shared.avatarListModel.first(where: {
|
||||
($0.friend!.consolidatedPresence == .Online || $0.friend!.consolidatedPresence == .Busy)
|
||||
&& $0.friend!.name == addressFriend!.name
|
||||
&& $0.friend!.address!.asStringUriOnly() == addressFriend!.address!.asStringUriOnly()
|
||||
})
|
||||
: ContactAvatarModel(friend: nil, name: "", withPresence: false)
|
||||
|
||||
if addressFriend != nil && addressFriend!.photo != nil && !addressFriend!.photo!.isEmpty {
|
||||
if contactAvatarModel != nil {
|
||||
Avatar(contactAvatarModel: contactAvatarModel!, avatarSize: 50)
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
} else {
|
||||
if historyListViewModel.callLogs[index].dir == .Outgoing && historyListViewModel.callLogs[index].toAddress != nil {
|
||||
if historyListViewModel.callLogs[index].toAddress!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].toAddress!.displayName!,
|
||||
lastName: historyListViewModel.callLogs[index].toAddress!.displayName!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].toAddress!.displayName!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].toAddress!.username ?? "Username Error",
|
||||
lastName: historyListViewModel.callLogs[index].toAddress!.username!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].toAddress!.username!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
} else if historyListViewModel.callLogs[index].fromAddress != nil {
|
||||
if historyListViewModel.callLogs[index].fromAddress!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].fromAddress!.displayName!,
|
||||
lastName: historyListViewModel.callLogs[index].fromAddress!.displayName!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].fromAddress!.displayName!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].fromAddress!.username ?? "Username Error",
|
||||
lastName: historyListViewModel.callLogs[index].fromAddress!.username!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].fromAddress!.username!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
}
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Spacer()
|
||||
|
||||
if historyListViewModel.callLogsIsConference[index].isEmpty {
|
||||
let fromAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].fromAddress!)
|
||||
let toAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].toAddress!)
|
||||
let addressFriend = historyListViewModel.callLogs[index].dir == .Incoming ? fromAddressFriend : toAddressFriend
|
||||
|
||||
if addressFriend != nil {
|
||||
Text(addressFriend!.name!)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
let contactAvatarModel = addressFriend != nil
|
||||
? ContactsManager.shared.avatarListModel.first(where: {
|
||||
($0.friend!.consolidatedPresence == .Online || $0.friend!.consolidatedPresence == .Busy)
|
||||
&& $0.friend!.name == addressFriend!.name
|
||||
&& $0.friend!.address!.asStringUriOnly() == addressFriend!.address!.asStringUriOnly()
|
||||
})
|
||||
: ContactAvatarModel(friend: nil, name: "", withPresence: false)
|
||||
|
||||
if addressFriend != nil && addressFriend!.photo != nil && !addressFriend!.photo!.isEmpty {
|
||||
if contactAvatarModel != nil {
|
||||
Avatar(contactAvatarModel: contactAvatarModel!, avatarSize: 50)
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
} else {
|
||||
if historyListViewModel.callLogs[index].dir == .Outgoing && historyListViewModel.callLogs[index].toAddress != nil {
|
||||
Text(historyListViewModel.callLogs[index].toAddress!.displayName != nil
|
||||
? historyListViewModel.callLogs[index].toAddress!.displayName!
|
||||
: historyListViewModel.callLogs[index].toAddress!.username!)
|
||||
if historyListViewModel.callLogs[index].toAddress!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].toAddress!.displayName!,
|
||||
lastName: historyListViewModel.callLogs[index].toAddress!.displayName!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].toAddress!.displayName!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].toAddress!.username ?? "Username Error",
|
||||
lastName: historyListViewModel.callLogs[index].toAddress!.username!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].toAddress!.username!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
} else if historyListViewModel.callLogs[index].fromAddress != nil {
|
||||
if historyListViewModel.callLogs[index].fromAddress!.displayName != nil {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].fromAddress!.displayName!,
|
||||
lastName: historyListViewModel.callLogs[index].fromAddress!.displayName!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].fromAddress!.displayName!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
} else {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
firstName: historyListViewModel.callLogs[index].fromAddress!.username ?? "Username Error",
|
||||
lastName: historyListViewModel.callLogs[index].fromAddress!.username!.components(separatedBy: " ").count > 1
|
||||
? historyListViewModel.callLogs[index].fromAddress!.username!.components(separatedBy: " ")[1]
|
||||
: ""))
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
} else {
|
||||
Image("profil-picture-default")
|
||||
.resizable()
|
||||
.frame(width: 45, height: 45)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
VStack {
|
||||
Image("users-three-square")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.frame(width: 28, height: 28)
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
}
|
||||
.frame(width: 45, height: 45)
|
||||
.background(Color.grayMain2c200)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Spacer()
|
||||
if historyListViewModel.callLogsIsConference[index].isEmpty {
|
||||
let fromAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].fromAddress!)
|
||||
let toAddressFriend = contactsManager.getFriendWithAddress(address: historyListViewModel.callLogs[index].toAddress!)
|
||||
let addressFriend = historyListViewModel.callLogs[index].dir == .Incoming ? fromAddressFriend : toAddressFriend
|
||||
|
||||
if addressFriend != nil {
|
||||
Text(addressFriend!.name!)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
} else if historyListViewModel.callLogs[index].fromAddress != nil {
|
||||
Text(historyListViewModel.callLogs[index].fromAddress!.displayName != nil
|
||||
? historyListViewModel.callLogs[index].fromAddress!.displayName!
|
||||
: historyListViewModel.callLogs[index].fromAddress!.username!)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
} else {
|
||||
if historyListViewModel.callLogs[index].dir == .Outgoing && historyListViewModel.callLogs[index].toAddress != nil {
|
||||
Text(historyListViewModel.callLogs[index].toAddress!.displayName != nil
|
||||
? historyListViewModel.callLogs[index].toAddress!.displayName!
|
||||
: historyListViewModel.callLogs[index].toAddress!.username!)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
} else if historyListViewModel.callLogs[index].fromAddress != nil {
|
||||
Text(historyListViewModel.callLogs[index].fromAddress!.displayName != nil
|
||||
? historyListViewModel.callLogs[index].fromAddress!.displayName!
|
||||
: historyListViewModel.callLogs[index].fromAddress!.username!)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text(historyListViewModel.callLogsIsConference[index])
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
HStack {
|
||||
Image(historyListViewModel.getCallIconResId(callStatus: historyListViewModel.callLogs[index].status, callDir: historyListViewModel.callLogs[index].dir))
|
||||
.resizable()
|
||||
.frame(
|
||||
width: historyListViewModel.getCallIconResId(callStatus: historyListViewModel.callLogs[index].status, callDir: historyListViewModel.callLogs[index].dir).contains("rejected") ? 12 : 8,
|
||||
height: historyListViewModel.getCallIconResId(callStatus: historyListViewModel.callLogs[index].status, callDir: historyListViewModel.callLogs[index].dir).contains("rejected") ? 6 : 8)
|
||||
.resizable()
|
||||
.frame(
|
||||
width: historyListViewModel.getCallIconResId(callStatus: historyListViewModel.callLogs[index].status, callDir: historyListViewModel.callLogs[index].dir).contains("rejected") ? 12 : 8,
|
||||
height: historyListViewModel.getCallIconResId(callStatus: historyListViewModel.callLogs[index].status, callDir: historyListViewModel.callLogs[index].dir).contains("rejected") ? 6 : 8)
|
||||
|
||||
Text(historyListViewModel.getCallTime(startDate: historyListViewModel.callLogs[index].startDate))
|
||||
.default_text_style_300(styleSize: 12)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.default_text_style_300(styleSize: 12)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
|
@ -156,20 +176,22 @@ struct HistoryListFragment: View {
|
|||
Spacer()
|
||||
}
|
||||
|
||||
Image("phone")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.all, 10)
|
||||
.padding(.trailing, 5)
|
||||
.highPriorityGesture(
|
||||
TapGesture()
|
||||
.onEnded { _ in
|
||||
withAnimation {
|
||||
doCall(index: index)
|
||||
historyViewModel.displayedCall = nil
|
||||
if historyListViewModel.callLogsIsConference[index].isEmpty {
|
||||
Image("phone")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.all, 10)
|
||||
.padding(.trailing, 5)
|
||||
.highPriorityGesture(
|
||||
TapGesture()
|
||||
.onEnded { _ in
|
||||
withAnimation {
|
||||
doCall(index: index)
|
||||
historyViewModel.displayedCall = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
|
|
@ -179,6 +201,7 @@ struct HistoryListFragment: View {
|
|||
.onTapGesture {
|
||||
withAnimation {
|
||||
historyViewModel.displayedCall = historyListViewModel.callLogs[index]
|
||||
historyViewModel.getConferenceSubject()
|
||||
}
|
||||
}
|
||||
.onLongPressGesture(minimumDuration: 0.2) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class HistoryListViewModel: ObservableObject {
|
|||
private var coreContext = CoreContext.shared
|
||||
|
||||
@Published var callLogs: [CallLog] = []
|
||||
@Published var callLogsIsConference: [String] = []
|
||||
var callLogsTmp: [CallLog] = []
|
||||
|
||||
var callLogsAddressToDelete = ""
|
||||
|
|
@ -42,28 +43,46 @@ class HistoryListViewModel: ObservableObject {
|
|||
let account = core.defaultAccount
|
||||
let logs = account?.callLogs != nil ? account!.callLogs : core.callLogs
|
||||
|
||||
var callLogsBis: [CallLog] = []
|
||||
var callLogsIsConferenceBis: [String] = []
|
||||
var callLogsTmpBis: [CallLog] = []
|
||||
|
||||
logs.forEach { log in
|
||||
callLogsBis.append(log)
|
||||
callLogsIsConferenceBis.append(log.conferenceInfo != nil && log.conferenceInfo!.subject != nil ? log.conferenceInfo!.subject! : "")
|
||||
callLogsTmpBis.append(log)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.callLogs.removeAll()
|
||||
self.callLogsTmp.removeAll()
|
||||
|
||||
logs.forEach { log in
|
||||
self.callLogs.append(log)
|
||||
self.callLogsTmp.append(log)
|
||||
}
|
||||
self.callLogs = callLogsBis
|
||||
self.callLogsIsConference = callLogsIsConferenceBis
|
||||
self.callLogsTmp = callLogsTmpBis
|
||||
}
|
||||
|
||||
self.callLogSubscription = core.publisher?.onCallLogUpdated?.postOnCoreQueue { (_: (_: Core, _: CallLog)) in
|
||||
let account = core.defaultAccount
|
||||
let logs = account != nil ? account!.callLogs : core.callLogs
|
||||
let logs = account?.callLogs != nil ? account!.callLogs : core.callLogs
|
||||
|
||||
var callLogsBis: [CallLog] = []
|
||||
var callLogsIsConferenceBis: [String] = []
|
||||
var callLogsTmpBis: [CallLog] = []
|
||||
|
||||
logs.forEach { log in
|
||||
callLogsBis.append(log)
|
||||
callLogsIsConferenceBis.append(log.conferenceInfo != nil && log.conferenceInfo!.subject != nil ? log.conferenceInfo!.subject! : "")
|
||||
callLogsTmpBis.append(log)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.callLogs.removeAll()
|
||||
self.callLogsTmp.removeAll()
|
||||
|
||||
logs.forEach { log in
|
||||
self.callLogs.append(log)
|
||||
self.callLogsTmp.append(log)
|
||||
}
|
||||
self.callLogs = callLogsBis
|
||||
self.callLogsIsConference = callLogsIsConferenceBis
|
||||
self.callLogsTmp = callLogsTmpBis
|
||||
}
|
||||
|
||||
self.updateMissedCallsCount()
|
||||
|
|
|
|||
|
|
@ -23,8 +23,22 @@ import linphonesw
|
|||
class HistoryViewModel: ObservableObject {
|
||||
|
||||
@Published var displayedCall: CallLog?
|
||||
@Published var displayedCallIsConference: String = ""
|
||||
|
||||
var selectedCall: CallLog?
|
||||
|
||||
init() {}
|
||||
|
||||
func getConferenceSubject() {
|
||||
CoreContext.shared.doOnCoreQueue { core in
|
||||
var displayedCallIsConferenceTmp = ""
|
||||
if self.displayedCall?.conferenceInfo != nil {
|
||||
displayedCallIsConferenceTmp = self.displayedCall?.conferenceInfo?.subject ?? ""
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.displayedCallIsConference = displayedCallIsConferenceTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue