import UIKit final class EPMessageListVC: EPBaseListViewController { override func viewDidLoad() { super.viewDidLoad() simulateItems(8) } } // MARK: - Cell final class EPMessageCell: UITableViewCell { private let avatar = UIImageView() private let nameLabel = UILabel() private let subtitleLabel = UILabel() private let timeLabel = UILabel() private let unreadView = UILabel() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() } required init?(coder: NSCoder) { super.init(coder: coder); setup() } private func setup() { selectionStyle = .none backgroundColor = .clear avatar.contentMode = .scaleAspectFill avatar.layer.cornerRadius = 24 avatar.layer.masksToBounds = true avatar.image = UIImage(named: "pi_login_new_logo") nameLabel.font = .systemFont(ofSize: 20, weight: .semibold) nameLabel.textColor = .white nameLabel.text = "Momoyy" subtitleLabel.font = .systemFont(ofSize: 16) subtitleLabel.textColor = UIColor.white.withAlphaComponent(0.6) subtitleLabel.text = "Nice to meet you" timeLabel.font = .systemFont(ofSize: 14) timeLabel.textColor = UIColor.white.withAlphaComponent(0.5) timeLabel.text = "11:03" unreadView.backgroundColor = UIColor.systemRed unreadView.textColor = .white unreadView.font = .systemFont(ofSize: 12, weight: .bold) unreadView.textAlignment = .center unreadView.layer.cornerRadius = 12 unreadView.layer.masksToBounds = true unreadView.text = "99+" contentView.addSubview(avatar) contentView.addSubview(nameLabel) contentView.addSubview(subtitleLabel) contentView.addSubview(timeLabel) contentView.addSubview(unreadView) avatar.translatesAutoresizingMaskIntoConstraints = false nameLabel.translatesAutoresizingMaskIntoConstraints = false subtitleLabel.translatesAutoresizingMaskIntoConstraints = false timeLabel.translatesAutoresizingMaskIntoConstraints = false unreadView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ avatar.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16), avatar.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), avatar.widthAnchor.constraint(equalToConstant: 48), avatar.heightAnchor.constraint(equalToConstant: 48), nameLabel.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12), nameLabel.topAnchor.constraint(equalTo: avatar.topAnchor, constant: -2), subtitleLabel.leadingAnchor.constraint(equalTo: nameLabel.leadingAnchor), subtitleLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 6), timeLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16), timeLabel.topAnchor.constraint(equalTo: nameLabel.topAnchor), unreadView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16), unreadView.centerYAnchor.constraint(equalTo: subtitleLabel.centerYAnchor), unreadView.widthAnchor.constraint(greaterThanOrEqualToConstant: 40), unreadView.heightAnchor.constraint(equalToConstant: 24) ]) } }