diff --git a/Linphone.xcodeproj/project.pbxproj b/Linphone.xcodeproj/project.pbxproj index a472253e4..1d119567a 100644 --- a/Linphone.xcodeproj/project.pbxproj +++ b/Linphone.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 6613A0B02BAEB7F4008923A4 /* MeetingsListFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A0AF2BAEB7F4008923A4 /* MeetingsListFragment.swift */; }; 6613A0B42BAEBE3F008923A4 /* MeetingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A0B32BAEBE3F008923A4 /* MeetingViewModel.swift */; }; 6613A0B62BAEBE5C008923A4 /* ScheduleMeetingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6613A0B52BAEBE5C008923A4 /* ScheduleMeetingViewModel.swift */; }; + 66162A202BDFC2F900DCE913 /* AddParticipantsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66162A1F2BDFC2F900DCE913 /* AddParticipantsViewModel.swift */; }; 662B69D92B25DE18007118BF /* TelecomManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662B69D82B25DE18007118BF /* TelecomManager.swift */; }; 662B69DB2B25DE25007118BF /* ProviderDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662B69DA2B25DE25007118BF /* ProviderDelegate.swift */; }; 6646A7A32BB2E224006B842A /* ScheduleMeetingFragment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6646A7A22BB2E224006B842A /* ScheduleMeetingFragment.swift */; }; @@ -167,6 +168,7 @@ 6613A0AF2BAEB7F4008923A4 /* MeetingsListFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingsListFragment.swift; sourceTree = ""; }; 6613A0B32BAEBE3F008923A4 /* MeetingViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeetingViewModel.swift; sourceTree = ""; }; 6613A0B52BAEBE5C008923A4 /* ScheduleMeetingViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleMeetingViewModel.swift; sourceTree = ""; }; + 66162A1F2BDFC2F900DCE913 /* AddParticipantsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddParticipantsViewModel.swift; sourceTree = ""; }; 662B69D82B25DE18007118BF /* TelecomManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelecomManager.swift; sourceTree = ""; }; 662B69DA2B25DE25007118BF /* ProviderDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderDelegate.swift; sourceTree = ""; }; 6646A7A22BB2E224006B842A /* ScheduleMeetingFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleMeetingFragment.swift; sourceTree = ""; }; @@ -658,6 +660,7 @@ D7A2EDD42AC180FE005D90FC /* Viewmodel */ = { isa = PBXGroup; children = ( + 66162A1F2BDFC2F900DCE913 /* AddParticipantsViewModel.swift */, D7A2EDD52AC18115005D90FC /* SharedMainViewModel.swift */, D796F1FF2B0BB61A0041115F /* ToastViewModel.swift */, ); @@ -980,6 +983,7 @@ D734499B2BC694C900778C56 /* MeetingWaitingRoomViewModel.swift in Sources */, D719ABB72ABC67BF00B41C10 /* LinphoneApp.swift in Sources */, 66E50A4B2BD12B7800AD61CA /* MeetingsFragment.swift in Sources */, + 66162A202BDFC2F900DCE913 /* AddParticipantsViewModel.swift in Sources */, D732A91B2B061BD900DB42BA /* HistoryListBottomSheet.swift in Sources */, D72250632ADE9615008FB426 /* HistoryViewModel.swift in Sources */, 66E56BC92BA4A6D7006CE56F /* MeetingsListViewModel.swift in Sources */, @@ -1252,7 +1256,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = Linphone/Linphone.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 10; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = "\"Linphone/Preview Content\""; diff --git a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift index 53ed85a86..557f39be4 100644 --- a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift @@ -18,7 +18,8 @@ struct AddParticipantsFragment: View { @ObservedObject var contactsManager = ContactsManager.shared @ObservedObject var magicSearch = MagicSearchSingleton.shared - @ObservedObject var scheduleMeetingViewModel: ScheduleMeetingViewModel + @ObservedObject var addParticipantsViewModel: AddParticipantsViewModel + var confirmAddParticipantsFunc: ([SelectedAddressModel]) -> Void @State private var delayedColor = Color.white @FocusState var isSearchFieldFocused: Bool @@ -50,7 +51,7 @@ struct AddParticipantsFragment: View { .padding(.top, 2) .padding(.leading, -10) .onTapGesture { - scheduleMeetingViewModel.participantsToAdd = [] + addParticipantsViewModel.reset() dismiss() } @@ -59,7 +60,7 @@ struct AddParticipantsFragment: View { .multilineTextAlignment(.leading) .default_text_style_orange_800(styleSize: 16) .padding(.top, 20) - Text("\($scheduleMeetingViewModel.participants.count) selected participants") + Text("\($addParticipantsViewModel.participantsToAdd.count) selected participants") .default_text_style_300(styleSize: 12) } Spacer() @@ -72,12 +73,12 @@ struct AddParticipantsFragment: View { ScrollView(.horizontal) { HStack { - ForEach(0..() var conferenceInfoToEdit: ConferenceInfo? @@ -75,11 +62,9 @@ class ScheduleMeetingViewModel: ObservableObject { allDayMeeting = false timezone = "" sendInvitations = true - participantsToAdd = [] participants = [] operationInProgress = false conferenceCreatedEvent = false - searchField = "" fromDate = Calendar.current.date(byAdding: .hour, value: 1, to: Date.now)! toDate = Calendar.current.date(byAdding: .hour, value: 2, to: Date.now)! @@ -113,14 +98,7 @@ class ScheduleMeetingViewModel: ObservableObject { // TODO } - func selectParticipant(addr: Address) { - if let idx = participantsToAdd.firstIndex(where: {$0.address.weakEqual(address2: addr)}) { - participantsToAdd.remove(at: idx) - } else { - participantsToAdd.append(SelectedAddressModel(addr: addr, avModel: ContactAvatarModel.getAvatarModelFromAddress(address: addr))) - } - } - func addParticipants() { + func addParticipants(participantsToAdd: [SelectedAddressModel]) { var list = participants for selectedAddr in participantsToAdd { if let found = list.first(where: { $0.address.weakEqual(address2: selectedAddr.address) }) { @@ -134,7 +112,6 @@ class ScheduleMeetingViewModel: ObservableObject { Log.info("\(ScheduleMeetingViewModel.TAG) [\(list.count - participants.count) participants added, now there are \(list.count) participants in list") participants = list - participantsToAdd = [] } private func fillConferenceInfo(confInfo: ConferenceInfo) { diff --git a/Linphone/UI/Main/Viewmodel/AddParticipantsViewModel.swift b/Linphone/UI/Main/Viewmodel/AddParticipantsViewModel.swift new file mode 100644 index 000000000..d8140d3a7 --- /dev/null +++ b/Linphone/UI/Main/Viewmodel/AddParticipantsViewModel.swift @@ -0,0 +1,42 @@ +// +// AddParticipantsViewModel.swift +// Linphone +// +// Created by QuentinArguillere on 29/04/2024. +// + +import Foundation +import linphonesw +import Combine + +class SelectedAddressModel: ObservableObject { + var address: Address + var avatarModel: ContactAvatarModel + + init (addr: Address, avModel: ContactAvatarModel) { + address = addr + avatarModel = avModel + } +} + +class AddParticipantsViewModel: ObservableObject { + static let TAG = "[AddParticipantsViewModel]" + + @Published var participantsToAdd: [SelectedAddressModel] = [] + @Published var searchField: String = "" + + func selectParticipant(addr: Address) { + if let idx = participantsToAdd.firstIndex(where: {$0.address.weakEqual(address2: addr)}) { + Log.info("[\(AddParticipantsViewModel.TAG)] Removing participant \(addr.asStringUriOnly()) from selection") + participantsToAdd.remove(at: idx) + } else { + Log.info("[\(AddParticipantsViewModel.TAG)] Adding participant \(addr.asStringUriOnly()) to selection") + participantsToAdd.append(SelectedAddressModel(addr: addr, avModel: ContactAvatarModel.getAvatarModelFromAddress(address: addr))) + } + } + + func reset() { + participantsToAdd = [] + searchField = "" + } +}