fix document view swift ui

pull/874/head
Ryan Zhao 2 years ago
parent 2a10ab208a
commit a826fcb061

@ -5,6 +5,8 @@ import SessionUIKit
import SessionMessagingKit import SessionMessagingKit
struct DocumentView_SwiftUI: View { struct DocumentView_SwiftUI: View {
static private let inset: CGFloat = 12
private let attachment: Attachment private let attachment: Attachment
private let textColor: ThemeValue private let textColor: ThemeValue
@ -21,19 +23,10 @@ struct DocumentView_SwiftUI: View {
ZStack { ZStack {
Rectangle() Rectangle()
.foregroundColor(themeColor: .messageBubble_overlay) .foregroundColor(themeColor: .messageBubble_overlay)
.frame(
width: 24 + Values.mediumSpacing
)
Image(systemName: "doc") Image(systemName: "doc")
.resizable() .font(.system(size: Values.largeFontSize))
.renderingMode(.template)
.foregroundColor(themeColor: textColor) .foregroundColor(themeColor: textColor)
.scaledToFit()
.frame(
width: 24,
height: 32
)
if attachment.isAudio { if attachment.isAudio {
Image(systemName: "music.note") Image(systemName: "music.note")
@ -48,6 +41,10 @@ struct DocumentView_SwiftUI: View {
) )
} }
} }
.frame(
width: 24 + Values.mediumSpacing * 2,
height: 32 + Values.smallSpacing * 2
)
Spacer(minLength: 0) Spacer(minLength: 0)
@ -67,14 +64,9 @@ struct DocumentView_SwiftUI: View {
.padding(.horizontal, Values.mediumSpacing) .padding(.horizontal, Values.mediumSpacing)
Image(systemName: (attachment.isAudio ? "play.fill" : "arrow.down")) Image(systemName: (attachment.isAudio ? "play.fill" : "arrow.down"))
.resizable() .font(.system(size: Values.mediumFontSize))
.renderingMode(.template)
.foregroundColor(themeColor: textColor) .foregroundColor(themeColor: textColor)
.scaledToFit() .padding(.trailing, Self.inset)
.frame(
width:24,
height: 24
)
} }
} }
} }

@ -1101,6 +1101,8 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate {
) -> NSMutableAttributedString? ) -> NSMutableAttributedString?
{ {
guard guard
let body: String = cellViewModel.body,
!body.isEmpty,
let actualTextColor: UIColor = theme.color(for: textColor), let actualTextColor: UIColor = theme.color(for: textColor),
let backgroundPrimaryColor: UIColor = theme.color(for: .backgroundPrimary), let backgroundPrimaryColor: UIColor = theme.color(for: .backgroundPrimary),
let textPrimaryColor: UIColor = theme.color(for: .textPrimary) let textPrimaryColor: UIColor = theme.color(for: .textPrimary)
@ -1110,7 +1112,7 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate {
let attributedText: NSMutableAttributedString = NSMutableAttributedString( let attributedText: NSMutableAttributedString = NSMutableAttributedString(
attributedString: MentionUtilities.highlightMentions( attributedString: MentionUtilities.highlightMentions(
in: (cellViewModel.body ?? ""), in: body,
threadVariant: cellViewModel.threadVariant, threadVariant: cellViewModel.threadVariant,
currentUserPublicKey: cellViewModel.currentUserPublicKey, currentUserPublicKey: cellViewModel.currentUserPublicKey,
currentUserBlinded15PublicKey: cellViewModel.currentUserBlinded15PublicKey, currentUserBlinded15PublicKey: cellViewModel.currentUserBlinded15PublicKey,

@ -53,7 +53,7 @@ struct MessageInfoView: View {
maxHeight: .infinity, maxHeight: .infinity,
alignment: .topLeading alignment: .topLeading
) )
.fixedSize(horizontal: true, vertical: true) .fixedSize()
.padding(.top, Values.smallSpacing) .padding(.top, Values.smallSpacing)
.padding(.bottom, Values.verySmallSpacing) .padding(.bottom, Values.verySmallSpacing)
.padding(.horizontal, Values.largeSpacing) .padding(.horizontal, Values.largeSpacing)
@ -85,7 +85,9 @@ struct MessageInfoView: View {
.padding(.horizontal, Values.largeSpacing) .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] let attachment: Attachment = attachments[(index - 1 + attachments.count) % attachments.count]
ZStack(alignment: .bottomTrailing) { ZStack(alignment: .bottomTrailing) {

Loading…
Cancel
Save