wip
This commit is contained in:
parent
a59d3bbeb7
commit
13ace49560
|
@ -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)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue