From f106f54021d03f0b5bce4015b0986cf3d17c0cf0 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Mon, 22 Apr 2024 13:48:42 +0200 Subject: [PATCH] Add a temporary meeting list --- Linphone/LinphoneApp.swift | 7 +- Linphone/Localizable.xcstrings | 6 +- Linphone/UI/Main/ContentView.swift | 3 + .../Fragments/HistoryListFragment.swift | 35 ++++++-- .../Meetings/Fragments/MeetingsFragment.swift | 86 ++++++++++++++----- Linphone/UI/Main/Meetings/MeetingsView.swift | 4 +- .../Main/Meetings/Models/MeetingModel.swift | 3 + .../ViewModel/MeetingsListViewModel.swift | 8 +- 8 files changed, 117 insertions(+), 35 deletions(-) diff --git a/Linphone/LinphoneApp.swift b/Linphone/LinphoneApp.swift index da5d206c1..fff6667d7 100644 --- a/Linphone/LinphoneApp.swift +++ b/Linphone/LinphoneApp.swift @@ -79,6 +79,7 @@ struct LinphoneApp: App { @State private var meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel? @State private var conversationsListViewModel: ConversationsListViewModel? @State private var conversationViewModel: ConversationViewModel? + @State private var meetingsListViewModel: MeetingsListViewModel? @State private var scheduleMeetingViewModel: ScheduleMeetingViewModel? var body: some Scene { @@ -103,7 +104,9 @@ struct LinphoneApp: App { && callViewModel != nil && meetingWaitingRoomViewModel != nil && conversationsListViewModel != nil - && conversationViewModel != nil { + && conversationViewModel != nil + && meetingsListViewModel != nil + && scheduleMeetingViewModel != nil { ContentView( contactViewModel: contactViewModel!, editContactViewModel: editContactViewModel!, @@ -114,6 +117,7 @@ struct LinphoneApp: App { meetingWaitingRoomViewModel: meetingWaitingRoomViewModel!, conversationsListViewModel: conversationsListViewModel!, conversationViewModel: conversationViewModel!, + meetingsListViewModel: meetingsListViewModel!, scheduleMeetingViewModel: scheduleMeetingViewModel! ) } else { @@ -131,6 +135,7 @@ struct LinphoneApp: App { meetingWaitingRoomViewModel = MeetingWaitingRoomViewModel() conversationsListViewModel = ConversationsListViewModel() conversationViewModel = ConversationViewModel() + meetingsListViewModel = MeetingsListViewModel() scheduleMeetingViewModel = ScheduleMeetingViewModel() } } diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 0fe4e9fd1..c9993f7f4 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -387,9 +387,6 @@ }, "Headphones" : { - }, - "Hello meetings list" : { - }, "History has been deleted" : { @@ -509,6 +506,9 @@ }, "No conversation for the moment..." : { + }, + "No meeting for the moment..." : { + }, "Not account yet?" : { diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index f22199412..1d6ae4e8e 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -43,6 +43,7 @@ struct ContentView: View { @ObservedObject var meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel @ObservedObject var conversationsListViewModel: ConversationsListViewModel @ObservedObject var conversationViewModel: ConversationViewModel + @ObservedObject var meetingsListViewModel: MeetingsListViewModel @ObservedObject var scheduleMeetingViewModel: ScheduleMeetingViewModel @State var index = 0 @@ -461,6 +462,7 @@ struct ContentView: View { ConversationsView(conversationViewModel: conversationViewModel, conversationsListViewModel: conversationsListViewModel) } else if self.index == 3 { MeetingsView( + meetingsListViewModel: meetingsListViewModel, scheduleMeetingViewModel: scheduleMeetingViewModel, isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment ) @@ -967,6 +969,7 @@ struct ContentView: View { meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel(), conversationsListViewModel: ConversationsListViewModel(), conversationViewModel: ConversationViewModel(), + meetingsListViewModel: MeetingsListViewModel(), scheduleMeetingViewModel: ScheduleMeetingViewModel() ) } diff --git a/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift index e8cc0b8c9..6a7f96220 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift @@ -72,17 +72,27 @@ struct HistoryListFragment: View { .frame(width: 45, height: 45) .clipShape(Circle()) - } else { + } else if historyListViewModel.callLogs[index].toAddress!.username != nil { Image(uiImage: contactsManager.textToImage( - firstName: historyListViewModel.callLogs[index].toAddress!.username ?? "Username Error", + firstName: historyListViewModel.callLogs[index].toAddress!.username!, 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 { + 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()) } - } else if historyListViewModel.callLogs[index].fromAddress != nil { if historyListViewModel.callLogs[index].fromAddress!.displayName != nil { Image(uiImage: contactsManager.textToImage( @@ -93,15 +103,26 @@ struct HistoryListFragment: View { .resizable() .frame(width: 45, height: 45) .clipShape(Circle()) - } else { + } else if historyListViewModel.callLogs[index].fromAddress!.username != nil { Image(uiImage: contactsManager.textToImage( - firstName: historyListViewModel.callLogs[index].fromAddress!.username ?? "Username Error", + firstName: historyListViewModel.callLogs[index].fromAddress!.username!, 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 { + 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()) } } else { Image("profil-picture-default") @@ -139,14 +160,14 @@ struct HistoryListFragment: View { 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!) + : 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!) + : historyListViewModel.callLogs[index].fromAddress!.username ?? "") .default_text_style(styleSize: 14) .frame(maxWidth: .infinity, alignment: .leading) .lineLimit(1) diff --git a/Linphone/UI/Main/Meetings/Fragments/MeetingsFragment.swift b/Linphone/UI/Main/Meetings/Fragments/MeetingsFragment.swift index 63e4d7f57..b6cf7193c 100644 --- a/Linphone/UI/Main/Meetings/Fragments/MeetingsFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/MeetingsFragment.swift @@ -6,9 +6,11 @@ // import SwiftUI +import linphonesw struct MeetingsFragment: View { + @ObservedObject var meetingsListViewModel: MeetingsListViewModel @ObservedObject var scheduleMeetingViewModel: ScheduleMeetingViewModel private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } @@ -17,32 +19,72 @@ struct MeetingsFragment: View { var body: some View { VStack { - Spacer() - Text("Hello meetings list") - Spacer() - /* - if #available(iOS 16.0, *), idiom != .pad { - MeetingsListFragment(conversationViewModel: conversationViewModel, conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet) - .sheet(isPresented: $showingSheet) { - ConversationsListBottomSheet( - conversationsListViewModel: conversationsListViewModel, - showingSheet: $showingSheet - ) - .presentationDetents([.fraction(0.4)]) + List { + ForEach(0..