浏览代码

Merge pull request #453 from deltachat/fix-deaddrop-layout

fix deaddrop layout
cyBerta 5 年之前
父节点
当前提交
f68133524b
共有 2 个文件被更改,包括 32 次插入7 次删除
  1. 31 7
      deltachat-ios/Controller/ChatListController.swift
  2. 1 0
      deltachat-ios/Helper/Colors.swift

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

@@ -154,7 +154,9 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
         }
 
         let cell: ContactCell
-        if let c = tableView.dequeueReusableCell(withIdentifier: "ChatCell") as? ContactCell {
+        if chatId == DC_CHAT_ID_DEADDROP {
+            cell = getDeaddropCell(tableView)
+        } else if let c = tableView.dequeueReusableCell(withIdentifier: "ChatCell") as? ContactCell {
             cell = c
         } else {
             cell = ContactCell(style: .default, reuseIdentifier: "ChatCell")
@@ -168,13 +170,23 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
             NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .bold) ]) :
             NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .medium) ])
 
-
-        if let img = chat.profileImage {
-            cell.resetBackupImage()
-            cell.setImage(img)
+        if chatId == DC_CHAT_ID_DEADDROP {
+            let contact = DcContact(id: DcMsg(id: chatList.getMsgId(index: row)).fromContactId)
+            if let img = contact.profileImage {
+                cell.resetBackupImage()
+                cell.setImage(img)
+            } else {
+                cell.setBackupImage(name: contact.name, color: contact.color)
+            }
         } else {
-            cell.setBackupImage(name: chat.name, color: chat.color)
+            if let img = chat.profileImage {
+                cell.resetBackupImage()
+                cell.setImage(img)
+            } else {
+                cell.setBackupImage(name: chat.name, color: chat.color)
+            }
         }
+
         cell.setVerified(isVerified: chat.isVerified)
 
         let result1 = summary.text1 ?? ""
@@ -230,7 +242,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
         }
 
         let chatId = chatList.getChatId(index: row)
-        if chatId==DC_CHAT_ID_ARCHIVED_LINK {
+        if chatId==DC_CHAT_ID_ARCHIVED_LINK || chatId==DC_CHAT_ID_DEADDROP {
             return []
             // returning nil may result in a default delete action,
             // see https://forums.developer.apple.com/thread/115030
@@ -253,6 +265,18 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
         return [archive, delete]
     }
 
+    func getDeaddropCell(_ tableView: UITableView) -> ContactCell {
+        let deaddropCell: ContactCell
+        if let cell = tableView.dequeueReusableCell(withIdentifier: "DeaddropCell") as? ContactCell {
+            deaddropCell = cell
+        } else {
+            deaddropCell = ContactCell(style: .default, reuseIdentifier: "DeaddropCell")
+        }
+        deaddropCell.backgroundColor = DcColors.deaddropBackground
+        deaddropCell.contentView.backgroundColor = DcColors.deaddropBackground
+        return deaddropCell
+    }
+
     func getArchiveCell(_ tableView: UITableView) -> UITableViewCell {
         let archiveCell: UITableViewCell
         if let cell = tableView.dequeueReusableCell(withIdentifier: "ArchiveCell") {

+ 1 - 0
deltachat-ios/Helper/Colors.swift

@@ -17,6 +17,7 @@ struct DcColors {
     static let placeholderColor = UIColor.themeColor(light: UIColor(red: 0.6, green: 0.6, blue: 0.6, alpha: 1),
                                                      dark: UIColor(red: 0.4, green: 0.4, blue: 0.4, alpha: 1))
     static let systemMessageBackgroundColor = UIColor.themeColor(light: UIColor.rgb(red: 248, green: 248, blue: 248), dark: UIColor(white: 0.2, alpha: 0.5))
+    static let deaddropBackground = UIColor.themeColor(light: UIColor.init(hexString: "ebebec"), dark: UIColor.init(hexString: "1a1a1c"))
 }
 
 enum SystemColor {