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 |
|
|
@ -17,11 +17,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// swiftlint:disable line_length
|
||||
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
import linphonesw
|
||||
|
||||
// swiftlint:disable line_length
|
||||
// swiftlint:disable type_body_length
|
||||
struct HistoryContactFragment: View {
|
||||
|
||||
@State private var orientation = UIDevice.current.orientation
|
||||
|
|
@ -44,6 +45,7 @@ struct HistoryContactFragment: View {
|
|||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
if historyViewModel.displayedCall != nil {
|
||||
VStack(spacing: 1) {
|
||||
Rectangle()
|
||||
.foregroundColor(Color.orangeMain500)
|
||||
|
|
@ -78,6 +80,7 @@ struct HistoryContactFragment: View {
|
|||
let toAddressFriend = historyViewModel.displayedCall != nil ? contactsManager.getFriendWithAddress(address: historyViewModel.displayedCall!.toAddress!) : nil
|
||||
let addressFriend = historyViewModel.displayedCall != nil ? (historyViewModel.displayedCall!.dir == .Incoming ? fromAddressFriend : toAddressFriend) : nil
|
||||
|
||||
if historyViewModel.displayedCallIsConference.isEmpty {
|
||||
Button {
|
||||
isMenuOpen = false
|
||||
|
||||
|
|
@ -127,6 +130,7 @@ struct HistoryContactFragment: View {
|
|||
.padding(.all, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
isMenuOpen = false
|
||||
|
|
@ -206,6 +210,7 @@ struct HistoryContactFragment: View {
|
|||
.frame(height: 7)
|
||||
}
|
||||
VStack(spacing: 0) {
|
||||
if historyViewModel.displayedCallIsConference.isEmpty {
|
||||
let fromAddressFriend = historyViewModel.displayedCall != nil ? contactsManager.getFriendWithAddress(address: historyViewModel.displayedCall!.fromAddress!) : nil
|
||||
let toAddressFriend = historyViewModel.displayedCall != nil ? contactsManager.getFriendWithAddress(address: historyViewModel.displayedCall!.toAddress!) : nil
|
||||
let addressFriend = historyViewModel.displayedCall != nil ? (historyViewModel.displayedCall!.dir == .Incoming ? fromAddressFriend : toAddressFriend) : nil
|
||||
|
|
@ -339,6 +344,7 @@ struct HistoryContactFragment: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if historyViewModel.displayedCall != nil
|
||||
&& addressFriend != nil
|
||||
&& addressFriend!.name != nil {
|
||||
|
|
@ -375,6 +381,25 @@ struct HistoryContactFragment: View {
|
|||
.frame(height: 20)
|
||||
.padding(.top, 5)
|
||||
}
|
||||
} else {
|
||||
VStack {
|
||||
Image("users-three-square")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.frame(width: 60, height: 60)
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
}
|
||||
.frame(width: 100, height: 100)
|
||||
.background(Color.grayMain2c200)
|
||||
.clipShape(Circle())
|
||||
|
||||
Text(historyViewModel.displayedCallIsConference ?? "")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 10)
|
||||
}
|
||||
}
|
||||
.frame(minHeight: 150)
|
||||
.frame(maxWidth: .infinity)
|
||||
|
|
@ -385,6 +410,7 @@ struct HistoryContactFragment: View {
|
|||
HStack {
|
||||
Spacer()
|
||||
|
||||
if historyViewModel.displayedCallIsConference.isEmpty {
|
||||
Button(action: {
|
||||
if historyViewModel.displayedCall!.dir == .Outgoing && historyViewModel.displayedCall!.toAddress != nil {
|
||||
telecomManager.doCallWithCore(
|
||||
|
|
@ -473,6 +499,56 @@ struct HistoryContactFragment: View {
|
|||
.frame(minWidth: 80)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Button(action: {
|
||||
withAnimation {
|
||||
if historyViewModel.displayedCall!.dir == .Outgoing && historyViewModel.displayedCall!.toAddress != nil {
|
||||
if historyViewModel.displayedCall!.toAddress!.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") {
|
||||
do {
|
||||
let meetingAddress = try Factory.Instance.createAddress(addr: historyViewModel.displayedCall!.toAddress!.asStringUriOnly())
|
||||
|
||||
telecomManager.meetingWaitingRoomDisplayed = true
|
||||
telecomManager.meetingWaitingRoomSelected = meetingAddress
|
||||
} catch {}
|
||||
} else {
|
||||
telecomManager.doCallWithCore(
|
||||
addr: historyViewModel.displayedCall!.toAddress!, isVideo: false, isConference: false
|
||||
)
|
||||
}
|
||||
} else if historyViewModel.displayedCall!.fromAddress != nil {
|
||||
if historyViewModel.displayedCall!.fromAddress!.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") {
|
||||
do {
|
||||
let meetingAddress = try Factory.Instance.createAddress(addr: historyViewModel.displayedCall!.fromAddress!.asStringUriOnly())
|
||||
|
||||
telecomManager.meetingWaitingRoomDisplayed = true
|
||||
telecomManager.meetingWaitingRoomSelected = meetingAddress
|
||||
} catch {}
|
||||
} else {
|
||||
telecomManager.doCallWithCore(
|
||||
addr: historyViewModel.displayedCall!.fromAddress!, isVideo: false, isConference: false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, label: {
|
||||
VStack {
|
||||
HStack(alignment: .center) {
|
||||
Image("users-three-square")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
}
|
||||
.padding(16)
|
||||
.background(Color.grayMain2c200)
|
||||
.cornerRadius(40)
|
||||
|
||||
Text("Rejoindre")
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(minWidth: 80)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
|
@ -557,6 +633,7 @@ struct HistoryContactFragment: View {
|
|||
orientation = newOrientation
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationViewStyle(.stack)
|
||||
}
|
||||
}
|
||||
|
|
@ -573,5 +650,5 @@ struct HistoryContactFragment: View {
|
|||
indexPage: .constant(1)
|
||||
)
|
||||
}
|
||||
|
||||
// swiftlint:enable line_length
|
||||
// swiftlint:enable type_body_length
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ struct HistoryListFragment: View {
|
|||
ForEach(0..<historyListViewModel.callLogs.count, id: \.self) { index in
|
||||
HStack {
|
||||
HStack {
|
||||
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
|
||||
|
|
@ -109,10 +110,22 @@ struct HistoryListFragment: View {
|
|||
.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
|
||||
|
|
@ -139,6 +152,13 @@ struct HistoryListFragment: View {
|
|||
.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()
|
||||
|
|
@ -156,6 +176,7 @@ struct HistoryListFragment: View {
|
|||
Spacer()
|
||||
}
|
||||
|
||||
if historyListViewModel.callLogsIsConference[index].isEmpty {
|
||||
Image("phone")
|
||||
.resizable()
|
||||
.frame(width: 25, height: 25)
|
||||
|
|
@ -172,6 +193,7 @@ struct HistoryListFragment: View {
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.listRowInsets(EdgeInsets(top: 5, leading: 20, bottom: 5, trailing: 20))
|
||||
.listRowSeparator(.hidden)
|
||||
|
|
@ -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