Fixed issue with double rendering the message body

pull/1061/head
Morgan Pretty 2 weeks ago
parent 5d5b7635bd
commit 6ff2bf7047

@ -26,10 +26,15 @@ struct MessageInfoScreen: View {
VStack( VStack(
alignment: .leading, alignment: .leading,
spacing: 10 spacing: 10
) {
VStack(
alignment: .leading,
spacing: 0
) { ) {
// Message bubble snapshot // Message bubble snapshot
MessageBubble( MessageBubble(
messageViewModel: messageViewModel, messageViewModel: messageViewModel,
attachmentOnly: false,
dependencies: dependencies dependencies: dependencies
) )
.background( .background(
@ -78,9 +83,9 @@ struct MessageInfoScreen: View {
.padding(.horizontal, Values.largeSpacing) .padding(.horizontal, Values.largeSpacing)
} }
if let attachments = messageViewModel.attachments, if let attachments = messageViewModel.attachments {
messageViewModel.cellType == .mediaMessage switch messageViewModel.cellType {
{ case .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) {
@ -134,7 +139,36 @@ struct MessageInfoScreen: View {
} }
.padding(.vertical, Values.verySmallSpacing) .padding(.vertical, Values.verySmallSpacing)
default:
MessageBubble(
messageViewModel: messageViewModel,
attachmentOnly: true,
dependencies: dependencies
)
.background(
RoundedRectangle(cornerRadius: Self.cornerRadius)
.fill(
themeColor: (messageViewModel.variant == .standardIncoming || messageViewModel.variant == .standardIncomingDeleted || messageViewModel.variant == .standardIncomingDeletedLocally ?
.messageBubble_incomingBackground :
.messageBubble_outgoingBackground)
)
)
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: .topLeading
)
.fixedSize(horizontal: false, vertical: true)
.padding(.bottom, Values.verySmallSpacing)
.padding(.horizontal, Values.largeSpacing)
}
}
}
// Attachment Info // Attachment Info
if let attachments = messageViewModel.attachments {
let attachment: Attachment = attachments[(index - 1 + attachments.count) % attachments.count]
ZStack { ZStack {
VStack( VStack(
alignment: .leading, alignment: .leading,
@ -381,6 +415,7 @@ struct MessageBubble: View {
static private let inset: CGFloat = 12 static private let inset: CGFloat = 12
let messageViewModel: MessageViewModel let messageViewModel: MessageViewModel
let attachmentOnly: Bool
let dependencies: Dependencies let dependencies: Dependencies
var bodyLabelTextColor: ThemeValue { var bodyLabelTextColor: ThemeValue {
@ -397,6 +432,7 @@ struct MessageBubble: View {
alignment: .leading, alignment: .leading,
spacing: 0 spacing: 0
) { ) {
if !attachmentOnly {
// FIXME: We should support rendering link previews alongside quotes (bigger refactor) // 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 {
@ -441,7 +477,10 @@ struct MessageBubble: View {
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.padding(.top, Self.inset) .padding(.top, Self.inset)
.padding(.horizontal, Self.inset) .padding(.horizontal, Self.inset)
.padding(.bottom, -Values.smallSpacing) .padding(.bottom, (messageViewModel.body?.isEmpty == false ?
-Values.smallSpacing :
Self.inset
))
} }
} }
@ -456,7 +495,8 @@ struct MessageBubble: View {
AttributedText(bodyText) AttributedText(bodyText)
.padding(.all, Self.inset) .padding(.all, Self.inset)
} }
}
else {
switch messageViewModel.cellType { switch messageViewModel.cellType {
case .mediaMessage: case .mediaMessage:
if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText( if let bodyText: NSAttributedString = VisibleMessageCell.getBodyAttributedText(
@ -520,6 +560,7 @@ struct MessageBubble: View {
} }
} }
} }
}
struct InfoBlock<Content>: View where Content: View { struct InfoBlock<Content>: View where Content: View {
let title: String let title: String

Loading…
Cancel
Save