This commit is contained in:
Woit 2024-11-25 13:02:36 +01:00
parent a59d3bbeb7
commit 13ace49560
3 changed files with 43 additions and 39 deletions

View file

@ -4,11 +4,16 @@ import QuickLook
import SwiftUI import SwiftUI
struct ConversationMessageContainer: View { struct ConversationMessageContainer: View {
// let message: Message let message: Message
let isOutgoing: Bool
var body: some View { 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 { // if let msgText = message.body, msgText.isLocation {
// EmbededMapView(location: msgText.getLatLon) // EmbededMapView(location: msgText.getLatLon)
// } else if let msgText = message.body, msgText.isContact { // } else if let msgText = message.body, msgText.isContact {
@ -26,14 +31,16 @@ struct ConversationMessageContainer: View {
} }
struct MessageAttr: View { struct MessageAttr: View {
// let message: Message let message: Message
var body: some View { var body: some View {
// VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
// Text(message.date, style: .time) Text(message.timestamp, style: .time)
// .font(.sub2) .font(.sub2)
// .foregroundColor(.Material.Shape.separator) .foregroundColor(.Material.Shape.separator)
// Spacer() Spacer()
// message state commented for now
// if message.status == .error { // if message.status == .error {
// Image(systemName: "exclamationmark.circle") // Image(systemName: "exclamationmark.circle")
// .font(.body3) // .font(.body3)
@ -47,8 +54,7 @@ struct MessageAttr: View {
// .font(.body3) // .font(.body3)
// .foregroundColor(.Material.Shape.separator) // .foregroundColor(.Material.Shape.separator)
// } // }
// } }
Text("dumb")
} }
} }

View file

@ -2,24 +2,25 @@ import Foundation
import SwiftUI import SwiftUI
struct ConversationMessageRow: View { struct ConversationMessageRow: View {
// @EnvironmentObject var messages: MessagesStore @EnvironmentObject var chatWrapper: MonalChatWrapper
let message: Message let message: Message
@State private var offset: CGSize = .zero @State private var offset: CGSize = .zero
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
HStack(spacing: 0) { HStack(spacing: 0) {
if isOutgoing() { if !message.isInbound {
Spacer() Spacer()
// MessageAttr(message: message) MessageAttr(message: message)
// .padding(.trailing, 4) .padding(.trailing, 4)
} }
// ConversationMessageContainer(message: message, isOutgoing: isOutgoing()) ConversationMessageContainer(message: message)
// .background(isOutgoing() ? Color.Material.Shape.alternate : Color.Material.Shape.white) .background(message.isInbound ? Color.Material.Shape.white : Color.Material.Shape.alternate)
// .clipShape(ConversationMessageBubble(isOutgoing: isOutgoing())) .clipShape(ConversationMessageBubble(isOutgoing: !message.isInbound))
if !isOutgoing() { if message.isInbound {
// MessageAttr(message: message) MessageAttr(message: message)
// .padding(.leading, 4) .padding(.leading, 4)
Spacer() Spacer()
} }
} }
@ -61,11 +62,6 @@ struct ConversationMessageRow: View {
.frame(maxWidth: .infinity, maxHeight: .infinity) .frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.Material.Background.light) .background(Color.Material.Background.light)
} }
private func isOutgoing() -> Bool {
true
// message.from == messages.roster.bareJid
}
} }
struct ConversationMessageBubble: Shape { struct ConversationMessageBubble: Shape {

View file

@ -88,6 +88,7 @@ struct Message: Identifiable {
let dbId: Int let dbId: Int
let timestamp: Date let timestamp: Date
let body: String let body: String
let isInbound: Bool
var id: String { var id: String {
"\(accountId)|\(dbId)" "\(accountId)|\(dbId)"
@ -100,5 +101,6 @@ struct Message: Identifiable {
self.dbId = dbId self.dbId = dbId
timestamp = obj.timestamp timestamp = obj.timestamp
body = obj.messageText body = obj.messageText
isInbound = obj.inbound
} }
} }