Parcourir la source

added title at share chats section

nayooti il y a 5 ans
Parent
commit
bde80b61c4

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

@@ -95,7 +95,7 @@ class ContactDetailViewController: UITableViewController {
         if section == 0 {
             return ContactDetailHeader.cellHeight
         }
-        return 0
+        return 20
     }
 
     override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
@@ -107,6 +107,10 @@ class ContactDetailViewController: UITableViewController {
             return ContactCell.cellHeight
         }
     }
+
+    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+        return viewModel.titleFor(section: section)
+    }
     
     override func tableView(_: UITableView, viewForHeaderInSection section: Int) -> UIView? {
         if section == 0 {

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

@@ -9,13 +9,14 @@ protocol ContactDetailViewModelProtocol {
     func update(actionCell: ActionCell, section: Int)
     func update(sharedChatCell: ContactCell, row index: Int)
     func getSharedChatIdAt(indexPath: IndexPath) -> Int
+    func titleFor(section: Int) -> String?
 }
 
 class ContactDetailViewModel: ContactDetailViewModelProtocol {
 
-
     let context: DcContext
     enum SectionType {
+        case contact
         case startChat
         case sharedChats
         case blockContact
@@ -56,7 +57,7 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
     func numberOfRowsInSection(_ section: Int) -> Int {
         switch sections[section] {
         case .sharedChats: return sharedChats.length
-        case .blockContact, .startChat: return 1
+        case .contact, .blockContact, .startChat: return 1
         }
     }
 
@@ -102,4 +103,10 @@ class ContactDetailViewModel: ContactDetailViewModelProtocol {
         cell.updateCell(cellViewModel: cellViewModel)
     }
 
+    func titleFor(section: Int) -> String? {
+        if sections[section] == .sharedChats {
+            String.localized("menu_shared_chats")
+        }
+        return nil
+      }
 }