// // 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) } }