summaryrefslogtreecommitdiff
path: root/JuickNext/View/MessageView.swift
blob: 398978b4d93debb810442eb859c2673c56ac825a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)
    }
}