Kordophone client for iOS and macOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

import SwiftUI
import KordophoneKit
struct MessageView : View {
var message: Message
var attachmentData: Data?
var body: some View {
HStack {
VStack {
attachmentData.map {
Image(data: $0)
}
Text(message.text)
}
.multilineTextAlignment(.leading)
}
.padding()
.background(Color.blue)
.padding()
}
}
struct MessageViewWrapper : View {
var message: Message
@State private var attachmentData: Data?
@EnvironmentObject private var connection: Connection
var body: some View {
MessageView(message: message, attachmentData: attachmentData)
.onChange(of: message) { _ in
print(message)
if let attachment = message.attachments.first {
print(attachment)
Task {
let data = await connection.data(for: attachment)
DispatchQueue.main.async {
print(data)
self.attachmentData = data
}
}
}
}
}
}