diff --git a/Linphone/UI/Assistant/AssistantView.swift b/Linphone/UI/Assistant/AssistantView.swift index 8ab5aaabb..b55cdc018 100644 --- a/Linphone/UI/Assistant/AssistantView.swift +++ b/Linphone/UI/Assistant/AssistantView.swift @@ -27,11 +27,11 @@ struct AssistantView: View { if SharedMainViewModel.shared.displayProfileMode && coreContext.loggedIn { ProfileModeFragment() } else { - LoginFragment(accountLoginViewModel: AccountLoginViewModel()) + LoginFragment() } } } #Preview { - LoginFragment(accountLoginViewModel: AccountLoginViewModel()) + LoginFragment() } diff --git a/Linphone/UI/Assistant/Fragments/LoginFragment.swift b/Linphone/UI/Assistant/Fragments/LoginFragment.swift index fe44afad8..a1f48084a 100644 --- a/Linphone/UI/Assistant/Fragments/LoginFragment.swift +++ b/Linphone/UI/Assistant/Fragments/LoginFragment.swift @@ -22,7 +22,8 @@ import SwiftUI struct LoginFragment: View { @ObservedObject private var coreContext = CoreContext.shared - @ObservedObject var accountLoginViewModel: AccountLoginViewModel + + @StateObject private var accountLoginViewModel = AccountLoginViewModel() @State private var isSecured: Bool = true @@ -365,5 +366,5 @@ struct LoginFragment: View { } #Preview { - LoginFragment(accountLoginViewModel: AccountLoginViewModel()) + LoginFragment() } diff --git a/Linphone/UI/Call/MeetingWaitingRoomFragment.swift b/Linphone/UI/Call/MeetingWaitingRoomFragment.swift index 3615c8bbb..a8cd1482a 100644 --- a/Linphone/UI/Call/MeetingWaitingRoomFragment.swift +++ b/Linphone/UI/Call/MeetingWaitingRoomFragment.swift @@ -29,7 +29,7 @@ struct MeetingWaitingRoomFragment: View { @ObservedObject private var coreContext = CoreContext.shared @ObservedObject private var telecomManager = TelecomManager.shared - @ObservedObject var meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel + @StateObject private var meetingWaitingRoomViewModel = MeetingWaitingRoomViewModel() private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } @State private var orientation = UIDevice.current.orientation @@ -572,7 +572,7 @@ struct MeetingWaitingRoomFragment: View { } #Preview { - MeetingWaitingRoomFragment(meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel()) + MeetingWaitingRoomFragment() } // swiftlint:enable type_body_length // swiftlint:enable cyclomatic_complexity diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index a83271c93..c74a8fb17 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -40,12 +40,8 @@ struct ContentView: View { @State private var contactsListViewModel: ContactsListViewModel? @State private var historyListViewModel: HistoryListViewModel? @State private var conversationsListViewModel: ConversationsListViewModel? - @State private var meetingsListViewModel: MeetingsListViewModel? + @State private var meetingsListViewModel: MeetingsListViewModel? - //@ObservedObject var meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel - - - //@Binding var index: Int @State private var orientation = UIDevice.current.orientation @State var sideMenuIsOpen: Bool = false @@ -74,12 +70,18 @@ struct ContentView: View { @State var fullscreenVideo = false @State var isShowScheduleMeetingFragment = false + @State var isShowScheduleMeetingFragmentSubject = "" + @State var isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel] = [] + @State private var isShowLoginFragment: Bool = false private let avatarSize = 45.0 @State private var imagePath: URL? @State private var imageTmp: Image? + @State var isShowConversationInfoPopup: Bool = false + @State var conversationInfoPopupText: String = "" + var body: some View { let contactLoaded = NotificationCenter.default .publisher(for: NSNotification.Name("ContactLoaded")) @@ -511,8 +513,8 @@ struct ContentView: View { } else if let conversationsListVM = conversationsListViewModel, sharedMainViewModel.indexView == 2 { conversationsListVM.resetFilterConversations() } else if let meetingsListVM = meetingsListViewModel, sharedMainViewModel.indexView == 3 { - meetingsListVM.currentFilter = "" - meetingsListVM.computeMeetingsList() + meetingsListVM.currentFilter = "" + meetingsListVM.computeMeetingsList() } } label: { Image("caret-left") @@ -565,8 +567,8 @@ struct ContentView: View { conversationsListVM.filterConversations(filter: text) } } else if let meetingsListVM = meetingsListViewModel, sharedMainViewModel.indexView == 3 { - meetingsListVM.currentFilter = text - meetingsListVM.computeMeetingsList() + meetingsListVM.currentFilter = text + meetingsListVM.computeMeetingsList() } } } else { @@ -600,8 +602,8 @@ struct ContentView: View { } else if let conversationsListVM = conversationsListViewModel, sharedMainViewModel.indexView == 2 { conversationsListVM.filterConversations(filter: text) } else if let meetingsListVM = meetingsListViewModel, sharedMainViewModel.indexView == 3 { - meetingsListVM.currentFilter = text - meetingsListVM.computeMeetingsList() + meetingsListVM.currentFilter = text + meetingsListVM.computeMeetingsList() } } } @@ -723,38 +725,38 @@ struct ContentView: View { } } } else if sharedMainViewModel.indexView == 3 { - if let meetingsListVM = meetingsListViewModel { - MeetingsView( - isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment, - isShowSendCancelMeetingNotificationPopup: $isShowSendCancelMeetingNotificationPopup, - text: $text - ) - .environmentObject(meetingsListVM) - .roundedCorner(25, corners: [.topRight, .topLeft]) - .shadow( - color: (orientation == .landscapeLeft - || orientation == .landscapeRight - || UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height) - ? .white.opacity(0.0) - : .black.opacity(0.2), - radius: 25 - ) - } else { - NavigationView { - VStack { - Spacer() - - ProgressView() - .controlSize(.large) - - Spacer() - } - .onAppear { - meetingsListViewModel = MeetingsListViewModel() - } - } - } - } + if let meetingsListVM = meetingsListViewModel { + MeetingsView( + isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment, + isShowSendCancelMeetingNotificationPopup: $isShowSendCancelMeetingNotificationPopup, + text: $text + ) + .environmentObject(meetingsListVM) + .roundedCorner(25, corners: [.topRight, .topLeft]) + .shadow( + color: (orientation == .landscapeLeft + || orientation == .landscapeRight + || UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height) + ? .white.opacity(0.0) + : .black.opacity(0.2), + radius: 25 + ) + } else { + NavigationView { + VStack { + Spacer() + + ProgressView() + .controlSize(.large) + + Spacer() + } + .onAppear { + meetingsListViewModel = MeetingsListViewModel() + } + } + } + } } } } @@ -986,16 +988,20 @@ struct ContentView: View { isShowStartCallGroupPopup: $isShowStartCallGroupPopup, isShowEditContactFragment: $isShowEditContactFragment, isShowEditContactFragmentAddress: $isShowEditContactFragmentAddress, - isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment + isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment, + isShowScheduleMeetingFragmentSubject: $isShowScheduleMeetingFragmentSubject, + isShowScheduleMeetingFragmentParticipants: $isShowScheduleMeetingFragmentParticipants, + isShowConversationInfoPopup: $isShowConversationInfoPopup, + conversationInfoPopupText: $conversationInfoPopupText ) - .environmentObject(conversationsListVM) + .environmentObject(conversationsListVM) .environmentObject(accountProfileViewModel) .frame(maxWidth: .infinity) .background(Color.gray100) .ignoresSafeArea(.keyboard) } else if let meetingsListVM = meetingsListViewModel, let displayedMeeting = sharedMainViewModel.displayedMeeting, sharedMainViewModel.indexView == 3 { MeetingFragment(isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment, isShowSendCancelMeetingNotificationPopup: $isShowSendCancelMeetingNotificationPopup) - .environmentObject(meetingsListVM) + .environmentObject(meetingsListVM) .frame(maxWidth: .infinity) .background(Color.gray100) .ignoresSafeArea(.keyboard) @@ -1040,10 +1046,8 @@ struct ContentView: View { .ignoresSafeArea(.all) .zIndex(2) - /* if isShowLoginFragment { LoginFragment( - accountLoginViewModel: AccountLoginViewModel(), isShowBack: true, onBackPressed: { withAnimation { @@ -1055,7 +1059,6 @@ struct ContentView: View { .onAppear { } } - */ if isShowEditContactFragment { EditContactFragment( @@ -1240,11 +1243,17 @@ struct ContentView: View { if let meetingsListVM = meetingsListViewModel, isShowScheduleMeetingFragment { ScheduleMeetingFragment( + isShowScheduleMeetingFragmentSubject: isShowScheduleMeetingFragmentSubject, + isShowScheduleMeetingFragmentParticipants: isShowScheduleMeetingFragmentParticipants, isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment ) .environmentObject(meetingsListVM) .zIndex(3) .transition(.move(edge: .bottom)) + .onAppear { + isShowScheduleMeetingFragmentSubject = "" + isShowScheduleMeetingFragmentParticipants = [] + } } if isShowAccountProfileFragment { @@ -1256,10 +1265,8 @@ struct ContentView: View { .transition(.move(edge: .trailing)) } - /* if isShowSettingsFragment { SettingsFragment( - settingsViewModel: SettingsViewModel(), isShowSettingsFragment: $isShowSettingsFragment ) .zIndex(3) @@ -1268,13 +1275,11 @@ struct ContentView: View { if isShowHelpFragment { HelpFragment( - helpViewModel: HelpViewModel(), isShowHelpFragment: $isShowHelpFragment ) .zIndex(3) .transition(.move(edge: .trailing)) } - */ if let meetingsListVM = meetingsListViewModel, isShowSendCancelMeetingNotificationPopup { PopupView(isShowPopup: $isShowSendCancelMeetingNotificationPopup, @@ -1323,25 +1328,23 @@ struct ContentView: View { } } - /* - if conversationViewModel.isShowConversationInfoPopup { - PopupViewWithTextField(conversationViewModel: conversationViewModel) - .background(.black.opacity(0.65)) - .zIndex(3) - .onTapGesture { - conversationViewModel.isShowConversationInfoPopup = false - } + if isShowConversationInfoPopup { + PopupViewWithTextField( + isShowConversationInfoPopup: $isShowConversationInfoPopup, + conversationInfoPopupText: $conversationInfoPopupText + ) + .background(.black.opacity(0.65)) + .zIndex(3) + .onTapGesture { + self.isShowConversationInfoPopup.toggle() + } } if telecomManager.meetingWaitingRoomDisplayed { - MeetingWaitingRoomFragment(meetingWaitingRoomViewModel: meetingWaitingRoomViewModel) + MeetingWaitingRoomFragment() .zIndex(3) .transition(.opacity.combined(with: .move(edge: .bottom))) - .onAppear { - meetingWaitingRoomViewModel.resetMeetingRoomView() - } } - */ if telecomManager.callDisplayed && ((telecomManager.callInProgress && telecomManager.outgoingCallStarted) || telecomManager.callConnected) && !telecomManager.meetingWaitingRoomDisplayed { CallView( @@ -1444,13 +1447,7 @@ class NavigationManager: ObservableObject { } #Preview { - ContentView( - //meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel(), - //meetingsListViewModel: MeetingsListViewModel(), - //meetingViewModel: MeetingViewModel(), - //conversationForwardMessageViewModel: ConversationForwardMessageViewModel(), - //accountProfileViewModel: AccountProfileViewModel(), - ) + ContentView() } // swiftlint:enable type_body_length // swiftlint:enable line_length diff --git a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift index a91c22040..dd554200b 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift @@ -295,7 +295,7 @@ struct ChatBubbleView: View { .frame(maxWidth: .infinity) .background(.white) } - .frame(width: geometryProxy.size.width - 110) + .frame(width: geometryProxy.size.width >= 110 ? geometryProxy.size.width - 110 : geometryProxy.size.width) .background(.white) .cornerRadius(10) } diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift index 283da640b..26dc09826 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift @@ -73,6 +73,12 @@ struct ConversationFragment: View { @State private var cachedConversation: ConversationModel? + @Binding var isShowScheduleMeetingFragmentSubject: String + @Binding var isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel] + + @Binding var isShowConversationInfoPopup: Bool + @Binding var conversationInfoPopupText: String + var body: some View { NavigationView { GeometryReader { geometry in @@ -1092,7 +1098,11 @@ struct ConversationFragment: View { isShowInfoConversationFragment: $isShowInfoConversationFragment, isShowEditContactFragment: $isShowEditContactFragment, isShowEditContactFragmentAddress: $isShowEditContactFragmentAddress, - isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment + isShowScheduleMeetingFragment: $isShowScheduleMeetingFragment, + isShowScheduleMeetingFragmentSubject: $isShowScheduleMeetingFragmentSubject, + isShowScheduleMeetingFragmentParticipants: $isShowScheduleMeetingFragmentParticipants, + isShowConversationInfoPopup: $isShowConversationInfoPopup, + conversationInfoPopupText: $conversationInfoPopupText ) .environmentObject(conversationViewModel) .zIndex(5) diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift index c93dc4a20..81cfe1df8 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift @@ -40,8 +40,14 @@ struct ConversationInfoFragment: View { @Binding var isShowScheduleMeetingFragment: Bool + @Binding var isShowScheduleMeetingFragmentSubject: String + @Binding var isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel] + @State private var participantListIsOpen = true + @Binding var isShowConversationInfoPopup: Bool + @Binding var conversationInfoPopupText: String + var body: some View { let accountModel = CoreContext.shared.accounts[accountProfileViewModel.accountModelIndex ?? 0] NavigationView { @@ -136,7 +142,7 @@ struct ConversationInfoFragment: View { if conversationViewModel.isUserAdmin { Button( action: { - conversationViewModel.isShowConversationInfoPopup = true + isShowConversationInfoPopup = true }, label: { Image("pencil-simple") @@ -218,11 +224,12 @@ struct ConversationInfoFragment: View { Spacer() Button(action: { - if SharedMainViewModel.shared.displayedConversation != nil { - /* - meetingViewModel.subject = SharedMainViewModel.shared.displayedConversation!.subject - meetingViewModel.participants = conversationViewModel.participants - */ + if let displayedConversation = SharedMainViewModel.shared.displayedConversation { + if displayedConversation.isGroup { + isShowScheduleMeetingFragmentSubject = displayedConversation.subject + } + isShowScheduleMeetingFragmentParticipants = conversationViewModel.participants + SharedMainViewModel.shared.displayedConversation = nil SharedMainViewModel.shared.changeIndexView(indexViewInt: 3) withAnimation { @@ -696,7 +703,11 @@ struct ConversationInfoFragment: View { isShowInfoConversationFragment: .constant(true), isShowEditContactFragment: .constant(false), isShowEditContactFragmentAddress: .constant(""), - isShowScheduleMeetingFragment: .constant(false) + isShowScheduleMeetingFragment: .constant(false), + isShowScheduleMeetingFragmentSubject: .constant(""), + isShowScheduleMeetingFragmentParticipants: .constant([]), + isShowConversationInfoPopup: .constant(false), + conversationInfoPopupText: .constant("") ) } // swiftlint:enable type_body_length diff --git a/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift b/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift index 78966df9a..67034a1a2 100644 --- a/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift +++ b/Linphone/UI/Main/Conversations/ViewModel/ConversationViewModel.swift @@ -43,9 +43,6 @@ class ConversationViewModel: ObservableObject { @Published var isEphemeral: Bool = false @Published var ephemeralTime: String = NSLocalizedString("conversation_ephemeral_messages_duration_disabled", comment: "") - @Published var isShowConversationInfoPopup: Bool = false - @Published var conversationInfoPopupText: String = "" - // Used to keep track of a ChatRoom callback without having to worry about life cycle // Init will add the delegate, deinit will remove it class ChatRoomDelegateHolder { @@ -551,8 +548,6 @@ class ConversationViewModel: ObservableObject { self.mediasToSend.removeAll() self.messageToReply = nil - self.conversationInfoPopupText = self.sharedMainViewModel.displayedConversation?.subject ?? "" - self.attachments.removeAll() coreContext.doOnCoreQueue { _ in @@ -2591,24 +2586,6 @@ class ConversationViewModel: ObservableObject { } } - func setNewChatRoomSubject() { - if self.sharedMainViewModel.displayedConversation != nil && self.conversationInfoPopupText != self.sharedMainViewModel.displayedConversation!.subject { - - coreContext.doOnCoreQueue { _ in - self.sharedMainViewModel.displayedConversation!.chatRoom.subject = self.conversationInfoPopupText - } - - self.sharedMainViewModel.displayedConversation!.subject = self.conversationInfoPopupText - self.sharedMainViewModel.displayedConversation!.avatarModel = ContactAvatarModel( - friend: self.sharedMainViewModel.displayedConversation!.avatarModel.friend, - name: self.conversationInfoPopupText, - address: self.sharedMainViewModel.displayedConversation!.avatarModel.address, - withPresence: false - ) - self.isShowConversationInfoPopup = false - } - } - func getParticipants() { self.participants = [] var list: [SelectedAddressModel] = [] diff --git a/Linphone/UI/Main/Fragments/PopupViewWithTextField.swift b/Linphone/UI/Main/Fragments/PopupViewWithTextField.swift index 36c5beb1d..6311c3b05 100644 --- a/Linphone/UI/Main/Fragments/PopupViewWithTextField.swift +++ b/Linphone/UI/Main/Fragments/PopupViewWithTextField.swift @@ -9,7 +9,10 @@ import SwiftUI struct PopupViewWithTextField: View { - @EnvironmentObject var conversationViewModel: ConversationViewModel + @ObservedObject var sharedMainViewModel = SharedMainViewModel.shared + + @Binding var isShowConversationInfoPopup: Bool + @Binding var conversationInfoPopupText: String @FocusState var isMessageTextFocused: Bool @@ -21,7 +24,7 @@ struct PopupViewWithTextField: View { .frame(alignment: .leading) .padding(.bottom, 2) - TextField("conversation_dialog_subject_hint", text: $conversationViewModel.conversationInfoPopupText) + TextField("conversation_dialog_subject_hint", text: $conversationInfoPopupText) .default_text_style(styleSize: 15) .frame(height: 25) .padding(.horizontal, 20) @@ -36,7 +39,7 @@ struct PopupViewWithTextField: View { .focused($isMessageTextFocused) Button(action: { - conversationViewModel.isShowConversationInfoPopup = false + isShowConversationInfoPopup = false }, label: { Text("dialog_cancel") .default_text_style_orange_600(styleSize: 20) @@ -54,7 +57,8 @@ struct PopupViewWithTextField: View { .padding(.bottom, 10) Button(action: { - conversationViewModel.setNewChatRoomSubject() + setNewChatRoomSubject() + isShowConversationInfoPopup = false }, label: { Text("dialog_ok") .default_text_style_white_600(styleSize: 20) @@ -63,9 +67,9 @@ struct PopupViewWithTextField: View { }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background(conversationViewModel.conversationInfoPopupText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) + .background(conversationInfoPopupText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) .cornerRadius(60) - .disabled(conversationViewModel.conversationInfoPopupText.isEmpty) + .disabled(conversationInfoPopupText.isEmpty) } .padding(.horizontal, 20) .padding(.vertical, 20) @@ -77,9 +81,29 @@ struct PopupViewWithTextField: View { .frame(maxWidth: SharedMainViewModel.shared.maxWidth) .position(x: geometry.size.width / 2, y: geometry.size.height / 2) } + .onAppear { + self.conversationInfoPopupText = self.sharedMainViewModel.displayedConversation?.subject ?? "" + } } + + func setNewChatRoomSubject() { + if let displayedConversation = self.sharedMainViewModel.displayedConversation, self.conversationInfoPopupText != displayedConversation.subject { + + CoreContext.shared.doOnCoreQueue { _ in + displayedConversation.chatRoom.subject = self.conversationInfoPopupText + } + + displayedConversation.subject = self.conversationInfoPopupText + displayedConversation.avatarModel = ContactAvatarModel( + friend: displayedConversation.avatarModel.friend, + name: self.conversationInfoPopupText, + address: displayedConversation.avatarModel.address, + withPresence: false + ) + } + } } #Preview { - PopupViewWithTextField() + PopupViewWithTextField(isShowConversationInfoPopup: .constant(true), conversationInfoPopupText: .constant("")) } diff --git a/Linphone/UI/Main/Help/Fragments/HelpFragment.swift b/Linphone/UI/Main/Help/Fragments/HelpFragment.swift index 538de559b..1c4b0cd58 100644 --- a/Linphone/UI/Main/Help/Fragments/HelpFragment.swift +++ b/Linphone/UI/Main/Help/Fragments/HelpFragment.swift @@ -21,7 +21,7 @@ import SwiftUI struct HelpFragment: View { - @ObservedObject var helpViewModel: HelpViewModel + @StateObject private var helpViewModel = HelpViewModel() @Binding var isShowHelpFragment: Bool diff --git a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift index 5d21a8520..e66677444 100644 --- a/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/ScheduleMeetingFragment.swift @@ -29,7 +29,7 @@ struct ScheduleMeetingFragment: View { @EnvironmentObject var meetingsListViewModel: MeetingsListViewModel - @StateObject private var meetingViewModel = MeetingViewModel() + @StateObject private var meetingViewModel: MeetingViewModel @State private var delayedColor = Color.white @State private var showDatePicker = false @@ -47,6 +47,11 @@ struct ScheduleMeetingFragment: View { @FocusState var isDescriptionTextFocused: Bool @FocusState var isSubjectTextFocused: Bool + init(isShowScheduleMeetingFragmentSubject: String? = nil, isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel]? = nil, isShowScheduleMeetingFragment: Binding) { + _meetingViewModel = StateObject(wrappedValue: MeetingViewModel(isShowScheduleMeetingFragmentSubject: isShowScheduleMeetingFragmentSubject, isShowScheduleMeetingFragmentParticipants: isShowScheduleMeetingFragmentParticipants)) + self._isShowScheduleMeetingFragment = isShowScheduleMeetingFragment + } + var body: some View { NavigationView { ZStack(alignment: .bottomTrailing) { @@ -504,6 +509,7 @@ struct ScheduleMeetingFragment: View { #Preview { ScheduleMeetingFragment(isShowScheduleMeetingFragment: .constant(true)) + } // swiftlint:enable type_body_length diff --git a/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift b/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift index c201a9761..5ec77397f 100644 --- a/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift +++ b/Linphone/UI/Main/Meetings/ViewModel/MeetingViewModel.swift @@ -52,7 +52,10 @@ class MeetingViewModel: ObservableObject { @Published var toDate: Date @Published var errorMsg: String = "" - init() { + init(isShowScheduleMeetingFragmentSubject: String? = nil, isShowScheduleMeetingFragmentParticipants: [SelectedAddressModel]? = nil) { + self.subject = isShowScheduleMeetingFragmentSubject ?? "" + self.participants = isShowScheduleMeetingFragmentParticipants ?? [] + fromDate = Calendar.current.date(byAdding: .hour, value: 1, to: Date.now)! toDate = Calendar.current.date(byAdding: .hour, value: 2, to: Date.now)! diff --git a/Linphone/UI/Main/Settings/Fragments/SettingsFragment.swift b/Linphone/UI/Main/Settings/Fragments/SettingsFragment.swift index c65572ca0..761b3e6fb 100644 --- a/Linphone/UI/Main/Settings/Fragments/SettingsFragment.swift +++ b/Linphone/UI/Main/Settings/Fragments/SettingsFragment.swift @@ -21,7 +21,8 @@ import SwiftUI import UniformTypeIdentifiers struct SettingsFragment: View { - @ObservedObject var settingsViewModel: SettingsViewModel + + @StateObject private var settingsViewModel = SettingsViewModel() @Binding var isShowSettingsFragment: Bool diff --git a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift index 5c4c71cd5..b9e20049f 100644 --- a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift +++ b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift @@ -35,12 +35,10 @@ class SharedMainViewModel: ObservableObject { @Published var displayedConversation: ConversationModel? @Published var displayedMeeting: MeetingModel? - @Published var dialPlansList: [DialPlan] = [] @Published var dialPlansLabelList: [String] = [] @Published var dialPlansShortLabelList: [String] = [] - @Published var operationInProgress = false let welcomeViewKey = "welcome_view"