summaryrefslogtreecommitdiff
path: root/Juick/Views/ConversationCell.swift
blob: b8fe113bab844fed2c694c49cd1bb97056e48b4e (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
//
//  ConversationCell.swift
//  Juick
//
//  Created by Vitaly Takmazov on 13.05.2023.
//  Copyright © 2023 com.juick. All rights reserved.
//

import UIKit

@objc class ConversationCell : UITableViewCell {
    @IBOutlet weak var chatName: UILabel!
    @IBOutlet weak var lastMessage: UILabel!
    @IBOutlet weak var unreadMarker: UILabel!
    @IBOutlet weak var avatar: UIImageView!
    
    @objc func configure(chat: Chat) {
        self.chatName.textColor = UIColor(named: "Title")
        self.chatName.text = chat.uname
        self.lastMessage.text = chat.lastMessageText
        self.unreadMarker.isHidden = false
        AppDelegate.shared().api.fetchImage(with: URL(string: chat.avatar)) { data in
            if let imageData = data {
                UIView.transition(with: self.avatar, duration: 0.3, options: .transitionCrossDissolve, animations: {
                    self.avatar.image = UIImage(data: imageData)
                })
            }
        }
    }
}