diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 55e8fd566..6bb5ae918 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -244,9 +244,6 @@ }, "Contacts" : { - }, - "Content" : { - }, "Continue" : { @@ -591,9 +588,6 @@ }, "This contact will be deleted definitively." : { - }, - "Title" : { - }, "TLS" : { diff --git a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift index 907f986bb..c7dd24d4b 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift @@ -26,6 +26,8 @@ struct ChatBubbleView: View { let message: Message + let geometryProxy: GeometryProxy + var body: some View { VStack { HStack { @@ -36,8 +38,44 @@ struct ChatBubbleView: View { VStack { if !message.attachments.isEmpty { if message.attachments.count == 1 { - let result = imageDimensions(url: message.attachments.first!.full.absoluteString) - if message.attachments.first!.type != .gif { + if message.attachments.first!.type == .image || message.attachments.first!.type == .gif { + let result = imageDimensions(url: message.attachments.first!.full.absoluteString) + if message.attachments.first!.type != .gif { + AsyncImage(url: message.attachments.first!.full) { image in + image.resizable() + .interpolation(.low) + .scaledToFit() + .clipShape(RoundedRectangle(cornerRadius: 4)) + } placeholder: { + ProgressView() + } + .frame( + height: result.0 > result.1 + ? result.1 / (result.0 / (geometryProxy.size.width - 80)) + : UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5 + ) + } else { + if result.0 < result.1 { + GifImageView(message.attachments.first!.full) + .clipShape(RoundedRectangle(cornerRadius: 4)) + .frame( + width: result.1 > (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5) + ? result.0 / (result.1 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5)) + : result.0, + height: result.1 > (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5) + ? UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5 + : result.1 + ) + } else { + GifImageView(message.attachments.first!.full) + .clipShape(RoundedRectangle(cornerRadius: 4)) + .frame( + height: result.1 / (result.0 / (geometryProxy.size.width - 80)) + ) + } + } + } else { + let result = imageDimensions(url: message.attachments.first!.full.absoluteString) AsyncImage(url: message.attachments.first!.full) { image in image.resizable() .interpolation(.low) @@ -48,29 +86,9 @@ struct ChatBubbleView: View { } .frame( height: result.0 > result.1 - ? (result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3))) - : (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3) + ? result.1 / (result.0 / (geometryProxy.size.width - 80)) + : UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5 ) - } else { - if result.0 < result.1 { - GifImageView(message.attachments.first!.full) - .clipShape(RoundedRectangle(cornerRadius: 4)) - .frame( - width: result.1 > UIScreen.main.bounds.height / 3 - ? (result.0 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3))) - : result.0, - height: result.1 > UIScreen.main.bounds.height / 3 - ? (result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3))) - : result.1 - ) - } else { - GifImageView(message.attachments.first!.full) - .clipShape(RoundedRectangle(cornerRadius: 4)) - .frame(maxWidth: .infinity) - .frame( - height: result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3)) - ) - } } } else { } diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift index 46dba158c..c95ecddde 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationFragment.swift @@ -152,7 +152,15 @@ struct ConversationFragment: View { if #available(iOS 16.0, *) { ZStack(alignment: .bottomTrailing) { - list + UIList(viewModel: viewModel, + paginationState: paginationState, + conversationViewModel: conversationViewModel, + isScrolledToBottom: $isScrolledToBottom, + showMessageMenuOnLongPress: showMessageMenuOnLongPress, + geometryProxy: geometry, + sections: conversationViewModel.conversationMessagesSection, + ids: conversationViewModel.conversationMessagesIds + ) if !isScrolledToBottom { Button { @@ -209,6 +217,7 @@ struct ConversationFragment: View { conversationViewModel.resetMessage() } } else { + /* ScrollViewReader { proxy in List { ForEach(0.., isScrolledToTop: Binding, showMessageMenuOnLongPress: Bool, sections: [MessagesSection], ids: [String]) { + init(conversationViewModel: ConversationViewModel, viewModel: ChatViewModel, paginationState: PaginationState, isScrolledToBottom: Binding, isScrolledToTop: Binding, showMessageMenuOnLongPress: Bool, geometryProxy: GeometryProxy, sections: [MessagesSection], ids: [String]) { self.conversationViewModel = conversationViewModel self.viewModel = viewModel self.paginationState = paginationState self._isScrolledToBottom = isScrolledToBottom self._isScrolledToTop = isScrolledToTop self.showMessageMenuOnLongPress = showMessageMenuOnLongPress + self.geometryProxy = geometryProxy self.sections = sections self.ids = ids } @@ -373,7 +377,7 @@ struct UIList: UIViewRepresentable { let row = sections[indexPath.section].rows[indexPath.row] if #available(iOS 16.0, *) { tableViewCell.contentConfiguration = UIHostingConfiguration { - ChatBubbleView(conversationViewModel: conversationViewModel, message: row) + ChatBubbleView(conversationViewModel: conversationViewModel, message: row, geometryProxy: geometryProxy) .padding(.vertical, 1) .padding(.horizontal, 10) .onTapGesture { }