|
|
|
@ -40,6 +40,14 @@ struct MessageInfoView: View {
|
|
|
|
|
MessageBubble(
|
|
|
|
|
messageViewModel: messageViewModel
|
|
|
|
|
)
|
|
|
|
|
.background(
|
|
|
|
|
RoundedRectangle(cornerRadius: Self.cornerRadius)
|
|
|
|
|
.fill(
|
|
|
|
|
themeColor: (messageViewModel.variant == .standardIncoming || messageViewModel.variant == .standardIncomingDeleted ?
|
|
|
|
|
.messageBubble_incomingBackground :
|
|
|
|
|
.messageBubble_outgoingBackground)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.frame(
|
|
|
|
|
maxWidth: .infinity,
|
|
|
|
|
maxHeight: .infinity,
|
|
|
|
@ -362,48 +370,43 @@ struct MessageBubble: View {
|
|
|
|
|
static private let cornerRadius: CGFloat = 18
|
|
|
|
|
|
|
|
|
|
let messageViewModel: MessageViewModel
|
|
|
|
|
var bubbleBackgroundColor: ThemeValue {
|
|
|
|
|
messageViewModel.variant == .standardIncoming || messageViewModel.variant == .standardIncomingDeleted ?
|
|
|
|
|
.messageBubble_incomingBackground :
|
|
|
|
|
.messageBubble_outgoingBackground
|
|
|
|
|
|
|
|
|
|
var bodyLabelTextColor: ThemeValue {
|
|
|
|
|
messageViewModel.variant == .standardOutgoing ?
|
|
|
|
|
.messageBubble_outgoingText :
|
|
|
|
|
.messageBubble_incomingText
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
ZStack {
|
|
|
|
|
// switch messageViewModel.cellType {
|
|
|
|
|
// case .typingIndicator, .dateHeader, .unreadMarker: break
|
|
|
|
|
//
|
|
|
|
|
// case .textOnlyMessage:
|
|
|
|
|
// let inset: CGFloat = 12
|
|
|
|
|
// let maxWidth: CGFloat = (VisibleMessageCell.getMaxWidth(for: messageViewModel) - 2 * inset)
|
|
|
|
|
//
|
|
|
|
|
// if let linkPreview: LinkPreview = messageViewModel.linkPreview {
|
|
|
|
|
// switch linkPreview.variant {
|
|
|
|
|
// case .standard:
|
|
|
|
|
// LinkPreviewView_SwiftUI(
|
|
|
|
|
// state: LinkPreview.SentState(
|
|
|
|
|
// linkPreview: linkPreview,
|
|
|
|
|
// imageAttachment: messageViewModel.linkPreviewAttachment
|
|
|
|
|
// ),
|
|
|
|
|
// isOutgoing: (messageViewModel.variant == .standardOutgoing),
|
|
|
|
|
// maxWidth: maxWidth,
|
|
|
|
|
// messageViewModel: messageViewModel,
|
|
|
|
|
// bodyLabelTextColor: nil,
|
|
|
|
|
// lastSearchText: nil
|
|
|
|
|
// )
|
|
|
|
|
//
|
|
|
|
|
// case .openGroupInvitation:
|
|
|
|
|
// let openGroupInvitationView: OpenGroupInvitationView = OpenGroupInvitationView(
|
|
|
|
|
// name: (linkPreview.title ?? ""),
|
|
|
|
|
// url: linkPreview.url,
|
|
|
|
|
// textColor: bodyLabelTextColor,
|
|
|
|
|
// isOutgoing: (cellViewModel.variant == .standardOutgoing)
|
|
|
|
|
// )
|
|
|
|
|
// bubbleView.addSubview(openGroupInvitationView)
|
|
|
|
|
// bubbleView.pin(to: openGroupInvitationView)
|
|
|
|
|
// snContentView.addArrangedSubview(bubbleBackgroundView)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
switch messageViewModel.cellType {
|
|
|
|
|
case .textOnlyMessage:
|
|
|
|
|
let inset: CGFloat = 12
|
|
|
|
|
let maxWidth: CGFloat = (VisibleMessageCell.getMaxWidth(for: messageViewModel) - 2 * inset)
|
|
|
|
|
|
|
|
|
|
if let linkPreview: LinkPreview = messageViewModel.linkPreview {
|
|
|
|
|
switch linkPreview.variant {
|
|
|
|
|
case .standard:
|
|
|
|
|
LinkPreviewView_SwiftUI(
|
|
|
|
|
state: LinkPreview.SentState(
|
|
|
|
|
linkPreview: linkPreview,
|
|
|
|
|
imageAttachment: messageViewModel.linkPreviewAttachment
|
|
|
|
|
),
|
|
|
|
|
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 {
|
|
|
|
|
// // Stack view
|
|
|
|
|
// let stackView = UIStackView(arrangedSubviews: [])
|
|
|
|
@ -411,7 +414,7 @@ struct MessageBubble: View {
|
|
|
|
|
// stackView.spacing = 2
|
|
|
|
|
//
|
|
|
|
|
// // Quote view
|
|
|
|
|
// if let quote: Quote = cellViewModel.quote {
|
|
|
|
|
// if let quote: Quote = messageViewModel.quote {
|
|
|
|
|
// let hInset: CGFloat = 2
|
|
|
|
|
// let quoteView: QuoteView = QuoteView(
|
|
|
|
|
// for: .regular,
|
|
|
|
@ -548,11 +551,9 @@ struct MessageBubble: View {
|
|
|
|
|
// snContentView.addArrangedSubview(bubbleBackgroundView)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
default: EmptyView()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.background(
|
|
|
|
|
RoundedRectangle(cornerRadius: Self.cornerRadius)
|
|
|
|
|
.fill(themeColor: bubbleBackgroundColor)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|