瀏覽代碼

header cell as tableHeader - now happy

nayooti 5 年之前
父節點
當前提交
d79b10173d

+ 4 - 33
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -59,11 +59,11 @@ class ContactDetailViewController: UITableViewController {
 
     // MARK: - setup and configuration
     private func configureTableView() {
-        tableView.estimatedSectionHeaderHeight = 20 // needed to trigger heighForHeaderInSection
-        tableView.sectionHeaderHeight = UITableView.automaticDimension
-        // tableView.estimatedSectionFooterHeight = 0 // needed to trigger heighForFooterInSection
         tableView.register(ActionCell.self, forCellReuseIdentifier: ActionCell.reuseIdentifier)
         tableView.register(ContactCell.self, forCellReuseIdentifier: ContactCell.reuseIdentifier)
+        headerCell.frame = CGRect(0, 0, tableView.frame.width, ContactCell.cellHeight)
+        tableView.tableHeaderView = headerCell
+
     }
 
     // MARK: - UITableViewDatasource, UITableViewDelegate
@@ -78,8 +78,6 @@ class ContactDetailViewController: UITableViewController {
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cellType = viewModel.typeFor(section: indexPath.section)
         switch cellType {
-        case .contact:
-            return headerCell
         case .blockContact:
             return blockContactCell
         case .startChat:
@@ -104,8 +102,6 @@ class ContactDetailViewController: UITableViewController {
         case .sharedChats:
             let chatId = viewModel.getSharedChatIdAt(indexPath: indexPath)
             coordinator?.showChat(chatId: chatId)
-        case .contact:
-            break
         }
     }
 
@@ -114,36 +110,11 @@ class ContactDetailViewController: UITableViewController {
         switch type {
         case .blockContact, .startChat:
             return 44
-        case .sharedChats, .contact:
+        case .sharedChats:
             return ContactCell.cellHeight
         }
     }
 
-    /*
-    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
-        let type = viewModel.typeFor(section: section)
-        switch type {
-        case .startChat:
-            return CGFloat.leastNonzeroMagnitude
-        default:
-            return CGFloat.leastNonzeroMagnitude
-        }
-    }
-     */
-
-    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
-        let type = viewModel.typeFor(section: section)
-        switch type {
-        case .contact:
-            return 0
-//        case .blockContact:
-//            return 20
-        default:
-            return 20
-        }
-    }
-
-
     override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
         return viewModel.titleFor(section: section)
     }

+ 2 - 3
deltachat-ios/ViewModel/ContactDetailViewModel.swift

@@ -15,7 +15,6 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
 
     let context: DcContext
     enum SectionType {
-        case contact
         case startChat
         case sharedChats
         case blockContact
@@ -27,7 +26,7 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
     private let sharedChats: DcChatlist
     private let startChatOption: Bool
 
-    private var sections: [SectionType] = [.contact]
+    private var sections: [SectionType] = []
 
     init(contactId: Int, startChatOption: Bool, context: DcContext) {
         self.context = context
@@ -56,7 +55,7 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
     func numberOfRowsInSection(_ section: Int) -> Int {
         switch sections[section] {
         case .sharedChats: return sharedChats.length
-        case .contact, .blockContact, .startChat: return 1
+        case .blockContact, .startChat: return 1
         }
     }