Browse Source

code cleaning

nayooti 5 years ago
parent
commit
e4206c206a

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

@@ -4,10 +4,12 @@ class ChatListController: UIViewController {
     weak var coordinator: ChatListCoordinator?
     private let viewModel: ChatListViewModelProtocol
 
+    private let chatCellReuseIdentifier = "ChatCell"
     private let archivedCellReuseIdentifier = "ArchiveCell"
     private let deadDropCellReuseIdentifier = "DeaddropCell"
     private let contactCellReuseIdentifier = "ContactCell"
 
+
     private lazy var searchController: UISearchController = {
         let searchController = UISearchController(searchResultsController: nil)
         searchController.searchResultsUpdater = viewModel
@@ -20,6 +22,7 @@ class ChatListController: UIViewController {
     private lazy var chatTable: UITableView = {
         let chatTable = UITableView(frame: .zero, style: .grouped)
         chatTable.register(UITableViewCell.self, forCellReuseIdentifier: archivedCellReuseIdentifier)
+        chatTable.register(AvatarTextCell.self, forCellReuseIdentifier: chatCellReuseIdentifier)
         chatTable.register(AvatarTextCell.self, forCellReuseIdentifier: deadDropCellReuseIdentifier)
         chatTable.register(AvatarTextCell.self, forCellReuseIdentifier: contactCellReuseIdentifier)
         chatTable.dataSource = self
@@ -175,12 +178,13 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
             }
 
             // default chatCells
-            let chatCell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as! AvatarTextCell
+            let chatCell = tableView.dequeueReusableCell(withIdentifier: chatCellReuseIdentifier, for: indexPath) as! AvatarTextCell
             let cellViewModel = viewModel.getCellViewModelFor(indexPath: indexPath)
 
             update(avatarCell: chatCell, cellViewModel: cellViewModel)
             return chatCell
         case .CONTACT(let contactData):
+            // will be shown when search is active
             let contactCell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as! AvatarTextCell
             update(avatarCell: contactCell, cellViewModel: cellViewModel)
             return contactCell

+ 3 - 3
deltachat-ios/View/AvatarTextCell.swift

@@ -1,6 +1,6 @@
 import UIKit
 
-protocol ContactCellDelegate: class {
+protocol AvatarTextCellDelegate: class {
     func onAvatarTapped(at index: Int)
 }
 
@@ -9,7 +9,7 @@ class AvatarTextCell: UITableViewCell {
 
     static let cellHeight: CGFloat = 74.5
 
-    weak var delegate: ContactCellDelegate?
+    weak var delegate: AvatarTextCellDelegate?
     var rowIndex = -1
     private let badgeSize: CGFloat = 54
     private let imgSize: CGFloat = 20
@@ -196,6 +196,7 @@ class AvatarTextCell: UITableViewCell {
         fatalError("init(coder:) has not been implemented")
     }
 
+    // use this to update cells in cellForRowAt -
     func updateCell(cellViewModel: AvatarCellViewModel) {
 
         // subtitle
@@ -225,7 +226,6 @@ class AvatarTextCell: UITableViewCell {
 
         case .CONTACT(let contactData):
             nameLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: nameLabel.font.pointSize)
-
         }
     }