فهرست منبع

tweak GroupChatDetailViewController for resizing cells

cyberta 5 سال پیش
والد
کامیت
678461c1f6
1فایلهای تغییر یافته به همراه17 افزوده شده و 16 حذف شده
  1. 17 16
      deltachat-ios/Controller/GroupChatDetailViewController.swift

+ 17 - 16
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -131,16 +131,16 @@ class GroupChatDetailViewController: UIViewController {
         return cell
     }()
 
-    private lazy var galleryCell: UITableViewCell = {
-        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
-        cell.textLabel?.text = String.localized("gallery")
+    private lazy var galleryCell: BasicCell = {
+        let cell = BasicCell(style: .default, reuseIdentifier: nil)
+        cell.title.text = String.localized("gallery")
         cell.accessoryType = .disclosureIndicator
         return cell
     }()
 
-    private lazy var documentsCell: UITableViewCell = {
-        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
-        cell.textLabel?.text = String.localized("documents")
+    private lazy var documentsCell: BasicCell = {
+        let cell = BasicCell(style: .default, reuseIdentifier: nil)
+        cell.title.text = String.localized("documents")
         cell.accessoryType = .disclosureIndicator
         return cell
     }()
@@ -183,6 +183,13 @@ class GroupChatDetailViewController: UIViewController {
         updateHeader()
     }
 
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        if previousTraitCollection?.preferredContentSizeCategory !=
+            traitCollection.preferredContentSizeCategory {
+            groupHeader.frame = CGRect(0, 0, tableView.frame.width, ContactCell.cellHeight)
+        }
+    }
+
     // MARK: - update
     private func updateGroupMembers() {
         groupMemberIds = chat.contactIds
@@ -306,16 +313,10 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         let sectionType = sections[indexPath.section]
         let row = indexPath.row
-        switch sectionType {
-        case .chatOptions, .chatActions:
-            return Constants.defaultCellHeight
-        case .members:
-            switch row {
-            case membersRowAddMembers, membersRowQrInvite:
-                return Constants.defaultCellHeight
-            default:
-                return ContactCell.cellHeight
-            }
+        if sectionType == .members && row != membersRowAddMembers && row != membersRowQrInvite {
+            return ContactCell.cellHeight
+        } else {
+            return UITableView.automaticDimension
         }
     }