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

add pinned icon to chatlist

B. Petersen пре 5 година
родитељ
комит
a237be05d0

+ 23 - 0
deltachat-ios/Assets.xcassets/pinned_chatlist.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "pinned_chatlist.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinned_chatlist_2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "pinned_chatlist_3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
deltachat-ios/Assets.xcassets/pinned_chatlist.imageset/pinned_chatlist.png


BIN
deltachat-ios/Assets.xcassets/pinned_chatlist.imageset/pinned_chatlist_2x.png


BIN
deltachat-ios/Assets.xcassets/pinned_chatlist.imageset/pinned_chatlist_3x.png


+ 1 - 1
deltachat-ios/Controller/ChatListController.swift

@@ -216,7 +216,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
         cell.subtitleLabel.text = result
         cell.setTimeLabel(summary.timestamp)
-        cell.setStatusIndicators(unreadCount: unreadMessages, status: summary.state, archived: showArchive)
+        cell.setStatusIndicators(unreadCount: unreadMessages, status: summary.state, visibility: chat.visibility)
         return cell
     }
 

+ 20 - 5
deltachat-ios/View/ContactCell.swift

@@ -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)
         }
     }
 }