|
@@ -15,8 +15,9 @@ class ContactCell: UITableViewCell {
|
|
|
private let imgSize: CGFloat = 20
|
|
|
|
|
|
lazy var toplineStackView: UIStackView = {
|
|
|
- let stackView = UIStackView(arrangedSubviews: [titleLabel, timeLabel])
|
|
|
+ let stackView = UIStackView(arrangedSubviews: [titleLabel, pinnedIndicator, timeLabel])
|
|
|
stackView.axis = .horizontal
|
|
|
+ stackView.spacing = 4
|
|
|
return stackView
|
|
|
}()
|
|
|
|
|
@@ -45,6 +46,17 @@ class ContactCell: UITableViewCell {
|
|
|
return label
|
|
|
}()
|
|
|
|
|
|
+ private let pinnedIndicator: UIImageView = {
|
|
|
+ let view = UIImageView()
|
|
|
+ view.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ view.heightAnchor.constraint(equalToConstant: 16).isActive = true
|
|
|
+ view.widthAnchor.constraint(equalToConstant: 16).isActive = true
|
|
|
+ view.tintColor = UIColor(hexString: "848ba7")
|
|
|
+ view.image = #imageLiteral(resourceName: "pinned_chatlist").withRenderingMode(.alwaysTemplate)
|
|
|
+ view.isHidden = true
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+
|
|
|
private let timeLabel: UILabel = {
|
|
|
let label = UILabel()
|
|
|
label.font = UIFont.systemFont(ofSize: 14)
|
|
@@ -159,14 +171,16 @@ class ContactCell: UITableViewCell {
|
|
|
avatar.setName(name)
|
|
|
}
|
|
|
|
|
|
- func setStatusIndicators(unreadCount: Int, status: Int, archived: Bool) {
|
|
|
- if archived {
|
|
|
+ func setStatusIndicators(unreadCount: Int, status: Int, visibility: Int32) {
|
|
|
+ if visibility==DC_CHAT_VISIBILITY_ARCHIVED {
|
|
|
+ pinnedIndicator.isHidden = true
|
|
|
unreadMessageCounter.isHidden = true
|
|
|
deliveryStatusIndicator.isHidden = true
|
|
|
archivedIndicator.isHidden = false
|
|
|
} else if unreadCount > 0 {
|
|
|
unreadMessageCounter.setCount(unreadCount)
|
|
|
|
|
|
+ pinnedIndicator.isHidden = !(visibility==DC_CHAT_VISIBILITY_PINNED)
|
|
|
unreadMessageCounter.isHidden = false
|
|
|
deliveryStatusIndicator.isHidden = true
|
|
|
archivedIndicator.isHidden = true
|
|
@@ -188,6 +202,7 @@ class ContactCell: UITableViewCell {
|
|
|
deliveryStatusIndicator.image = nil
|
|
|
}
|
|
|
|
|
|
+ pinnedIndicator.isHidden = !(visibility==DC_CHAT_VISIBILITY_PINNED)
|
|
|
unreadMessageCounter.isHidden = true
|
|
|
deliveryStatusIndicator.isHidden = deliveryStatusIndicator.image == nil ? true : false
|
|
|
archivedIndicator.isHidden = true
|
|
@@ -239,14 +254,14 @@ class ContactCell: UITableViewCell {
|
|
|
}
|
|
|
setVerified(isVerified: chat.isVerified)
|
|
|
setTimeLabel(chatData.summary.timestamp)
|
|
|
- setStatusIndicators(unreadCount: chatData.unreadMessages, status: chatData.summary.state, archived: chat.isArchived)
|
|
|
+ setStatusIndicators(unreadCount: chatData.unreadMessages, status: chatData.summary.state, visibility: chat.visibility)
|
|
|
|
|
|
case .CONTACT(let contactData):
|
|
|
let contact = DcContact(id: contactData.contactId)
|
|
|
titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
|
|
|
avatar.setName(cellViewModel.title)
|
|
|
avatar.setColor(contact.color)
|
|
|
- setStatusIndicators(unreadCount: 0, status: 0, archived: false)
|
|
|
+ setStatusIndicators(unreadCount: 0, status: 0, visibility: 0)
|
|
|
}
|
|
|
}
|
|
|
}
|