From abe0f2db1bd3a3ae8d116f0e0f33b3e8a8ff5397 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Tue, 15 Jul 2025 10:51:54 +0200 Subject: [PATCH] Add IMDN sheet to selected message view --- .../Localizable/cs.lproj/Localizable.strings | 1 + .../Localizable/en.lproj/Localizable.strings | 1 + .../Localizable/fr.lproj/Localizable.strings | 1 + .../Localizable/uk.lproj/Localizable.strings | 1 + .../Fragments/ConversationFragment.swift | 70 ++++++++++++++++--- 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Linphone/Localizable/cs.lproj/Localizable.strings b/Linphone/Localizable/cs.lproj/Localizable.strings index 2588c89fc..9c72ba778 100644 --- a/Linphone/Localizable/cs.lproj/Localizable.strings +++ b/Linphone/Localizable/cs.lproj/Localizable.strings @@ -244,6 +244,7 @@ "meeting_waiting_room_joining_title" = "Probíhá připojování"; "meetings_list_no_meeting_for_today" = "Dnes není naplánována žádná schůzka"; "menu_see_existing_contact" = "Zobrazit kontakt"; +"menu_show_imdn" = "Stav doručení"; "message_delivery_info_error_title" = "Chyba"; "message_forwarded_label" = "Přeposláno"; "message_reaction_click_to_remove_label" = "Klepnutím odstranit"; diff --git a/Linphone/Localizable/en.lproj/Localizable.strings b/Linphone/Localizable/en.lproj/Localizable.strings index acf3b543b..0ce88871a 100644 --- a/Linphone/Localizable/en.lproj/Localizable.strings +++ b/Linphone/Localizable/en.lproj/Localizable.strings @@ -390,6 +390,7 @@ "menu_reply_to_chat_message" = "Reply"; "menu_resend_chat_message" = "Re-send"; "menu_see_existing_contact" = "See contact"; +"menu_show_imdn" = "Delivery status"; "message_copied_to_clipboard_toast" = "Message copied into clipboard"; "message_delivery_info_error_title" = "Error"; "message_delivery_info_read_title" = "Read"; diff --git a/Linphone/Localizable/fr.lproj/Localizable.strings b/Linphone/Localizable/fr.lproj/Localizable.strings index 98ef0961f..c8ac51199 100644 --- a/Linphone/Localizable/fr.lproj/Localizable.strings +++ b/Linphone/Localizable/fr.lproj/Localizable.strings @@ -390,6 +390,7 @@ "menu_reply_to_chat_message" = "Répondre"; "menu_resend_chat_message" = "Ré-envoyer"; "menu_see_existing_contact" = "Voir le contact"; +"menu_show_imdn" = "Info de réception"; "message_copied_to_clipboard_toast" = "Message copié dans le presse-papier"; "message_delivery_info_error_title" = "En erreur"; "message_delivery_info_read_title" = "Lu"; diff --git a/Linphone/Localizable/uk.lproj/Localizable.strings b/Linphone/Localizable/uk.lproj/Localizable.strings index b51871703..591db985e 100644 --- a/Linphone/Localizable/uk.lproj/Localizable.strings +++ b/Linphone/Localizable/uk.lproj/Localizable.strings @@ -189,6 +189,7 @@ "menu_reply_to_chat_message" = "Відповісти"; "menu_resend_chat_message" = "Надіслати повторно"; "menu_see_existing_contact" = "Переглянути контакт"; +"menu_show_imdn" = "Статус доставки"; "message_delivery_info_error_title" = "Помилка"; "message_forwarded_label" = "Перенаправлено"; "message_reaction_click_to_remove_label" = "Натисніть, щоб видалити"; diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift index aebaeccb8..5a17eb6ea 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift @@ -86,6 +86,8 @@ struct ConversationFragment: View { @State private var showPicker = false @State private var isSheetVisible = false + @State private var isImdnOrReactionsSheetVisible = false + var body: some View { NavigationView { GeometryReader { geometry in @@ -106,7 +108,7 @@ struct ConversationFragment: View { .sheet(isPresented: $conversationViewModel.isShowSelectedMessageToDisplayDetails, onDismiss: { conversationViewModel.isShowSelectedMessageToDisplayDetails = false }, content: { - ImdnOrReactionsSheet(selectedCategoryIndex: $selectedCategoryIndex) + ImdnOrReactionsSheet(selectedCategoryIndex: $selectedCategoryIndex, isImdnOrReactionsSheetVisible: $isImdnOrReactionsSheetVisible) .environmentObject(conversationViewModel) .presentationDetents([.medium]) .presentationDragIndicator(.visible) @@ -178,7 +180,7 @@ struct ConversationFragment: View { conversationViewModel.removeConversationDelegate() } .halfSheet(showSheet: $conversationViewModel.isShowSelectedMessageToDisplayDetails) { - ImdnOrReactionsSheet(selectedCategoryIndex: $selectedCategoryIndex) + ImdnOrReactionsSheet(selectedCategoryIndex: $selectedCategoryIndex, isImdnOrReactionsSheetVisible: $isImdnOrReactionsSheetVisible) .environmentObject(conversationViewModel) } onDismiss: { conversationViewModel.isShowSelectedMessageToDisplayDetails = false @@ -918,7 +920,7 @@ struct ConversationFragment: View { Spacer() VStack { - if !isSheetVisible { + if !isSheetVisible && !isImdnOrReactionsSheetVisible { HStack { if conversationViewModel.selectedMessage!.message.isOutgoing { Spacer() @@ -1010,15 +1012,35 @@ struct ConversationFragment: View { .padding(.horizontal, 10) .padding(.vertical, 1) .shadow(color: .black.opacity(0.1), radius: 10) - .offset(y: isSheetVisible ? -(UIScreen.main.bounds.height * 0.5) - 10 : 0) + .offset(y: isSheetVisible || isImdnOrReactionsSheetVisible ? -(UIScreen.main.bounds.height * 0.5) - 10 : 0) - if !isSheetVisible { + if !isSheetVisible && !isImdnOrReactionsSheetVisible { HStack { if conversationViewModel.selectedMessage!.message.isOutgoing { Spacer() } VStack { + if !(CoreContext.shared.imdnToEverybodyThreshold && !conversationViewModel.selectedMessage!.message.isOutgoing) { + Button { + conversationViewModel.selectedMessageToDisplayDetails = conversationViewModel.selectedMessage + conversationViewModel.prepareBottomSheetForDeliveryStatus() + } label: { + HStack { + Text("menu_show_imdn") + .default_text_style(styleSize: 15) + Spacer() + Image("info") + .resizable() + .frame(width: 20, height: 20, alignment: .leading) + } + .padding(.vertical, 5) + .padding(.horizontal, 20) + } + + Divider() + } + Button { let indexMessage = conversationViewModel.conversationMessagesSection[0].rows.firstIndex(where: {$0.message.id == conversationViewModel.selectedMessage!.message.id}) conversationViewModel.selectedMessage = nil @@ -1190,6 +1212,7 @@ struct ImdnOrReactionsSheet: View { @EnvironmentObject var conversationViewModel: ConversationViewModel @Binding var selectedCategoryIndex: Int + @Binding var isImdnOrReactionsSheetVisible: Bool var body: some View { VStack { @@ -1246,9 +1269,15 @@ struct ImdnOrReactionsSheet: View { } } .listStyle(.plain) + + WillDisappearNotifierView { + isImdnOrReactionsSheetVisible = false + } + .frame(width: 0, height: 0) } .onAppear { selectedCategoryIndex = 0 + isImdnOrReactionsSheetVisible = true } .padding(.top) .background(.white) @@ -1518,11 +1547,34 @@ struct VoiceRecorderPlayer: View { timer = nil } } -/* -#Preview { - ConversationFragment(sections: [MessagesSection], ids: [""]) + +struct WillDisappearNotifierView: UIViewControllerRepresentable { + let onWillDisappear: () -> Void + + func makeUIViewController(context: Context) -> UIViewController { + Controller(onWillDisappear: onWillDisappear) + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} + + class Controller: UIViewController { + let onWillDisappearCallback: () -> Void + + init(onWillDisappear: @escaping () -> Void) { + self.onWillDisappearCallback = onWillDisappear + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + onWillDisappearCallback() + } + } } -*/ // swiftlint:enable type_body_length // swiftlint:enable line_length