summaryrefslogtreecommitdiff
path: root/JuickNext/View/MessageView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'JuickNext/View/MessageView.swift')
-rw-r--r--JuickNext/View/MessageView.swift43
1 files changed, 43 insertions, 0 deletions
diff --git a/JuickNext/View/MessageView.swift b/JuickNext/View/MessageView.swift
new file mode 100644
index 0000000..398978b
--- /dev/null
+++ b/JuickNext/View/MessageView.swift
@@ -0,0 +1,43 @@
+//
+// MessageView.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import SwiftUI
+
+struct MessageView: View {
+ var message: Message
+ var body: some View {
+ VStack(alignment: .leading) {
+ HStack {
+ LoadableImageView(with: message.user.avatar ?? "")
+ .frame(width: 48, height: 48, alignment: .center)
+ Text(message.user.name)
+ .font(.headline)
+ .foregroundColor(.accentColor)
+ }
+ message.tags.map {
+ Text($0.joined(separator: ", "))
+ .font(.subheadline)
+ .italic()
+ .foregroundColor(.secondary)
+ }
+ Text(message.text ?? "")
+ .font(.body)
+ .padding()
+ message.attachment.map {
+ LoadableImageView(with: $0.url).scaledToFit()
+ }
+ }
+ }
+}
+
+struct MessageView_Previews: PreviewProvider {
+ static let msg = Message(id: 0, user: User(id: 0, name: "ugnich"), text: "Lorem ipsum")
+ static var previews: some View {
+ MessageView(message: msg)
+ }
+}