Fixed the quote rendering with attachments on the MessageInfo screen

pull/1061/head
Morgan Pretty 4 days ago
parent bcbc481dad
commit 5d5b7635bd

@ -391,61 +391,74 @@ struct MessageBubble: View {
var body: some View { var body: some View {
ZStack { ZStack {
switch messageViewModel.cellType { let maxWidth: CGFloat = (VisibleMessageCell.getMaxWidth(for: messageViewModel) - 2 * Self.inset)
case .textOnlyMessage:
let maxWidth: CGFloat = (VisibleMessageCell.getMaxWidth(for: messageViewModel) - 2 * Self.inset) VStack(
alignment: .leading,
VStack( spacing: 0
alignment: .leading, ) {
spacing: 0 // FIXME: We should support rendering link previews alongside quotes (bigger refactor)
) { if let linkPreview: LinkPreview = messageViewModel.linkPreview {
if let linkPreview: LinkPreview = messageViewModel.linkPreview { switch linkPreview.variant {
switch linkPreview.variant { case .standard:
case .standard: LinkPreviewView_SwiftUI(
LinkPreviewView_SwiftUI( state: LinkPreview.SentState(
state: LinkPreview.SentState( linkPreview: linkPreview,
linkPreview: linkPreview, imageAttachment: messageViewModel.linkPreviewAttachment,
imageAttachment: messageViewModel.linkPreviewAttachment,
using: dependencies
),
isOutgoing: (messageViewModel.variant == .standardOutgoing),
maxWidth: maxWidth,
messageViewModel: messageViewModel,
bodyLabelTextColor: bodyLabelTextColor,
lastSearchText: nil
)
case .openGroupInvitation:
OpenGroupInvitationView_SwiftUI(
name: (linkPreview.title ?? ""),
url: linkPreview.url,
textColor: bodyLabelTextColor,
isOutgoing: (messageViewModel.variant == .standardOutgoing))
}
}
else {
if let quote = messageViewModel.quote {
QuoteView_SwiftUI(
info: .init(
mode: .regular,
authorId: quote.authorId,
quotedText: quote.body,
threadVariant: messageViewModel.threadVariant,
currentUserSessionId: messageViewModel.currentUserSessionId,
currentUserBlinded15SessionId: messageViewModel.currentUserBlinded15SessionId,
currentUserBlinded25SessionId: messageViewModel.currentUserBlinded25SessionId,
direction: (messageViewModel.variant == .standardOutgoing ? .outgoing : .incoming),
attachment: messageViewModel.quoteAttachment
),
using: dependencies using: dependencies
) ),
.fixedSize(horizontal: false, vertical: true) isOutgoing: (messageViewModel.variant == .standardOutgoing),
.padding(.top, Self.inset) maxWidth: maxWidth,
.padding(.horizontal, Self.inset) messageViewModel: messageViewModel,
.padding(.bottom, -Values.smallSpacing) bodyLabelTextColor: bodyLabelTextColor,
} lastSearchText: nil
} )
case .openGroupInvitation:
OpenGroupInvitationView_SwiftUI(
name: (linkPreview.title ?? ""),
url: linkPreview.url,
textColor: bodyLabelTextColor,
isOutgoing: (messageViewModel.variant == .standardOutgoing))
}
}
else {
if let quote = messageViewModel.quote {
QuoteView_SwiftUI(
info: .init(
mode: .regular,
authorId: quote.authorId,
quotedText: quote.body,
threadVariant: messageViewModel.threadVariant,
currentUserSessionId: messageViewModel.currentUserSessionId,
currentUserBlinded15SessionId: messageViewModel.currentUserBlinded15SessionId,
currentUserBlinded25SessionId: messageViewModel.currentUserBlinded25SessionId,
direction: (messageViewModel.variant == .standardOutgoing ? .outgoing : .incoming),
attachment: messageViewModel.quoteAttachment
),
using: dependencies
)
.fixedSize(horizontal: false, vertical: true)
.padding(.top, Self.inset)
.padding(.horizontal, Self.inset)
.padding(.bottom, -Values.smallSpacing)
}
}
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText(
for: messageViewModel,
theme: ThemeManager.currentTheme,
primaryColor: ThemeManager.primaryColor,
textColor: bodyLabelTextColor,
searchText: nil,
using: dependencies
) {
AttributedText(bodyText)
.padding(.all, Self.inset)
}
switch messageViewModel.cellType {
case .mediaMessage:
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText( if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText(
for: messageViewModel, for: messageViewModel,
theme: ThemeManager.currentTheme, theme: ThemeManager.currentTheme,
@ -457,64 +470,52 @@ struct MessageBubble: View {
AttributedText(bodyText) AttributedText(bodyText)
.padding(.all, Self.inset) .padding(.all, Self.inset)
} }
} case .voiceMessage:
case .mediaMessage: if let attachment: Attachment = messageViewModel.attachments?.first(where: { $0.isAudio }){
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText( // TODO: Playback Info and check if playing function is needed
for: messageViewModel, VoiceMessageView_SwiftUI(attachment: attachment)
theme: ThemeManager.currentTheme, }
primaryColor: ThemeManager.primaryColor, case .audio, .genericAttachment:
textColor: bodyLabelTextColor, if let attachment: Attachment = messageViewModel.attachments?.first {
searchText: nil, VStack(
using: dependencies alignment: .leading,
) { spacing: Values.smallSpacing
AttributedText(bodyText)
.padding(.all, Self.inset)
}
case .voiceMessage:
if let attachment: Attachment = messageViewModel.attachments?.first(where: { $0.isAudio }){
// TODO: Playback Info and check if playing function is needed
VoiceMessageView_SwiftUI(attachment: attachment)
}
case .audio, .genericAttachment:
if let attachment: Attachment = messageViewModel.attachments?.first {
VStack(
alignment: .leading,
spacing: Values.smallSpacing
) {
DocumentView_SwiftUI(
maxWidth: $maxWidth,
attachment: attachment,
textColor: bodyLabelTextColor
)
.modifier(MaxWidthEqualizer.notify)
.frame(
width: maxWidth,
alignment: .leading
)
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText(
for: messageViewModel,
theme: ThemeManager.currentTheme,
primaryColor: ThemeManager.primaryColor,
textColor: bodyLabelTextColor,
searchText: nil,
using: dependencies
) { ) {
ZStack{ DocumentView_SwiftUI(
AttributedText(bodyText) maxWidth: $maxWidth,
.padding(.horizontal, Self.inset) attachment: attachment,
.padding(.bottom, Self.inset) textColor: bodyLabelTextColor
} )
.modifier(MaxWidthEqualizer.notify) .modifier(MaxWidthEqualizer.notify)
.frame( .frame(
width: maxWidth, width: maxWidth,
alignment: .leading alignment: .leading
) )
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText(
for: messageViewModel,
theme: ThemeManager.currentTheme,
primaryColor: ThemeManager.primaryColor,
textColor: bodyLabelTextColor,
searchText: nil,
using: dependencies
) {
ZStack{
AttributedText(bodyText)
.padding(.horizontal, Self.inset)
.padding(.bottom, Self.inset)
}
.modifier(MaxWidthEqualizer.notify)
.frame(
width: maxWidth,
alignment: .leading
)
}
} }
.modifier(MaxWidthEqualizer(width: $maxWidth))
} }
.modifier(MaxWidthEqualizer(width: $maxWidth)) default: EmptyView()
} }
default: EmptyView()
} }
} }
} }

Loading…
Cancel
Save