Преглед изворни кода

set chat title bold in chat list if there are unread messages

cyberta пре 5 година
родитељ
комит
f2d8400573
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      deltachat-ios/Controller/ChatListController.swift

+ 7 - 2
deltachat-ios/Controller/ChatListController.swift

@@ -142,8 +142,13 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
 
         let chat = DcChat(id: chatId)
         let chat = DcChat(id: chatId)
         let summary = chatList.getSummary(index: row)
         let summary = chatList.getSummary(index: row)
+        let unreadMessages = dcContext.getUnreadMessages(chatId: chatId)
+
+        cell.nameLabel.attributedText = (unreadMessages > 0) ?
+            NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .bold) ]) :
+            NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .medium) ])
+
 
 
-        cell.nameLabel.text = chat.name
         if let img = chat.profileImage {
         if let img = chat.profileImage {
             cell.resetBackupImage()
             cell.resetBackupImage()
             cell.setImage(img)
             cell.setImage(img)
@@ -163,7 +168,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
 
         cell.emailLabel.text = result
         cell.emailLabel.text = result
         cell.setTimeLabel(summary.timestamp)
         cell.setTimeLabel(summary.timestamp)
-        cell.setUnreadMessageCounter(dcContext.getUnreadMessages(chatId: chatId))
+        cell.setUnreadMessageCounter(unreadMessages)
         cell.setDeliveryStatusIndicator(summary.state)
         cell.setDeliveryStatusIndicator(summary.state)
 
 
         return cell
         return cell