From 6dfc87062421db5ad147753435fd66ea3b0b3c00 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Mon, 22 Apr 2024 15:58:17 +0200 Subject: [PATCH] fix some padding, update meeting list to add the newly created conference when exiting scheduler menu --- Linphone/UI/Main/ContentView.swift | 1 + .../Fragments/AddParticipantsFragment.swift | 8 +- .../Fragments/ScheduleMeetingFragment.swift | 5 +- .../ViewModel/MeetingsListViewModel.swift | 115 +++++++++--------- 4 files changed, 69 insertions(+), 60 deletions(-) diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index 1d6ae4e8e..d82114e56 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -895,6 +895,7 @@ struct ContentView: View { if isShowScheduleMeetingFragment { ScheduleMeetingFragment( scheduleMeetingViewModel: scheduleMeetingViewModel, + meetingsListViewModel: meetingsListViewModel, isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment ) .zIndex(3) diff --git a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift index 96e2ecebd..53ed85a86 100644 --- a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift @@ -168,14 +168,14 @@ struct AddParticipantsFragment: View { ).first)!)) .contact_text_style_500(styleSize: 20) .frame(width: 18) - .padding(.leading, -5) - .padding(.trailing, 10) + .padding(.leading, 5) + .padding(.trailing, 5) } else { Text("") .contact_text_style_500(styleSize: 20) .frame(width: 18) - .padding(.leading, -5) - .padding(.trailing, 10) + .padding(.leading, 5) + .padding(.trailing, 5) } if index < contactsManager.avatarListModel.count diff --git a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift index 8beb2f117..833fed15c 100644 --- a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift @@ -29,6 +29,7 @@ struct ScheduleMeetingFragment: View { @State private var orientation = UIDevice.current.orientation @ObservedObject var scheduleMeetingViewModel: ScheduleMeetingViewModel + @ObservedObject var meetingsListViewModel: MeetingsListViewModel @State private var delayedColor = Color.white @State private var showDatePicker = false @@ -305,7 +306,7 @@ struct ScheduleMeetingFragment: View { VStack { HStack { Avatar(contactAvatarModel: scheduleMeetingViewModel.participants[index].avatarModel, avatarSize: 50) - .padding(.leading, 66) + .padding(.leading, 20) Text(scheduleMeetingViewModel.participants[index].avatarModel.name) .default_text_style(styleSize: 16) @@ -374,6 +375,7 @@ struct ScheduleMeetingFragment: View { }.onDisappear { withAnimation { if scheduleMeetingViewModel.conferenceCreatedEvent { + meetingsListViewModel.computeMeetingsList() isShowScheduleMeetingFragment.toggle() } } @@ -488,6 +490,7 @@ struct ScheduleMeetingFragment: View { #Preview { ScheduleMeetingFragment(scheduleMeetingViewModel: ScheduleMeetingViewModel() + , meetingsListViewModel: MeetingsListViewModel() , isShowScheduleMeetingFragment: .constant(true)) } diff --git a/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift b/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift index abd42d565..9e85634a6 100644 --- a/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift +++ b/Linphone/UI/Main/Meetings/ViewModel/MeetingsListViewModel.swift @@ -33,74 +33,79 @@ class MeetingsListViewModel: ObservableObject { init() { coreContext.doOnCoreQueue { core in - self.computeMeetingsList(core: core, filter: self.currentFilter) - self.mCoreSuscriptions.insert(core.publisher?.onConferenceInfoReceived?.postOnCoreQueue { (cbVal: (core: Core, conferenceInfo: ConferenceInfo)) in Log.info("\(MeetingsListViewModel.TAG) Conference info received [\(cbVal.conferenceInfo.uri?.asStringUriOnly())") - self.computeMeetingsList(core: cbVal.core, filter: self.currentFilter) + self.computeMeetingsList() }) } + computeMeetingsList() } - func computeMeetingsList(core: Core, filter: String) { - var confInfoList: [ConferenceInfo] = [] + func computeMeetingsList() { + let filter = self.currentFilter - if let account = core.defaultAccount { - confInfoList = account.conferenceInformationList - } - if confInfoList.isEmpty { - confInfoList = core.conferenceInformationList - } - - var meetingsListTmp: [MeetingsListItemModel] = [] - var previousModel: MeetingModel? - var meetingForTodayFound = false - - for confInfo in confInfoList { - if confInfo.duration == 0 { continue }// This isn't a scheduled conference, don't display it - var add = true - if !filter.isEmpty { - let organizerCheck = confInfo.organizer?.asStringUriOnly().range(of: filter, options: .caseInsensitive) != nil - let subjectCheck = confInfo.subject?.range(of: filter, options: .caseInsensitive) != nil - let descriptionCheck = confInfo.description?.range(of: filter, options: .caseInsensitive) != nil - let participantsCheck = confInfo.participantInfos.first(where: {$0.address?.asStringUriOnly().range(of: filter, options: .caseInsensitive) != nil}) != nil - - add = organizerCheck || subjectCheck || descriptionCheck || participantsCheck + coreContext.doOnCoreQueue { core in + var confInfoList: [ConferenceInfo] = [] + + if let account = core.defaultAccount { + confInfoList = account.conferenceInformationList + } + if confInfoList.isEmpty { + confInfoList = core.conferenceInformationList } - if add { - let model = MeetingModel(conferenceInfo: confInfo) - let firstMeetingOfTheDay = (previousModel != nil) ? previousModel?.day != model.day || previousModel?.dayNumber != model.dayNumber : true - model.firstMeetingOfTheDay = firstMeetingOfTheDay - - // Insert "Today" fake model before the first one of today - /* - if firstMeetingOfTheDay && model.isToday { - meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) - meetingForTodayFound = true + var meetingsListTmp: [MeetingsListItemModel] = [] + var previousModel: MeetingModel? + // var meetingForTodayFound = false + + for confInfo in confInfoList { + if confInfo.duration == 0 { continue }// This isn't a scheduled conference, don't display it + var add = true + if !filter.isEmpty { + let organizerCheck = confInfo.organizer?.asStringUriOnly().range(of: filter, options: .caseInsensitive) != nil + let subjectCheck = confInfo.subject?.range(of: filter, options: .caseInsensitive) != nil + let descriptionCheck = confInfo.description?.range(of: filter, options: .caseInsensitive) != nil + let participantsCheck = confInfo.participantInfos.first(where: {$0.address?.asStringUriOnly().range(of: filter, options: .caseInsensitive) != nil}) != nil + + add = organizerCheck || subjectCheck || descriptionCheck || participantsCheck } - */ - // If no meeting was found for today, insert "Today" fake model before the next meeting to come - /* - if !meetingForTodayFound && model.isAfterToday { - meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) - meetingForTodayFound = true + if add { + let model = MeetingModel(conferenceInfo: confInfo) + let firstMeetingOfTheDay = (previousModel != nil) ? previousModel?.day != model.day || previousModel?.dayNumber != model.dayNumber : true + model.firstMeetingOfTheDay = firstMeetingOfTheDay + + // Insert "Today" fake model before the first one of today + /* + if firstMeetingOfTheDay && model.isToday { + meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) + meetingForTodayFound = true + } + */ + + // If no meeting was found for today, insert "Today" fake model before the next meeting to come + /* + if !meetingForTodayFound && model.isAfterToday { + meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) + meetingForTodayFound = true + } + */ + + meetingsListTmp.append(MeetingsListItemModel(meetingModel: model)) + previousModel = model } - */ - - meetingsListTmp.append(MeetingsListItemModel(meetingModel: model)) - previousModel = model + } + + // If no meeting was found after today, insert "Today" fake model at the end + /* + if !meetingForTodayFound { + meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) + } + */ + + DispatchQueue.main.sync { + self.meetingsList = meetingsListTmp } } - - // If no meeting was found after today, insert "Today" fake model at the end - /* - if !meetingForTodayFound { - meetingsListTmp.append(MeetingsListItemModel(meetingModel: nil)) - } - */ - - self.meetingsList = meetingsListTmp } }