From 73ea3362b0adcaf20a36e2cff9edc5a64644b44c Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Thu, 24 Oct 2024 17:55:11 +0200 Subject: [PATCH] Add Menu in chatroom --- Linphone/Localizable.xcstrings | 68 +++++++++++++++++++ .../Fragments/ConversationFragment.swift | 20 ++++-- .../Model/ConversationModel.swift | 7 +- 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 97bfe9292..112190c0e 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -928,6 +928,40 @@ } } }, + "conversation_action_mute" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Mute" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Mettre en sourdine" + } + } + } + }, + "conversation_action_unmute" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Un-mute" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Enlever la sourdine" + } + } + } + }, "conversation_composing_label_multiple" : { "extractionState" : "manual", "localizations" : { @@ -1303,6 +1337,40 @@ } } }, + "conversation_menu_configure_ephemeral_messages" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ephemeral messages" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Messages éphémères" + } + } + } + }, + "conversation_menu_go_to_info" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Conversation info" + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Informations" + } + } + } + }, "conversation_message_forward_cancelled_toast" : { "extractionState" : "manual", "localizations" : { diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift index a29489ba4..9b281b80f 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift @@ -223,10 +223,12 @@ struct ConversationFragment: View { isMenuOpen = false } label: { HStack { - Text("See contact") + Text("conversation_menu_go_to_info") Spacer() - Image("user-circle") + Image("info") + .renderingMode(.template) .resizable() + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.all, 10) } @@ -236,23 +238,27 @@ struct ConversationFragment: View { isMenuOpen = false } label: { HStack { - Text("Copy SIP address") + Text(conversationViewModel.displayedConversation!.isMuted ? "conversation_action_unmute" : "conversation_action_mute") Spacer() - Image("copy") + Image(conversationViewModel.displayedConversation!.isMuted ? "bell-simple" : "bell-simple-slash") + .renderingMode(.template) .resizable() + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.all, 10) } } - Button(role: .destructive) { + Button { isMenuOpen = false } label: { HStack { - Text("Delete history") + Text("conversation_menu_configure_ephemeral_messages") Spacer() - Image("trash-simple-red") + Image("clock-countdown") + .renderingMode(.template) .resizable() + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.all, 10) } diff --git a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift index b5d8dca7e..587c433b8 100644 --- a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift +++ b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift @@ -22,7 +22,7 @@ import linphonesw import Combine // swiftlint:disable line_length -class ConversationModel: ObservableObject { +class ConversationModel: ObservableObject, Identifiable { private var coreContext = CoreContext.shared private var contactsManager = ContactsManager.shared @@ -101,8 +101,11 @@ class ConversationModel: ObservableObject { func toggleMute() { coreContext.doOnCoreQueue { _ in + let chatRoomMuted = self.chatRoom.muted self.chatRoom.muted.toggle() - self.isMuted = self.chatRoom.muted + DispatchQueue.main.async { + self.isMuted = !chatRoomMuted + } } }