Przeglądaj źródła

remove unused method in ChatListController and use an ActionCell for the archive item

cyberta 5 lat temu
rodzic
commit
a296afda08
1 zmienionych plików z 7 dodań i 22 usunięć
  1. 7 22
      deltachat-ios/Controller/ChatListController.swift

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

@@ -22,6 +22,11 @@ class ChatListController: UITableViewController {
         return searchController
         return searchController
     }()
     }()
 
 
+    private lazy var archiveCell: ActionCell = {
+        let actionCell = ActionCell()
+        return actionCell
+    }()
+
     private lazy var newButton: UIBarButtonItem = {
     private lazy var newButton: UIBarButtonItem = {
         let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.compose, target: self, action: #selector(didPressNewChat))
         let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.compose, target: self, action: #selector(didPressNewChat))
         button.tintColor = DcColors.primary
         button.tintColor = DcColors.primary
@@ -39,14 +44,6 @@ class ChatListController: UITableViewController {
         return label
         return label
     }()
     }()
 
 
-    func getArchiveCell(title: String) -> UITableViewCell {
-        let cell = UITableViewCell()
-        cell.textLabel?.textColor = .systemBlue
-        cell.textLabel?.text = title
-        cell.textLabel?.textAlignment = .center
-        return cell
-    }
-
     init(dcContext: DcContext, viewModel: ChatListViewModelProtocol) {
     init(dcContext: DcContext, viewModel: ChatListViewModelProtocol) {
         self.viewModel = viewModel
         self.viewModel = viewModel
         self.dcContext = dcContext
         self.dcContext = dcContext
@@ -208,7 +205,8 @@ class ChatListController: UITableViewController {
         case .chat(let chatData):
         case .chat(let chatData):
             let chatId = chatData.chatId
             let chatId = chatData.chatId
             if chatId == DC_CHAT_ID_ARCHIVED_LINK {
             if chatId == DC_CHAT_ID_ARCHIVED_LINK {
-                return getArchiveCell(title: dcContext.getChat(chatId: chatId).name)
+                archiveCell.actionTitle = dcContext.getChat(chatId: chatId).name
+                return archiveCell
             } else if let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as? ContactCell {
             } else if let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as? ContactCell {
                 // default chatCell
                 // default chatCell
                 chatCell.updateCell(cellViewModel: cellData)
                 chatCell.updateCell(cellViewModel: cellData)
@@ -325,19 +323,6 @@ class ChatListController: UITableViewController {
         }
         }
     }
     }
 
 
-    func getArchiveCell(_ tableView: UITableView, title: String) -> UITableViewCell {
-        let archiveCell: UITableViewCell
-        if let cell = tableView.dequeueReusableCell(withIdentifier: "ArchiveCell") {
-            archiveCell = cell
-        } else {
-            archiveCell = UITableViewCell(style: .default, reuseIdentifier: "ArchiveCell")
-        }
-        archiveCell.textLabel?.textAlignment = .center
-        archiveCell.textLabel?.text = title
-        archiveCell.textLabel?.textColor = UIColor.systemBlue
-        return archiveCell
-    }
-
     // MARK: - alerts
     // MARK: - alerts
     private func showDeleteChatConfirmationAlert(chatId: Int) {
     private func showDeleteChatConfirmationAlert(chatId: Int) {
         let alert = UIAlertController(
         let alert = UIAlertController(