diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationForwardMessageFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationForwardMessageFragment.swift index d1f281302..d7618ec69 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationForwardMessageFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationForwardMessageFragment.swift @@ -220,7 +220,7 @@ struct ConversationForwardMessageFragment: View { .navigationTitle("") .navigationBarHidden(true) .onAppear { - if !magicSearch.currentFilter.isEmpty { + if !magicSearch.currentFilter.isEmpty || (self.contactsManager.lastSearch.isEmpty && self.contactsManager.lastSearchSuggestions.isEmpty) { magicSearch.currentFilter = "" magicSearch.searchForContacts() } diff --git a/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift index 8f766df96..f00832aa0 100644 --- a/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift @@ -35,8 +35,6 @@ struct StartConversationFragment: View { @FocusState var isSearchFieldFocused: Bool @State private var delayedColor = Color.white - @FocusState var isMessageTextFocused: Bool - @State var operationInProgress: Bool = false var body: some View { @@ -133,7 +131,7 @@ struct StartConversationFragment: View { .padding(.horizontal) NavigationLink(destination: { - StartGroupConversationFragment() + StartGroupConversationFragment(isShowStartConversationFragment: $isShowStartConversationFragment) .environmentObject(startConversationViewModel) }, label: { HStack { @@ -204,37 +202,9 @@ struct StartConversationFragment: View { .frame(maxWidth: .infinity) } .background(.white) - - if !startConversationViewModel.participants.isEmpty { - startConversationPopup - .background(.black.opacity(0.65)) - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { - isMessageTextFocused = true - } - } - } - - if startConversationViewModel.operationInProgress { - PopupLoadingView() - .background(.black.opacity(0.65)) - .onDisappear { - startConversationViewModel.searchField = "" - magicSearch.currentFilter = "" - magicSearch.searchForContacts() - delayColorDismiss() - - isShowStartConversationFragment = false - - if let displayedConversation = startConversationViewModel.displayedConversation { - self.conversationsListViewModel.changeDisplayedChatRoom(conversationModel: displayedConversation) - startConversationViewModel.displayedConversation = nil - } - } - } } .onAppear { - if !magicSearch.currentFilter.isEmpty { + if !magicSearch.currentFilter.isEmpty || (self.contactsManager.lastSearch.isEmpty && self.contactsManager.lastSearchSuggestions.isEmpty) { magicSearch.currentFilter = "" magicSearch.searchForContacts() } @@ -297,75 +267,6 @@ struct StartConversationFragment: View { .listRowSeparator(.hidden) } } - - var startConversationPopup: some View { - GeometryReader { geometry in - VStack(alignment: .leading) { - Text("conversation_dialog_set_subject") - .default_text_style_800(styleSize: 16) - .frame(alignment: .leading) - .padding(.bottom, 2) - - TextField("conversation_dialog_subject_hint", text: $startConversationViewModel.messageText) - .default_text_style(styleSize: 15) - .frame(height: 25) - .padding(.horizontal, 20) - .padding(.vertical, 15) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(isMessageTextFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) - ) - .padding(.bottom) - .focused($isMessageTextFocused) - - Button(action: { - startConversationViewModel.participants.removeAll() - }, label: { - Text("dialog_cancel") - .default_text_style_orange_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - }) - .padding(.horizontal, 20) - .padding(.vertical, 10) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(Color.orangeMain500, lineWidth: 1) - ) - .padding(.bottom, 10) - - Button(action: { - startConversationViewModel.createGroupChatRoom() - }, label: { - Text("dialog_ok") - .default_text_style_white_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - }) - .padding(.horizontal, 20) - .padding(.vertical, 10) - .background(startConversationViewModel.messageText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) - .cornerRadius(60) - .disabled(startConversationViewModel.messageText.isEmpty) - } - .padding(.horizontal, 20) - .padding(.vertical, 20) - .background(.white) - .cornerRadius(20) - .padding(.horizontal) - .frame(maxHeight: .infinity) - .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) - .frame(maxWidth: SharedMainViewModel.shared.maxWidth) - .position(x: geometry.size.width / 2, y: geometry.size.height / 2) - .onDisappear { - startConversationViewModel.messageText = "" - } - } - } } #Preview { diff --git a/Linphone/UI/Main/Conversations/Fragments/StartGroupConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/StartGroupConversationFragment.swift index e284e3262..988884997 100644 --- a/Linphone/UI/Main/Conversations/Fragments/StartGroupConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/StartGroupConversationFragment.swift @@ -26,14 +26,114 @@ struct StartGroupConversationFragment: View { @State var addParticipantsViewModel = AddParticipantsViewModel() + @FocusState var isMessageTextFocused: Bool + + @Binding var isShowStartConversationFragment: Bool + var body: some View { - AddParticipantsFragment(addParticipantsViewModel: addParticipantsViewModel, confirmAddParticipantsFunc: startConversationViewModel.addParticipants) - .onAppear { - addParticipantsViewModel.participantsToAdd = startConversationViewModel.participants + ZStack { + AddParticipantsFragment(addParticipantsViewModel: addParticipantsViewModel, confirmAddParticipantsFunc: startConversationViewModel.addParticipants) + .onAppear { + addParticipantsViewModel.participantsToAdd = startConversationViewModel.participants + } + + + if !startConversationViewModel.participants.isEmpty { + startConversationPopup + .background(.black.opacity(0.65)) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { + isMessageTextFocused = true + } + } } + + if startConversationViewModel.operationInProgress { + PopupLoadingView() + .background(.black.opacity(0.65)) + .onDisappear { + startConversationViewModel.searchField = "" + MagicSearchSingleton.shared.currentFilter = "" + MagicSearchSingleton.shared.searchForContacts() + //delayColorDismiss() + + isShowStartConversationFragment = false + + if let displayedConversation = startConversationViewModel.displayedConversation { + self.conversationsListViewModel.changeDisplayedChatRoom(conversationModel: displayedConversation) + startConversationViewModel.displayedConversation = nil + } + } + } + } + } + + var startConversationPopup: some View { + GeometryReader { geometry in + VStack(alignment: .leading) { + Text("conversation_dialog_set_subject") + .default_text_style_800(styleSize: 16) + .frame(alignment: .leading) + .padding(.bottom, 2) + + TextField("conversation_dialog_subject_hint", text: $startConversationViewModel.messageText) + .default_text_style(styleSize: 15) + .frame(height: 25) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(isMessageTextFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) + ) + .padding(.bottom) + .focused($isMessageTextFocused) + + Button(action: { + startConversationViewModel.participants.removeAll() + }, label: { + Text("dialog_cancel") + .default_text_style_orange_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(Color.orangeMain500, lineWidth: 1) + ) + .padding(.bottom, 10) + + Button(action: { + startConversationViewModel.createGroupChatRoom() + }, label: { + Text("dialog_ok") + .default_text_style_white_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .background(startConversationViewModel.messageText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) + .cornerRadius(60) + .disabled(startConversationViewModel.messageText.isEmpty) + } + .padding(.horizontal, 20) + .padding(.vertical, 20) + .background(.white) + .cornerRadius(20) + .padding(.horizontal) + .frame(maxHeight: .infinity) + .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) + .frame(maxWidth: SharedMainViewModel.shared.maxWidth) + .position(x: geometry.size.width / 2, y: geometry.size.height / 2) + .onDisappear { + startConversationViewModel.messageText = "" + } + } } } - -#Preview { - StartGroupConversationFragment() -} diff --git a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift index ac89ffe72..4437d50cb 100644 --- a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift +++ b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift @@ -38,8 +38,6 @@ struct StartCallFragment: View { @FocusState var isSearchFieldFocused: Bool @State private var delayedColor = Color.white - @FocusState var isMessageTextFocused: Bool - var resetCallView: () -> Void var body: some View { @@ -198,7 +196,8 @@ struct StartCallFragment: View { .padding(.horizontal) NavigationLink(destination: { - StartGroupCallFragment(startCallViewModel: startCallViewModel) + StartGroupCallFragment(isShowStartCallFragment: $isShowStartCallFragment) + .environmentObject(startCallViewModel) }, label: { HStack { HStack(alignment: .center) { @@ -308,29 +307,11 @@ struct StartCallFragment: View { .frame(maxWidth: .infinity) } .background(.white) - - if !startCallViewModel.participants.isEmpty { - startCallPopup - .background(.black.opacity(0.65)) - .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { - isMessageTextFocused = true - } - } - } - - if startCallViewModel.operationInProgress { - PopupLoadingView() - .background(.black.opacity(0.65)) - .onDisappear { - isShowStartCallFragment.toggle() - } - } } .navigationTitle("") .navigationBarHidden(true) .onAppear { - if !magicSearch.currentFilter.isEmpty { + if !magicSearch.currentFilter.isEmpty || (self.contactsManager.lastSearch.isEmpty && self.contactsManager.lastSearchSuggestions.isEmpty) { magicSearch.currentFilter = "" magicSearch.searchForContacts() } @@ -431,72 +412,6 @@ struct StartCallFragment: View { .listRowSeparator(.hidden) } } - - var startCallPopup: some View { - GeometryReader { geometry in - VStack(alignment: .leading) { - Text("history_group_call_start_dialog_set_subject") - .default_text_style_800(styleSize: 16) - .frame(alignment: .leading) - .padding(.bottom, 2) - - TextField("history_group_call_start_dialog_subject_hint", text: $startCallViewModel.messageText) - .default_text_style(styleSize: 15) - .frame(height: 25) - .padding(.horizontal, 20) - .padding(.vertical, 15) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(isMessageTextFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) - ) - .padding(.bottom) - .focused($isMessageTextFocused) - - Button(action: { - startCallViewModel.participants.removeAll() - }, label: { - Text("dialog_cancel") - .default_text_style_orange_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - }) - .padding(.horizontal, 20) - .padding(.vertical, 10) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(Color.orangeMain500, lineWidth: 1) - ) - .padding(.bottom, 10) - - Button(action: { - startCallViewModel.createGroupCall() - }, label: { - Text("dialog_call") - .default_text_style_white_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - }) - .padding(.horizontal, 20) - .padding(.vertical, 10) - .background(startCallViewModel.messageText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) - .cornerRadius(60) - .disabled(startCallViewModel.messageText.isEmpty) - } - .padding(.horizontal, 20) - .padding(.vertical, 20) - .background(.white) - .cornerRadius(20) - .padding(.horizontal) - .frame(maxHeight: .infinity) - .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) - .frame(maxWidth: SharedMainViewModel.shared.maxWidth) - .position(x: geometry.size.width / 2, y: geometry.size.height / 2) - } - } } #Preview { diff --git a/Linphone/UI/Main/History/Fragments/StartGroupCallFragment.swift b/Linphone/UI/Main/History/Fragments/StartGroupCallFragment.swift index 9e5386f4e..c0f7c8664 100644 --- a/Linphone/UI/Main/History/Fragments/StartGroupCallFragment.swift +++ b/Linphone/UI/Main/History/Fragments/StartGroupCallFragment.swift @@ -20,17 +20,104 @@ import SwiftUI struct StartGroupCallFragment: View { - @ObservedObject var startCallViewModel: StartCallViewModel + @EnvironmentObject var startCallViewModel: StartCallViewModel + @State var addParticipantsViewModel = AddParticipantsViewModel() + @FocusState var isMessageTextFocused: Bool + + @Binding var isShowStartCallFragment: Bool + var body: some View { - AddParticipantsFragment(addParticipantsViewModel: addParticipantsViewModel, confirmAddParticipantsFunc: startCallViewModel.addParticipants) - .onAppear { - addParticipantsViewModel.participantsToAdd = startCallViewModel.participants + ZStack { + AddParticipantsFragment(addParticipantsViewModel: addParticipantsViewModel, confirmAddParticipantsFunc: startCallViewModel.addParticipants) + .onAppear { + addParticipantsViewModel.participantsToAdd = startCallViewModel.participants + } + + if !startCallViewModel.participants.isEmpty { + startCallPopup + .background(.black.opacity(0.65)) + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) { + isMessageTextFocused = true + } + } } + + if startCallViewModel.operationInProgress { + PopupLoadingView() + .background(.black.opacity(0.65)) + .onDisappear { + isShowStartCallFragment.toggle() + } + } + } } -} - -#Preview { - StartGroupCallFragment(startCallViewModel: StartCallViewModel()) + + var startCallPopup: some View { + GeometryReader { geometry in + VStack(alignment: .leading) { + Text("history_group_call_start_dialog_set_subject") + .default_text_style_800(styleSize: 16) + .frame(alignment: .leading) + .padding(.bottom, 2) + + TextField("history_group_call_start_dialog_subject_hint", text: $startCallViewModel.messageText) + .default_text_style(styleSize: 15) + .frame(height: 25) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(isMessageTextFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) + ) + .padding(.bottom) + .focused($isMessageTextFocused) + + Button(action: { + startCallViewModel.participants.removeAll() + }, label: { + Text("dialog_cancel") + .default_text_style_orange_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(Color.orangeMain500, lineWidth: 1) + ) + .padding(.bottom, 10) + + Button(action: { + startCallViewModel.createGroupCall() + }, label: { + Text("dialog_call") + .default_text_style_white_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .background(startCallViewModel.messageText.isEmpty ? Color.orangeMain100 : Color.orangeMain500) + .cornerRadius(60) + .disabled(startCallViewModel.messageText.isEmpty) + } + .padding(.horizontal, 20) + .padding(.vertical, 20) + .background(.white) + .cornerRadius(20) + .padding(.horizontal) + .frame(maxHeight: .infinity) + .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) + .frame(maxWidth: SharedMainViewModel.shared.maxWidth) + .position(x: geometry.size.width / 2, y: geometry.size.height / 2) + } + } } diff --git a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift index 6c9390a5c..72d1429d6 100644 --- a/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift +++ b/Linphone/UI/Main/Meetings/Fragments/AddParticipantsFragment.swift @@ -252,7 +252,7 @@ struct AddParticipantsFragment: View { Button { withAnimation { confirmAddParticipantsFunc(addParticipantsViewModel.participantsToAdd) - dismiss() + //dismiss() magicSearch.currentFilter = "" magicSearch.searchForContacts() @@ -272,7 +272,7 @@ struct AddParticipantsFragment: View { .navigationTitle("") .navigationBarHidden(true) .onAppear { - if !magicSearch.currentFilter.isEmpty { + if !magicSearch.currentFilter.isEmpty || (self.contactsManager.lastSearch.isEmpty && self.contactsManager.lastSearchSuggestions.isEmpty) { magicSearch.currentFilter = "" magicSearch.searchForContacts() }