blob: ffd0f19fa5da396f9543bf321a7891c1eb520645 (
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
44
45
46
47
48
49
50
51
|
//
// MessageView.swift
// tst
//
// Created by Vitaly Takmazov on 10.12.2019.
// Copyright © 2019 com.juick. All rights reserved.
//
import SwiftUI
import Atributika
struct MessageView: View {
var message: Message
let all = Style.font(UIFont.preferredFont(forTextStyle: .body))
let link = Style("a")
.foregroundColor(.blue, .normal)
.foregroundColor(.brown, .highlighted)
let configureLabel: ((AttributedLabel) -> Void) = { label in
label.numberOfLines = 0
label.textColor = .label
}
var body: some View {
VStack(alignment: .leading) {
HStack {
LoadableImageView(with: message.user.avatar ?? "")
.frame(width: 48, height: 48, alignment: .center)
Text(message.user.uname)
.font(.headline)
.foregroundColor(.accentColor)
.fixedSize(horizontal: true, vertical: false)
}
AttributedLabelView(attributedText: (message.text ?? "")
.style(tags: link)
.styleHashtags(link)
.styleMentions(link)
.styleLinks(link)
.styleAll(all), configureLabel: configureLabel)
.fixedSize(horizontal: true, vertical: true)
message.attachment.map {
LoadableImageView(with: $0.url).scaledToFit()
}
}
}
}
struct MessageView_Previews: PreviewProvider {
static let msg = Message()
static var previews: some View {
MessageView(message: msg)
}
}
|