diff options
author | Vitaly Takmazov | 2023-05-13 18:17:06 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-05-14 01:15:35 +0300 |
commit | 312afec3c4fd7f0f51c82c6dc067bc5c89a4c453 (patch) | |
tree | 9f0f0ea47024e3b2cd3f797346db3a4a047e0709 /Juick/Views/BubbleMessageCell.swift | |
parent | ea7006ad743375855fab434f4e6e9caf4274bfb5 (diff) |
BubbleMessageCell conversion
Diffstat (limited to 'Juick/Views/BubbleMessageCell.swift')
-rw-r--r-- | Juick/Views/BubbleMessageCell.swift | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Juick/Views/BubbleMessageCell.swift b/Juick/Views/BubbleMessageCell.swift new file mode 100644 index 0000000..fcd9381 --- /dev/null +++ b/Juick/Views/BubbleMessageCell.swift @@ -0,0 +1,35 @@ +// +// BubbleMessageCell.swift +// Juick +// +// Created by Vitaly Takmazov on 13.05.2023. +// Copyright © 2023 com.juick. All rights reserved. +// + +import UIKit + +@objc +class BubbleMessageCell: UITableViewCell { + @IBOutlet weak var avatarView: UIImageView! + @IBOutlet weak var unreadMarker: UILabel! + @IBOutlet weak var name: UILabel! + @IBOutlet weak var message: UITextView! + + @objc + func configure(message: Message, isMe: Bool) { + self.message.backgroundColor = isMe ? UIColor(named: "Title") : UIColor(named: "Chat") + self.message.textColor = isMe ? UIColor.white : UIColor(named: "Text") + self.message.dataDetectorTypes = .all + self.message.tintColor = isMe ? UIColor.white : UIColor(named: "Title") + self.name.text = message.user.uname + self.message.text = message.text + self.unreadMarker.text = "" + AppDelegate.shared().api.fetchImage(with: URL(string: message.user.avatar)) { data in + if let imageData = data { + UIView.transition(with: self.avatarView, duration: 0.3, options: .transitionCrossDissolve, animations: { + self.avatarView.image = UIImage(data: imageData) + }) + } + } + } +} |