From a826fcb061078e315bfc37780f525bfee7b1e630 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 2 Nov 2023 13:38:00 +1100 Subject: [PATCH] fix document view swift ui --- .../SwiftUI/DocumentView_SwiftUI.swift | 28 +++++++------------ .../Message Cells/VisibleMessageCell.swift | 4 ++- .../MessageInfoView.swift | 6 ++-- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Session/Conversations/Message Cells/Content Views/SwiftUI/DocumentView_SwiftUI.swift b/Session/Conversations/Message Cells/Content Views/SwiftUI/DocumentView_SwiftUI.swift index 0a17cdc18..ef056915b 100644 --- a/Session/Conversations/Message Cells/Content Views/SwiftUI/DocumentView_SwiftUI.swift +++ b/Session/Conversations/Message Cells/Content Views/SwiftUI/DocumentView_SwiftUI.swift @@ -5,6 +5,8 @@ import SessionUIKit import SessionMessagingKit struct DocumentView_SwiftUI: View { + static private let inset: CGFloat = 12 + private let attachment: Attachment private let textColor: ThemeValue @@ -21,20 +23,11 @@ struct DocumentView_SwiftUI: View { ZStack { Rectangle() .foregroundColor(themeColor: .messageBubble_overlay) - .frame( - width: 24 + Values.mediumSpacing - ) Image(systemName: "doc") - .resizable() - .renderingMode(.template) + .font(.system(size: Values.largeFontSize)) .foregroundColor(themeColor: textColor) - .scaledToFit() - .frame( - width: 24, - height: 32 - ) - + if attachment.isAudio { Image(systemName: "music.note") .resizable() @@ -48,6 +41,10 @@ struct DocumentView_SwiftUI: View { ) } } + .frame( + width: 24 + Values.mediumSpacing * 2, + height: 32 + Values.smallSpacing * 2 + ) Spacer(minLength: 0) @@ -67,14 +64,9 @@ struct DocumentView_SwiftUI: View { .padding(.horizontal, Values.mediumSpacing) Image(systemName: (attachment.isAudio ? "play.fill" : "arrow.down")) - .resizable() - .renderingMode(.template) + .font(.system(size: Values.mediumFontSize)) .foregroundColor(themeColor: textColor) - .scaledToFit() - .frame( - width:24, - height: 24 - ) + .padding(.trailing, Self.inset) } } } diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 366babb82..414f1ef77 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -1101,6 +1101,8 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { ) -> NSMutableAttributedString? { guard + let body: String = cellViewModel.body, + !body.isEmpty, let actualTextColor: UIColor = theme.color(for: textColor), let backgroundPrimaryColor: UIColor = theme.color(for: .backgroundPrimary), let textPrimaryColor: UIColor = theme.color(for: .textPrimary) @@ -1110,7 +1112,7 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { let attributedText: NSMutableAttributedString = NSMutableAttributedString( attributedString: MentionUtilities.highlightMentions( - in: (cellViewModel.body ?? ""), + in: body, threadVariant: cellViewModel.threadVariant, currentUserPublicKey: cellViewModel.currentUserPublicKey, currentUserBlinded15PublicKey: cellViewModel.currentUserBlinded15PublicKey, diff --git a/Session/Media Viewing & Editing/MessageInfoView.swift b/Session/Media Viewing & Editing/MessageInfoView.swift index b40042f8d..510a954fa 100644 --- a/Session/Media Viewing & Editing/MessageInfoView.swift +++ b/Session/Media Viewing & Editing/MessageInfoView.swift @@ -53,7 +53,7 @@ struct MessageInfoView: View { maxHeight: .infinity, alignment: .topLeading ) - .fixedSize(horizontal: true, vertical: true) + .fixedSize() .padding(.top, Values.smallSpacing) .padding(.bottom, Values.verySmallSpacing) .padding(.horizontal, Values.largeSpacing) @@ -85,7 +85,9 @@ struct MessageInfoView: View { .padding(.horizontal, Values.largeSpacing) } - if let attachments = messageViewModel.attachments { + if let attachments = messageViewModel.attachments, + messageViewModel.cellType == .mediaMessage + { let attachment: Attachment = attachments[(index - 1 + attachments.count) % attachments.count] ZStack(alignment: .bottomTrailing) {