From 13ace49560670acd2d085c2cfd3989edfe6016b4 Mon Sep 17 00:00:00 2001 From: Woit Date: Mon, 25 Nov 2024 13:02:36 +0100 Subject: [PATCH] wip --- .../ConversationMessageContainer.swift | 54 ++++++++++--------- .../Conversation/ConversationMessageRow.swift | 26 ++++----- .../another.im/XMPP/MonalWrapperModels.swift | 2 + 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Monal/another.im/Views/Conversation/ConversationMessageContainer.swift b/Monal/another.im/Views/Conversation/ConversationMessageContainer.swift index 9ffc3ac..d67eb06 100644 --- a/Monal/another.im/Views/Conversation/ConversationMessageContainer.swift +++ b/Monal/another.im/Views/Conversation/ConversationMessageContainer.swift @@ -4,11 +4,16 @@ import QuickLook import SwiftUI struct ConversationMessageContainer: View { - // let message: Message - let isOutgoing: Bool + let message: Message var body: some View { - Text("dumb") + // fmodf: for now only text + Text(message.body) + .font(.body2) + .foregroundColor(.Material.Text.main) + .multilineTextAlignment(.leading) + .padding(10) + // if let msgText = message.body, msgText.isLocation { // EmbededMapView(location: msgText.getLatLon) // } else if let msgText = message.body, msgText.isContact { @@ -26,29 +31,30 @@ struct ConversationMessageContainer: View { } struct MessageAttr: View { - // let message: Message + let message: Message var body: some View { - // VStack(alignment: .leading, spacing: 0) { - // Text(message.date, style: .time) - // .font(.sub2) - // .foregroundColor(.Material.Shape.separator) - // Spacer() - // if message.status == .error { - // Image(systemName: "exclamationmark.circle") - // .font(.body3) - // .foregroundColor(.Rainbow.red500) - // } else if message.status == .pending { - // Image(systemName: "clock") - // .font(.body3) - // .foregroundColor(.Material.Shape.separator) - // } else if message.secure { - // Image(systemName: "lock") - // .font(.body3) - // .foregroundColor(.Material.Shape.separator) - // } - // } - Text("dumb") + VStack(alignment: .leading, spacing: 0) { + Text(message.timestamp, style: .time) + .font(.sub2) + .foregroundColor(.Material.Shape.separator) + Spacer() + + // message state commented for now + // if message.status == .error { + // Image(systemName: "exclamationmark.circle") + // .font(.body3) + // .foregroundColor(.Rainbow.red500) + // } else if message.status == .pending { + // Image(systemName: "clock") + // .font(.body3) + // .foregroundColor(.Material.Shape.separator) + // } else if message.secure { + // Image(systemName: "lock") + // .font(.body3) + // .foregroundColor(.Material.Shape.separator) + // } + } } } diff --git a/Monal/another.im/Views/Conversation/ConversationMessageRow.swift b/Monal/another.im/Views/Conversation/ConversationMessageRow.swift index 0d12b6e..4422639 100644 --- a/Monal/another.im/Views/Conversation/ConversationMessageRow.swift +++ b/Monal/another.im/Views/Conversation/ConversationMessageRow.swift @@ -2,24 +2,25 @@ import Foundation import SwiftUI struct ConversationMessageRow: View { - // @EnvironmentObject var messages: MessagesStore + @EnvironmentObject var chatWrapper: MonalChatWrapper let message: Message + @State private var offset: CGSize = .zero var body: some View { VStack(spacing: 0) { HStack(spacing: 0) { - if isOutgoing() { + if !message.isInbound { Spacer() - // MessageAttr(message: message) - // .padding(.trailing, 4) + MessageAttr(message: message) + .padding(.trailing, 4) } - // ConversationMessageContainer(message: message, isOutgoing: isOutgoing()) - // .background(isOutgoing() ? Color.Material.Shape.alternate : Color.Material.Shape.white) - // .clipShape(ConversationMessageBubble(isOutgoing: isOutgoing())) - if !isOutgoing() { - // MessageAttr(message: message) - // .padding(.leading, 4) + ConversationMessageContainer(message: message) + .background(message.isInbound ? Color.Material.Shape.white : Color.Material.Shape.alternate) + .clipShape(ConversationMessageBubble(isOutgoing: !message.isInbound)) + if message.isInbound { + MessageAttr(message: message) + .padding(.leading, 4) Spacer() } } @@ -61,11 +62,6 @@ struct ConversationMessageRow: View { .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color.Material.Background.light) } - - private func isOutgoing() -> Bool { - true - // message.from == messages.roster.bareJid - } } struct ConversationMessageBubble: Shape { diff --git a/Monal/another.im/XMPP/MonalWrapperModels.swift b/Monal/another.im/XMPP/MonalWrapperModels.swift index eaeb0ed..9398c97 100644 --- a/Monal/another.im/XMPP/MonalWrapperModels.swift +++ b/Monal/another.im/XMPP/MonalWrapperModels.swift @@ -88,6 +88,7 @@ struct Message: Identifiable { let dbId: Int let timestamp: Date let body: String + let isInbound: Bool var id: String { "\(accountId)|\(dbId)" @@ -100,5 +101,6 @@ struct Message: Identifiable { self.dbId = dbId timestamp = obj.timestamp body = obj.messageText + isInbound = obj.inbound } }