瀏覽代碼

split newChatViewController into sections - populating cells

Bastian van de Wetering 6 年之前
父節點
當前提交
d4ff5ff890
共有 2 個文件被更改,包括 23 次插入7 次删除
  1. 1 1
      deltachat-ios/AccountSetupController.swift
  2. 22 6
      deltachat-ios/NewChatViewController.swift

+ 1 - 1
deltachat-ios/AccountSetupController.swift

@@ -458,7 +458,7 @@ extension AccountSetupController: UITextFieldDelegate {
       // special case: email field should check for potential oAuth
 
       // this will activate passwordTextField if oAuth-Dialogue was canceled
-      passwordCell.textField.becomeFirstResponder()
+      self.passwordCell.textField.becomeFirstResponder()
     }) {
       // all the action is defined in if condition
     } else {

+ 22 - 6
deltachat-ios/NewChatViewController.swift

@@ -51,9 +51,6 @@ class NewChatViewController: UITableViewController {
     navigationItem.rightBarButtonItem = cancelButton
 
     deviceContactHandler.importDeviceContacts(delegate: self)
-		tableView.register(UITableViewCell.self, forCellReuseIdentifier: "newChatCell")
-		tableView.register(UITableViewCell.self, forCellReuseIdentifier: "importContactsCell")
-		tableView.register(UITableViewCell.self, forCellReuseIdentifier: "contactCell")
   }
 
   override func viewDidAppear(_ animated: Bool) {
@@ -167,19 +164,38 @@ class NewChatViewController: UITableViewController {
 			}
 		} else if section == 1 {
 			if deviceContactAccessGranted {
-				let cell = tableView.dequeueReusableCell(withIdentifier: "contactCell", for: indexPath) as! ContactCell
+				let cell: ContactCell
+				if let c = tableView.dequeueReusableCell(withIdentifier: "contactCell") as? ContactCell {
+					cell = c
+				} else {
+					cell = ContactCell(style: .default, reuseIdentifier: "contactCell")
+				}
 				let contactId = contactIds[row]
 				updateContactCell(cell: cell, contactId: contactId)
 				return cell
 			} else {
-
+				let cell: ActionCell
+				if let c = tableView.dequeueReusableCell(withIdentifier: "actionCell") as? ActionCell {
+					cell = c
+				} else {
+					cell = ActionCell(style: .default, reuseIdentifier: "actionCell")
+				}
+				cell.actionTitle = "Import Device Contacts"
+				return cell
 			}
 		} else {
-			let cell = tableView.dequeueReusableCell(withIdentifier: "contactCell", for: indexPath) as! ContactCell
+			// section 2
+			let cell: ContactCell
+			if let c = tableView.dequeueReusableCell(withIdentifier: "contactCell") as? ContactCell {
+				cell = c
+			} else {
+				cell = ContactCell(style: .default, reuseIdentifier: "contactCell")
+			}
 			let contactId = contactIds[row]
 			updateContactCell(cell: cell, contactId: contactId)
 			return cell
 		}
+		fatalError()
   }