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.

46 lines
1.2 KiB

3 years ago
import SwiftUI
import KordophoneKit
struct MessageView : View {
var message: Message
1 year ago
var attachmentData: Data?
3 years ago
var body: some View {
HStack {
1 year ago
VStack {
attachmentData.map {
Image(data: $0)
}
Text(message.text)
}
.multilineTextAlignment(.leading)
3 years ago
}
.padding()
.background(Color.blue)
.padding()
}
}
1 year ago
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
}
}
}
}
}
}