Kaynağa Gözat

code cleaning

Bastian van de Wetering 6 yıl önce
ebeveyn
işleme
dd3db61902

+ 5 - 5
deltachat-ios/Controller/AccountSetupController.swift

@@ -129,7 +129,7 @@ class AccountSetupController: UITableViewController {
 
   init() {
     super.init(style: .grouped)
-		hidesBottomBarWhenPushed = true
+    hidesBottomBarWhenPushed = true
   }
 
   required init?(coder _: NSCoder) {
@@ -575,10 +575,10 @@ class AdvancedSectionHeader: UIView {
 
  // TODO: to add Eye-icon -> uncomment -> add to inputField.rightView
  /*
-      lazy var makeVisibleIcon: UIImageView = {
-      let view = UIImageView(image: )
-      return view
-      }()
+       lazy var makeVisibleIcon: UIImageView = {
+       let view = UIImageView(image: )
+       return view
+       }()
   */
  init() {
  super.init(style: .default, reuseIdentifier: nil)

+ 16 - 16
deltachat-ios/Controller/ChatViewController.swift

@@ -26,9 +26,9 @@ class ChatViewController: MessagesViewController {
   var msgChangedObserver: Any?
   var incomingMsgObserver: Any?
 
-	lazy var navBarTap: UITapGestureRecognizer = {
-		return UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
-	}()
+  lazy var navBarTap: UITapGestureRecognizer = {
+    UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
+  }()
 
   var disableWriting = false
 
@@ -41,7 +41,7 @@ class ChatViewController: MessagesViewController {
     if let title = title {
       updateTitleView(title: title, subtitle: nil)
     }
-		hidesBottomBarWhenPushed = true
+    hidesBottomBarWhenPushed = true
   }
 
   required init?(coder _: NSCoder) {
@@ -70,18 +70,18 @@ class ChatViewController: MessagesViewController {
   override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)
 
-		// this will be removed in viewWillDisappear
-		navigationController?.navigationBar.addGestureRecognizer(navBarTap)
+    // this will be removed in viewWillDisappear
+    navigationController?.navigationBar.addGestureRecognizer(navBarTap)
 
-		let chat = MRChat(id: chatId)
-		updateTitleView(title: chat.name, subtitle: chat.subtitle)
+    let chat = MRChat(id: chatId)
+    updateTitleView(title: chat.name, subtitle: chat.subtitle)
 
-		if let image = chat.profileImage {
-			navigationItem.rightBarButtonItem = UIBarButtonItem(image: image, style: .done, target: self, action: #selector(chatProfilePressed))
-		} else {
-			let initialsLabel = InitialsLabel(name: chat.name, color: chat.color, size: 28)
-			navigationItem.rightBarButtonItem = UIBarButtonItem(customView: initialsLabel)
-		}
+    if let image = chat.profileImage {
+      navigationItem.rightBarButtonItem = UIBarButtonItem(image: image, style: .done, target: self, action: #selector(chatProfilePressed))
+    } else {
+      let initialsLabel = InitialsLabel(name: chat.name, color: chat.color, size: 28)
+      navigationItem.rightBarButtonItem = UIBarButtonItem(customView: initialsLabel)
+    }
 
     configureMessageMenu()
 
@@ -127,8 +127,8 @@ class ChatViewController: MessagesViewController {
   override func viewWillDisappear(_ animated: Bool) {
     super.viewWillDisappear(animated)
 
-		// the navigationController will be used when chatDetail is pushed, so we have to remove that gestureRecognizer
-		navigationController?.navigationBar.removeGestureRecognizer(navBarTap)
+    // the navigationController will be used when chatDetail is pushed, so we have to remove that gestureRecognizer
+    navigationController?.navigationBar.removeGestureRecognizer(navBarTap)
 
     let cnt = Int(dc_get_fresh_msg_cnt(mailboxPointer, UInt32(chatId)))
     logger.info("updating count for chat \(cnt)")

+ 9 - 13
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -9,8 +9,7 @@
 import UIKit
 
 class ContactDetailViewController: UITableViewController {
-
-	weak var coordinator: ContactDetailCoordinator?
+  weak var coordinator: ContactDetailCoordinator?
 
   let contactId: Int
 
@@ -27,18 +26,16 @@ class ContactDetailViewController: UITableViewController {
     fatalError("init(coder:) has not been implemented")
   }
 
-	override func viewDidLoad() {
-		super.viewDidLoad()
-		title = "Info"
-
-	}
+  override func viewDidLoad() {
+    super.viewDidLoad()
+    title = "Info"
+  }
 
   override func viewWillAppear(_: Bool) {
     navigationController?.navigationBar.prefersLargeTitles = false
     tableView.reloadData()
   }
 
-
   override func didReceiveMemoryWarning() {
     super.didReceiveMemoryWarning()
     // Dispose of any resources that can be recreated.
@@ -126,9 +123,8 @@ class ContactDetailViewController: UITableViewController {
     return vw
   }
 
-	private func displayNewChat(contactId: Int) {
-		let chatId = dc_create_chat_by_contact_id(mailboxPointer, UInt32(contactId))
-		coordinator?.showChat(chatId: Int(chatId))
-}
-
+  private func displayNewChat(contactId: Int) {
+    let chatId = dc_create_chat_by_contact_id(mailboxPointer, UInt32(contactId))
+    coordinator?.showChat(chatId: Int(chatId))
+  }
 }

+ 3 - 3
deltachat-ios/Controller/ContactListController.swift

@@ -86,7 +86,7 @@ class ContactListController: UITableViewController {
   }
 
   override func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
-		let contactId = contactIds[indexPath.row]
-		coordinator?.showContactDetail(contactId: contactId)
-   }
+    let contactId = contactIds[indexPath.row]
+    coordinator?.showContactDetail(contactId: contactId)
+  }
 }

+ 149 - 153
deltachat-ios/Controller/GroupMembersViewController.swift

@@ -9,161 +9,157 @@
 import UIKit
 
 class NewGroupViewController: GroupMembersViewController {
-	weak var coordinator: NewGroupCoordinator?
-
-
-	override func viewDidLoad() {
-		super.viewDidLoad()
-		title = "New Group"
-		navigationController?.navigationBar.prefersLargeTitles = false
-		let groupCreationNextButton = UIBarButtonItem(title: "Next", style: .done, target: self, action: #selector(nextButtonPressed))
-		navigationItem.rightBarButtonItem = groupCreationNextButton
-		contactIds = Utils.getContactIds()
-	}
-
-	override func didReceiveMemoryWarning() {
-		super.didReceiveMemoryWarning()
-	}
-
-	@objc func nextButtonPressed() {
-		coordinator?.showGroupNameController(contactIdsForGroup: selectedContactIds)
-	}
+  weak var coordinator: NewGroupCoordinator?
+
+  override func viewDidLoad() {
+    super.viewDidLoad()
+    title = "New Group"
+    navigationController?.navigationBar.prefersLargeTitles = false
+    let groupCreationNextButton = UIBarButtonItem(title: "Next", style: .done, target: self, action: #selector(nextButtonPressed))
+    navigationItem.rightBarButtonItem = groupCreationNextButton
+    contactIds = Utils.getContactIds()
+  }
+
+  override func didReceiveMemoryWarning() {
+    super.didReceiveMemoryWarning()
+  }
+
+  @objc func nextButtonPressed() {
+    coordinator?.showGroupNameController(contactIdsForGroup: selectedContactIds)
+  }
 }
 
 class AddGroupMembersViewController: GroupMembersViewController {
-
-	private var chatId: Int?
-
-	private lazy var resetButton: UIBarButtonItem = {
-		let button = UIBarButtonItem(title: "Reset", style: .plain, target: self, action: #selector(resetButtonPressed))
-		button.isEnabled = false
-		return button
-	}()
-
-	override var selectedContactIds: Set<Int> {
-		didSet {
-			resetButton.isEnabled = !selectedContactIds.isEmpty
-		}
-	}
-
-	private lazy var chat: MRChat? = {
-		if let chatId = chatId {
-			return MRChat(id: chatId)
-		}
-		return nil
-	}()
-
-	private lazy var chatMemberIds: [Int] = {
-		if let chat = chat {
-			return chat.contactIds
-		}
-		return []
-	}()
-
-	private lazy var memberCandidateIds: [Int] = {
-		var contactIds = Set(Utils.getContactIds())	// turn into set to speed up search
-		for member in chatMemberIds {
-			contactIds.remove(member)
-		}
-		return Array(contactIds)
-	}()
-
-
-	init(chatId: Int) {
-		super.init()
-		self.chatId = chatId
-	}
-
-	required init?(coder aDecoder: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-	override func viewDidLoad() {
-		super.viewDidLoad()
-		super.contactIds = memberCandidateIds
-		super.navigationItem.rightBarButtonItem = resetButton
-		title = "Add Group Members"
-		// Do any additional setup after loading the view.
-	}
-
-	override func viewWillDisappear(_ animated: Bool) {
-		guard let chatId = chatId else {
-			return
-		}
-		for contactId in selectedContactIds {
-			dc_add_contact_to_chat(mailboxPointer, UInt32(chatId), UInt32(contactId))
-		}
-	}
-
-	@objc func resetButtonPressed() {
-		selectedContactIds = []
-		tableView.reloadData()
-	}
+  private var chatId: Int?
+
+  private lazy var resetButton: UIBarButtonItem = {
+    let button = UIBarButtonItem(title: "Reset", style: .plain, target: self, action: #selector(resetButtonPressed))
+    button.isEnabled = false
+    return button
+  }()
+
+  override var selectedContactIds: Set<Int> {
+    didSet {
+      resetButton.isEnabled = !selectedContactIds.isEmpty
+    }
+  }
+
+  private lazy var chat: MRChat? = {
+    if let chatId = chatId {
+      return MRChat(id: chatId)
+    }
+    return nil
+  }()
+
+  private lazy var chatMemberIds: [Int] = {
+    if let chat = chat {
+      return chat.contactIds
+    }
+    return []
+  }()
+
+  private lazy var memberCandidateIds: [Int] = {
+    var contactIds = Set(Utils.getContactIds()) // turn into set to speed up search
+    for member in chatMemberIds {
+      contactIds.remove(member)
+    }
+    return Array(contactIds)
+  }()
+
+  init(chatId: Int) {
+    super.init()
+    self.chatId = chatId
+  }
+
+  required init?(coder _: NSCoder) {
+    fatalError("init(coder:) has not been implemented")
+  }
+
+  override func viewDidLoad() {
+    super.viewDidLoad()
+    super.contactIds = memberCandidateIds
+    super.navigationItem.rightBarButtonItem = resetButton
+    title = "Add Group Members"
+    // Do any additional setup after loading the view.
+  }
+
+  override func viewWillDisappear(_: Bool) {
+    guard let chatId = chatId else {
+      return
+    }
+    for contactId in selectedContactIds {
+      dc_add_contact_to_chat(mailboxPointer, UInt32(chatId), UInt32(contactId))
+    }
+  }
+
+  @objc func resetButtonPressed() {
+    selectedContactIds = []
+    tableView.reloadData()
+  }
 }
- 	
-class GroupMembersViewController : UITableViewController {
-
-	let contactCellReuseIdentifier = "contactCell"
-
-	var contactIds: [Int] = [] {
-		didSet {
-			tableView.reloadData()
-		}
-	}
-
-	var selectedContactIds: Set<Int> = []
-
-	init() {
-		super.init(nibName: nil, bundle: nil)
-		hidesBottomBarWhenPushed = true
-	}
-
-	required init?(coder aDecoder: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-	override func viewDidLoad() {
-		 tableView.register(ContactCell.self, forCellReuseIdentifier: contactCellReuseIdentifier)
-	}
-
-	override func numberOfSections(in _: UITableView) -> Int {
-		return 1
-	}
-
-	override func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
-		return contactIds.count
-	}
-
-	override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-		guard let cell: ContactCell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as? ContactCell else {
-			fatalError("shouldn't happen")
-		}
-
-		let row = indexPath.row
-		let contactRow = row
-
-		let contact = MRContact(id: contactIds[contactRow])
-		cell.nameLabel.text = contact.name
-		cell.emailLabel.text = contact.email
-		cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
-		cell.accessoryType = selectedContactIds.contains(contactIds[row]) ? .checkmark : .none
-		cell.setColor(contact.color)
-
-		return cell
-	}
-
-	override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-		let row = indexPath.row
-		if let cell = tableView.cellForRow(at: indexPath) {
-			tableView.deselectRow(at: indexPath, animated: true)
-			let contactId = contactIds[row]
-			if selectedContactIds.contains(contactId) {
-				selectedContactIds.remove(contactId)
-				cell.accessoryType = .none
-			} else {
-				selectedContactIds.insert(contactId)
-				cell.accessoryType = .checkmark
-			}
-		}
-	}
+
+class GroupMembersViewController: UITableViewController {
+  let contactCellReuseIdentifier = "contactCell"
+
+  var contactIds: [Int] = [] {
+    didSet {
+      tableView.reloadData()
+    }
+  }
+
+  var selectedContactIds: Set<Int> = []
+
+  init() {
+    super.init(nibName: nil, bundle: nil)
+    hidesBottomBarWhenPushed = true
+  }
+
+  required init?(coder _: NSCoder) {
+    fatalError("init(coder:) has not been implemented")
+  }
+
+  override func viewDidLoad() {
+    tableView.register(ContactCell.self, forCellReuseIdentifier: contactCellReuseIdentifier)
+  }
+
+  override func numberOfSections(in _: UITableView) -> Int {
+    return 1
+  }
+
+  override func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
+    return contactIds.count
+  }
+
+  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+    guard let cell: ContactCell = tableView.dequeueReusableCell(withIdentifier: contactCellReuseIdentifier, for: indexPath) as? ContactCell else {
+      fatalError("shouldn't happen")
+    }
+
+    let row = indexPath.row
+    let contactRow = row
+
+    let contact = MRContact(id: contactIds[contactRow])
+    cell.nameLabel.text = contact.name
+    cell.emailLabel.text = contact.email
+    cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
+    cell.accessoryType = selectedContactIds.contains(contactIds[row]) ? .checkmark : .none
+    cell.setColor(contact.color)
+
+    return cell
+  }
+
+  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+    let row = indexPath.row
+    if let cell = tableView.cellForRow(at: indexPath) {
+      tableView.deselectRow(at: indexPath, animated: true)
+      let contactId = contactIds[row]
+      if selectedContactIds.contains(contactId) {
+        selectedContactIds.remove(contactId)
+        cell.accessoryType = .none
+      } else {
+        selectedContactIds.insert(contactId)
+        cell.accessoryType = .checkmark
+      }
+    }
+  }
 }

+ 11 - 25
deltachat-ios/Controller/MailboxViewController.swift

@@ -9,32 +9,18 @@
 import UIKit
 
 class MailboxViewController: ChatViewController {
+  override init(chatId: Int, title: String? = nil) {
+    super.init(chatId: chatId, title: title)
+    hidesBottomBarWhenPushed = false
+  }
 
-	override init(chatId: Int, title: String? = nil) {
-		super.init(chatId: chatId, title: title)
-		hidesBottomBarWhenPushed = false
-	}
+  required init?(coder _: NSCoder) {
+    fatalError("init(coder:) has not been implemented")
+  }
 
-	required init?(coder _: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-
-	override func viewDidLoad() {
-		super.viewDidLoad()
-
-		// Do any additional setup after loading the view.
-	}
-
-
-	/*
-	// MARK: - Navigation
-
-	// In a storyboard-based application, you will often want to do a little preparation before navigation
-	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-	// Get the new view controller using segue.destination.
-	// Pass the selected object to the new view controller.
-	}
-	*/
+  override func viewDidLoad() {
+    super.viewDidLoad()
 
+    // Do any additional setup after loading the view.
+  }
 }

+ 2 - 2
deltachat-ios/Controller/NewChatViewController.swift

@@ -59,7 +59,7 @@ class NewChatViewController: UITableViewController {
 
   init() {
     super.init(style: .grouped)
-		hidesBottomBarWhenPushed = true
+    hidesBottomBarWhenPushed = true
   }
 
   required init?(coder _: NSCoder) {
@@ -80,7 +80,7 @@ class NewChatViewController: UITableViewController {
     super.viewWillAppear(animated)
     deviceContactAccessGranted = CNContactStore.authorizationStatus(for: .contacts) == .authorized
     contactIds = Utils.getContactIds()
-		// this will show the searchbar on launch -> will be set back to true on viewDidAppear
+    // this will show the searchbar on launch -> will be set back to true on viewDidAppear
     if #available(iOS 11.0, *) {
       navigationItem.hidesSearchBarWhenScrolling = false
     }

+ 4 - 5
deltachat-ios/Controller/NewContactController.swift

@@ -51,7 +51,6 @@ class NewContactController: UITableViewController {
     }
   }
 
-
   // for creating a new contact
   init() {
     cells = [emailCell, nameCell]
@@ -85,10 +84,10 @@ class NewContactController: UITableViewController {
     }
   }
 
-	override func viewWillAppear(_: Bool) {
-		navigationController?.setNavigationBarHidden(false, animated: false)
-		navigationController?.navigationBar.prefersLargeTitles = false
-	}
+  override func viewWillAppear(_: Bool) {
+    navigationController?.setNavigationBarHidden(false, animated: false)
+    navigationController?.navigationBar.prefersLargeTitles = false
+  }
 
   @objc func emailTextChanged() {
     let emailText = emailCell.textField.text ?? ""

+ 329 - 340
deltachat-ios/Controller/SingleChatDetailViewController.swift

@@ -9,356 +9,345 @@
 import UIKit
 
 class ChatDetailViewController: UIViewController {
-	weak var coordinator: ChatDetailCoordinator?
-
-	fileprivate var chat: MRChat
-
-	var chatDetailTable: UITableView = {
-		let table = UITableView(frame: .zero, style: .grouped)
-		table.bounces = false
-		table.register(UITableViewCell.self, forCellReuseIdentifier: "tableCell")
-		table.register(ActionCell.self, forCellReuseIdentifier: "actionCell")
-		table.register(ContactCell.self, forCellReuseIdentifier: "contactCell")
-
-		return table
-	}()
-
-	init(chatId: Int) {
-		self.chat = MRChat(id: chatId)
-		super.init(nibName: nil, bundle: nil)
-		setupSubviews()
-	}
-
-	override func viewWillAppear(_ animated: Bool) {
-		chatDetailTable.reloadData()	// to display updates
-	}
-
-	required init?(coder _: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-	private func setupSubviews() {
-		view.addSubview(chatDetailTable)
-		chatDetailTable.translatesAutoresizingMaskIntoConstraints = false
-
-		chatDetailTable.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
-		chatDetailTable.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
-		chatDetailTable.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
-		chatDetailTable.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
-	}
-
-	@objc func editButtonPressed() {
-		// will be overwritten
-	}
-
-	func showNotificationSetup() {
-		let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet", message: "But you get an idea where this is going", preferredStyle: .actionSheet)
-		let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
-		notificationSetupAlert.addAction(cancelAction)
-		present(notificationSetupAlert, animated: true, completion: nil)
-	}
-
+  weak var coordinator: ChatDetailCoordinator?
+
+  fileprivate var chat: MRChat
+
+  var chatDetailTable: UITableView = {
+    let table = UITableView(frame: .zero, style: .grouped)
+    table.bounces = false
+    table.register(UITableViewCell.self, forCellReuseIdentifier: "tableCell")
+    table.register(ActionCell.self, forCellReuseIdentifier: "actionCell")
+    table.register(ContactCell.self, forCellReuseIdentifier: "contactCell")
+
+    return table
+  }()
+
+  init(chatId: Int) {
+    chat = MRChat(id: chatId)
+    super.init(nibName: nil, bundle: nil)
+    setupSubviews()
+  }
+
+  override func viewWillAppear(_: Bool) {
+    chatDetailTable.reloadData() // to display updates
+  }
+
+  required init?(coder _: NSCoder) {
+    fatalError("init(coder:) has not been implemented")
+  }
+
+  private func setupSubviews() {
+    view.addSubview(chatDetailTable)
+    chatDetailTable.translatesAutoresizingMaskIntoConstraints = false
+
+    chatDetailTable.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
+    chatDetailTable.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
+    chatDetailTable.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
+    chatDetailTable.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
+  }
+
+  @objc func editButtonPressed() {
+    // will be overwritten
+  }
+
+  func showNotificationSetup() {
+    let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet", message: "But you get an idea where this is going", preferredStyle: .actionSheet)
+    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
+    notificationSetupAlert.addAction(cancelAction)
+    present(notificationSetupAlert, animated: true, completion: nil)
+  }
 }
 
 class SingleChatDetailViewController: ChatDetailViewController {
-
-	var contact: MRContact? {
-		if let id = chat.contactIds.first {
-			return MRContact(id: id)
-		}
-		return nil
-	}
-
-	override func viewDidLoad() {
-		super.viewDidLoad()
-		title = "Info"
-		chatDetailTable.delegate = self
-		chatDetailTable.dataSource = self
-	}
-
-	@objc override func editButtonPressed() {
-		if let id = chat.contactIds.first {
-			coordinator?.showSingleChatEdit(contactId: id)
-		}
-	}
-
+  var contact: MRContact? {
+    if let id = chat.contactIds.first {
+      return MRContact(id: id)
+    }
+    return nil
+  }
+
+  override func viewDidLoad() {
+    super.viewDidLoad()
+    title = "Info"
+    chatDetailTable.delegate = self
+    chatDetailTable.dataSource = self
+  }
+
+  @objc override func editButtonPressed() {
+    if let id = chat.contactIds.first {
+      coordinator?.showSingleChatEdit(contactId: id)
+    }
+  }
 }
 
 extension SingleChatDetailViewController: UITableViewDelegate, UITableViewDataSource {
-
-	func numberOfSections(in tableView: UITableView) -> Int {
-		return 2
-	}
-
-	func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-		return 1
-	}
-
-	func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
-		if section == 0 {
-			guard let contact = contact else {
-				return nil
-			}
-			let bg = UIColor(red: 248 / 255, green: 248 / 255, blue: 255 / 255, alpha: 1.0)
-
-			let contactCell = ContactCell()
-			contactCell.backgroundColor = bg
-			contactCell.nameLabel.text = contact.name
-			contactCell.emailLabel.text = contact.email
-			contactCell.darkMode = false
-			contactCell.selectionStyle = .none
-			if let img = chat.profileImage {
-				contactCell.setImage(img)
-			} else {
-				contactCell.setBackupImage(name: contact.name, color: contact.color)
-			}
-			contactCell.setVerified(isVerified: chat.isVerified)
-			return contactCell
-		} else {
-			return nil
-		}
-	}
-
-	func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-		let section = indexPath.section
-
-		if section == 0 {
-			let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
-			cell.textLabel?.text = "Notifications"
-			cell.selectionStyle = .none
-			return cell
-		} else if section == 1 {
-			let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
-			if let contact = contact {
-				cell.actionTitle =  contact.isBlocked ? "Unblock Contact" : "Block Contact"
-				cell.actionColor = contact.isBlocked ? SystemColor.blue.uiColor : UIColor.red // SystemColor.red.uiColor
-			}
-			return cell
-		}
-		return UITableViewCell(frame: .zero)
-	}
-
-	func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-		let section = indexPath.section
-
-		if section == 0 {
-			showNotificationSetup()
-		} else if section == 1 {
-			if let contact = contact {
-				contact.isBlocked ? contact.unblock() : contact.block()
-				tableView.reloadData()
-			}
-		}
-	}
+  func numberOfSections(in _: UITableView) -> Int {
+    return 2
+  }
+
+  func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
+    return 1
+  }
+
+  func tableView(_: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+    if section == 0 {
+      guard let contact = contact else {
+        return nil
+      }
+      let bg = UIColor(red: 248 / 255, green: 248 / 255, blue: 255 / 255, alpha: 1.0)
+
+      let contactCell = ContactCell()
+      contactCell.backgroundColor = bg
+      contactCell.nameLabel.text = contact.name
+      contactCell.emailLabel.text = contact.email
+      contactCell.darkMode = false
+      contactCell.selectionStyle = .none
+      if let img = chat.profileImage {
+        contactCell.setImage(img)
+      } else {
+        contactCell.setBackupImage(name: contact.name, color: contact.color)
+      }
+      contactCell.setVerified(isVerified: chat.isVerified)
+      return contactCell
+    } else {
+      return nil
+    }
+  }
+
+  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+    let section = indexPath.section
+
+    if section == 0 {
+      let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
+      cell.textLabel?.text = "Notifications"
+      cell.selectionStyle = .none
+      return cell
+    } else if section == 1 {
+      let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
+      if let contact = contact {
+        cell.actionTitle = contact.isBlocked ? "Unblock Contact" : "Block Contact"
+        cell.actionColor = contact.isBlocked ? SystemColor.blue.uiColor : UIColor.red // SystemColor.red.uiColor
+      }
+      return cell
+    }
+    return UITableViewCell(frame: .zero)
+  }
+
+  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+    let section = indexPath.section
+
+    if section == 0 {
+      showNotificationSetup()
+    } else if section == 1 {
+      if let contact = contact {
+        contact.isBlocked ? contact.unblock() : contact.block()
+        tableView.reloadData()
+      }
+    }
+  }
 }
 
 class GroupChatDetailViewController: ChatDetailViewController {
-
-	private var currentUser: MRContact? {
-		return groupMembers.filter({$0.email == MRConfig.addr}).first
-	}
-
-	private let editGroupCell = GroupLabelCell()
-
-	private var editingGroupName: Bool = false
-
-	private lazy var editBarButtonItem: UIBarButtonItem = {
-		UIBarButtonItem(title: editingGroupName ? "Done" : "Edit", style: .plain, target: self, action: #selector(editButtonPressed))
-	}()
-
-	private var groupMembers: [MRContact] = []
-
-	private let staticCellCountMemberSection = 1 //
-
-	override func viewDidLoad() {
-		super.viewDidLoad()
-		title = "Group Info"
-		chatDetailTable.delegate = self
-		chatDetailTable.dataSource = self
-		navigationItem.rightBarButtonItem = editBarButtonItem
-	}
-
-	override func viewWillAppear(_ animated: Bool) {
-		updateGroupMembers()
-		editBarButtonItem.isEnabled = currentUser != nil
-	}
-
-	private func updateGroupMembers() {
-		let ids = chat.contactIds
-		groupMembers = ids.map({MRContact(id: $0)})
-		chatDetailTable.reloadData()
-	}
-
-	@objc override func editButtonPressed() {
-		if editingGroupName {
-			let newName = editGroupCell.getGroupName()
-			dc_set_chat_name(mailboxPointer, UInt32(chat.id), newName)
-			self.chat = MRChat(id: chat.id) // reload
-		}
-
-		editingGroupName = !editingGroupName
-		editBarButtonItem.title = editingGroupName ? "Save" : "Edit"
-		chatDetailTable.reloadData()
-	}
-
-	private func leaveGroup() {
-		if let userId = currentUser?.id {
-			dc_remove_contact_from_chat(mailboxPointer, UInt32(chat.id), UInt32(userId))
-			editBarButtonItem.isEnabled = false
-			updateGroupMembers()
-		}
-	}
-
+  private var currentUser: MRContact? {
+    return groupMembers.filter { $0.email == MRConfig.addr }.first
+  }
+
+  private let editGroupCell = GroupLabelCell()
+
+  private var editingGroupName: Bool = false
+
+  private lazy var editBarButtonItem: UIBarButtonItem = {
+    UIBarButtonItem(title: editingGroupName ? "Done" : "Edit", style: .plain, target: self, action: #selector(editButtonPressed))
+  }()
+
+  private var groupMembers: [MRContact] = []
+
+  private let staticCellCountMemberSection = 1 //
+
+  override func viewDidLoad() {
+    super.viewDidLoad()
+    title = "Group Info"
+    chatDetailTable.delegate = self
+    chatDetailTable.dataSource = self
+    navigationItem.rightBarButtonItem = editBarButtonItem
+  }
+
+  override func viewWillAppear(_: Bool) {
+    updateGroupMembers()
+    editBarButtonItem.isEnabled = currentUser != nil
+  }
+
+  private func updateGroupMembers() {
+    let ids = chat.contactIds
+    groupMembers = ids.map { MRContact(id: $0) }
+    chatDetailTable.reloadData()
+  }
+
+  @objc override func editButtonPressed() {
+    if editingGroupName {
+      let newName = editGroupCell.getGroupName()
+      dc_set_chat_name(mailboxPointer, UInt32(chat.id), newName)
+      chat = MRChat(id: chat.id) // reload
+    }
+
+    editingGroupName = !editingGroupName
+    editBarButtonItem.title = editingGroupName ? "Save" : "Edit"
+    chatDetailTable.reloadData()
+  }
+
+  private func leaveGroup() {
+    if let userId = currentUser?.id {
+      dc_remove_contact_from_chat(mailboxPointer, UInt32(chat.id), UInt32(userId))
+      editBarButtonItem.isEnabled = false
+      updateGroupMembers()
+    }
+  }
 }
 
 extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSource {
-
-	func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
-		if section == 1 {
-			return "Members:"
-		}
-		return nil
-	}
-
-	func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
-		if section == 0 {
-			let bg = UIColor(red: 248 / 255, green: 248 / 255, blue: 255 / 255, alpha: 1.0)
-
-			if editingGroupName {
-				editGroupCell.groupBadge.setColor(chat.color)
-				editGroupCell.backgroundColor = bg
-				editGroupCell.inputField.text = chat.name
-				editGroupCell.groupBadge.setText(chat.name)
-				return editGroupCell
-			} else {
-
-				let contactCell = ContactCell()
-				contactCell.backgroundColor = bg
-				contactCell.nameLabel.text = chat.name
-				contactCell.emailLabel.text = chat.subtitle
-				contactCell.darkMode = false
-				contactCell.selectionStyle = .none
-				if let img = chat.profileImage {
-					contactCell.setImage(img)
-				} else {
-					contactCell.setBackupImage(name: chat.name, color: chat.color)
-				}
-				contactCell.setVerified(isVerified: chat.isVerified)
-				return contactCell
-			}
-		} else {
-			return nil
-		}
-	}
-
-	func numberOfSections(in tableView: UITableView) -> Int {
-		/*
-		section 0: config
-		section 1: members
-		section 2: leave group (optional - if user already left group this option will be hidden)
-		*/
-
-		if currentUser == nil {
-			return 2
-		}
-		return 3
-	}
-
-	func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-		if section == 0 {
-			return 1
-		} else if section == 1 {
-			return groupMembers.count + staticCellCountMemberSection // first cell is addGroupMemberCell
-		} else if section == 2 {
-			return 1
-		} else {
-			return 0
-		}
-	}
-
-	func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-		let section = indexPath.section
-		let row = indexPath.row
-
-		if section == 0 {
-			let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
-			cell.textLabel?.text = "Notifications"
-			cell.selectionStyle = .none
-			return cell
-		} else  if section == 1 {
-
-			if row == 0 {
-				let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
-				cell.actionTitle = "Add Members"
-				return cell
-			} else {
-				let cell = tableView.dequeueReusableCell(withIdentifier: "contactCell", for: indexPath) as! ContactCell
-				let contact = groupMembers[row - staticCellCountMemberSection]
-				cell.nameLabel.text = contact.name
-				cell.emailLabel.text = contact.email
-				cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
-				cell.setColor(contact.color)
-				return cell
-			}
-		} else if section == 2 {
-			let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
-			cell.actionTitle = "Leave Group"
-			cell.actionColor = UIColor.red
-			return cell
-		}
-
-		return UITableViewCell(frame: .zero)
-	}
-
-
-	func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-		let section = indexPath.section
-		let row = indexPath.row
-		if section == 0 {
-			showNotificationSetup()
-		} else if section == 1 {
-			if row == 0 {
-				coordinator?.showAddGroupMember(chatId: self.chat.id)
-			}
-			// ignore for now - in Telegram tapping a contactCell leads into ContactDetail
-		} else if section == 2 {
-			leaveGroup()
-		}
-	}
-
-	func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
-		let section = indexPath.section
-		let row = indexPath.row
-
-		if let currentUser = currentUser {
-			if section == 1 && row > 0 && groupMembers[row - staticCellCountMemberSection].id != currentUser.id {
-				return true
-			}
-		}
-		return false
-	}
-
-	func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
-
-		let section = indexPath.section
-		let row = indexPath.row
-
-		// assigning swipe by delete to members (except for current user)
-		if section == 1 && row >= staticCellCountMemberSection && groupMembers[row - staticCellCountMemberSection].id != currentUser?.id {
-			let delete = UITableViewRowAction(style: .destructive, title: "Delete") { [unowned self] (action, indexPath) in
-
-				let memberId = self.groupMembers[row - self.staticCellCountMemberSection].id
-				let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(memberId))
-				if success == 1 {
-					self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
-					tableView.deleteRows(at: [indexPath], with: .fade)
-					tableView.reloadData()
-				}
-			}
-			delete.backgroundColor = UIColor.red
-			return [delete]
-		} else {
-			return nil
-		}
-	}
+  func tableView(_: UITableView, titleForHeaderInSection section: Int) -> String? {
+    if section == 1 {
+      return "Members:"
+    }
+    return nil
+  }
+
+  func tableView(_: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+    if section == 0 {
+      let bg = UIColor(red: 248 / 255, green: 248 / 255, blue: 255 / 255, alpha: 1.0)
+
+      if editingGroupName {
+        editGroupCell.groupBadge.setColor(chat.color)
+        editGroupCell.backgroundColor = bg
+        editGroupCell.inputField.text = chat.name
+        editGroupCell.groupBadge.setText(chat.name)
+        return editGroupCell
+      } else {
+        let contactCell = ContactCell()
+        contactCell.backgroundColor = bg
+        contactCell.nameLabel.text = chat.name
+        contactCell.emailLabel.text = chat.subtitle
+        contactCell.darkMode = false
+        contactCell.selectionStyle = .none
+        if let img = chat.profileImage {
+          contactCell.setImage(img)
+        } else {
+          contactCell.setBackupImage(name: chat.name, color: chat.color)
+        }
+        contactCell.setVerified(isVerified: chat.isVerified)
+        return contactCell
+      }
+    } else {
+      return nil
+    }
+  }
+
+  func numberOfSections(in _: UITableView) -> Int {
+    /*
+     section 0: config
+     section 1: members
+     section 2: leave group (optional - if user already left group this option will be hidden)
+     */
+
+    if currentUser == nil {
+      return 2
+    }
+    return 3
+  }
+
+  func tableView(_: UITableView, numberOfRowsInSection section: Int) -> Int {
+    if section == 0 {
+      return 1
+    } else if section == 1 {
+      return groupMembers.count + staticCellCountMemberSection // first cell is addGroupMemberCell
+    } else if section == 2 {
+      return 1
+    } else {
+      return 0
+    }
+  }
+
+  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+    let section = indexPath.section
+    let row = indexPath.row
+
+    if section == 0 {
+      let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
+      cell.textLabel?.text = "Notifications"
+      cell.selectionStyle = .none
+      return cell
+    } else if section == 1 {
+      if row == 0 {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
+        cell.actionTitle = "Add Members"
+        return cell
+      } else {
+        let cell = tableView.dequeueReusableCell(withIdentifier: "contactCell", for: indexPath) as! ContactCell
+        let contact = groupMembers[row - staticCellCountMemberSection]
+        cell.nameLabel.text = contact.name
+        cell.emailLabel.text = contact.email
+        cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
+        cell.setColor(contact.color)
+        return cell
+      }
+    } else if section == 2 {
+      let cell = tableView.dequeueReusableCell(withIdentifier: "actionCell", for: indexPath) as! ActionCell
+      cell.actionTitle = "Leave Group"
+      cell.actionColor = UIColor.red
+      return cell
+    }
+
+    return UITableViewCell(frame: .zero)
+  }
+
+  func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
+    let section = indexPath.section
+    let row = indexPath.row
+    if section == 0 {
+      showNotificationSetup()
+    } else if section == 1 {
+      if row == 0 {
+        coordinator?.showAddGroupMember(chatId: chat.id)
+      }
+      // ignore for now - in Telegram tapping a contactCell leads into ContactDetail
+    } else if section == 2 {
+      leaveGroup()
+    }
+  }
+
+  func tableView(_: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
+    let section = indexPath.section
+    let row = indexPath.row
+
+    if let currentUser = currentUser {
+      if section == 1, row > 0, groupMembers[row - staticCellCountMemberSection].id != currentUser.id {
+        return true
+      }
+    }
+    return false
+  }
+
+  func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
+    let section = indexPath.section
+    let row = indexPath.row
+
+    // assigning swipe by delete to members (except for current user)
+    if section == 1, row >= staticCellCountMemberSection, groupMembers[row - staticCellCountMemberSection].id != currentUser?.id {
+      let delete = UITableViewRowAction(style: .destructive, title: "Delete") { [unowned self] _, indexPath in
+
+        let memberId = self.groupMembers[row - self.staticCellCountMemberSection].id
+        let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(memberId))
+        if success == 1 {
+          self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
+          tableView.deleteRows(at: [indexPath], with: .fade)
+          tableView.reloadData()
+        }
+      }
+      delete.backgroundColor = UIColor.red
+      return [delete]
+    } else {
+      return nil
+    }
+  }
 }

+ 265 - 267
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -9,318 +9,316 @@
 import UIKit
 
 class AppCoordinator: NSObject, Coordinator, UITabBarControllerDelegate {
-	private let window: UIWindow
-
-	var rootViewController: UIViewController {
-		return tabBarController
-	}
-
-	private var childCoordinators: [Coordinator] = []
-
-	private lazy var tabBarController: UITabBarController = {
-		let tabBarController = UITabBarController()
-		tabBarController.viewControllers = [contactListController, mailboxController, profileController, chatListController, settingsController]
-		// put viewControllers here
-		tabBarController.delegate = self
-		tabBarController.tabBar.tintColor = DCColors.primary
-		// tabBarController.tabBar.isTranslucent = false
-		return tabBarController
-	}()
-
-	// MARK: viewControllers
-
-	private lazy var contactListController: UIViewController = {
-		let controller = ContactListController()
-		let nav = NavigationController(rootViewController: controller)
-		let settingsImage = UIImage(named: "contacts")
-		nav.tabBarItem = UITabBarItem(title: "Contacts", image: settingsImage, tag: 4)
-		let coordinator = ContactListCoordinator(navigationController: nav)
-		self.childCoordinators.append(coordinator)
-		controller.coordinator = coordinator
-		return nav
-	}()
-
-	private lazy var mailboxController: UIViewController = {
-		let controller = MailboxViewController(chatId: Int(DC_CHAT_ID_DEADDROP), title: "Mailbox")
-		controller.disableWriting = true
-		let nav = NavigationController(rootViewController: controller)
-		let settingsImage = UIImage(named: "message")
-		nav.tabBarItem = UITabBarItem(title: "Mailbox", image: settingsImage, tag: 4)
-		let coordinator = MailboxCoordinator(navigationController: nav)
-		self.childCoordinators.append(coordinator)
-		controller.coordinator = coordinator
-		return nav
-	}()
-
-	private lazy var profileController: UIViewController = {
-		let controller = ProfileViewController()
-		let nav = NavigationController(rootViewController: controller)
-		let settingsImage = UIImage(named: "report_card")
-		nav.tabBarItem = UITabBarItem(title: "My Profile", image: settingsImage, tag: 4)
-		let coordinator = ProfileCoordinator(rootViewController: nav)
-		self.childCoordinators.append(coordinator)
-		controller.coordinator = coordinator
-		return nav
-	}()
-
-	private lazy var chatListController: UIViewController = {
-		let controller = ChatListController()
-		let nav = NavigationController(rootViewController: controller)
-		let settingsImage = UIImage(named: "chat")
-		nav.tabBarItem = UITabBarItem(title: "Chats", image: settingsImage, tag: 4)
-		let coordinator = ChatListCoordinator(navigationController: nav)
-		self.childCoordinators.append(coordinator)
-		controller.coordinator = coordinator
-		return nav
-	}()
-
-	private lazy var settingsController: UIViewController = {
-		let controller = SettingsViewController()
-		let nav = NavigationController(rootViewController: controller)
-		let settingsImage = UIImage(named: "settings")
-		nav.tabBarItem = UITabBarItem(title: "Settings", image: settingsImage, tag: 4)
-		let coordinator = SettingsCoordinator(navigationController: nav)
-		self.childCoordinators.append(coordinator)
-		controller.coordinator = coordinator
-		return nav
-	}()
-
-	init(window: UIWindow) {
-		self.window = window
-		super.init()
-		window.rootViewController = rootViewController
-		window.makeKeyAndVisible()
-	}
-
-	public func start() {
-		showTab(index: 3)
-	}
-
-	public func showTab(index: Int) {
-		tabBarController.selectedIndex = index
-	}
-
-	public func presentLoginController() {
-		let accountSetupController = AccountSetupController()
-		let accountSetupNavigationController = UINavigationController(rootViewController: accountSetupController)
-		rootViewController.present(accountSetupNavigationController, animated: false, completion: nil)
-	}
+  private let window: UIWindow
+
+  var rootViewController: UIViewController {
+    return tabBarController
+  }
+
+  private var childCoordinators: [Coordinator] = []
+
+  private lazy var tabBarController: UITabBarController = {
+    let tabBarController = UITabBarController()
+    tabBarController.viewControllers = [contactListController, mailboxController, profileController, chatListController, settingsController]
+    // put viewControllers here
+    tabBarController.delegate = self
+    tabBarController.tabBar.tintColor = DCColors.primary
+    // tabBarController.tabBar.isTranslucent = false
+    return tabBarController
+  }()
+
+  // MARK: viewControllers
+
+  private lazy var contactListController: UIViewController = {
+    let controller = ContactListController()
+    let nav = NavigationController(rootViewController: controller)
+    let settingsImage = UIImage(named: "contacts")
+    nav.tabBarItem = UITabBarItem(title: "Contacts", image: settingsImage, tag: 4)
+    let coordinator = ContactListCoordinator(navigationController: nav)
+    self.childCoordinators.append(coordinator)
+    controller.coordinator = coordinator
+    return nav
+  }()
+
+  private lazy var mailboxController: UIViewController = {
+    let controller = MailboxViewController(chatId: Int(DC_CHAT_ID_DEADDROP), title: "Mailbox")
+    controller.disableWriting = true
+    let nav = NavigationController(rootViewController: controller)
+    let settingsImage = UIImage(named: "message")
+    nav.tabBarItem = UITabBarItem(title: "Mailbox", image: settingsImage, tag: 4)
+    let coordinator = MailboxCoordinator(navigationController: nav)
+    self.childCoordinators.append(coordinator)
+    controller.coordinator = coordinator
+    return nav
+  }()
+
+  private lazy var profileController: UIViewController = {
+    let controller = ProfileViewController()
+    let nav = NavigationController(rootViewController: controller)
+    let settingsImage = UIImage(named: "report_card")
+    nav.tabBarItem = UITabBarItem(title: "My Profile", image: settingsImage, tag: 4)
+    let coordinator = ProfileCoordinator(rootViewController: nav)
+    self.childCoordinators.append(coordinator)
+    controller.coordinator = coordinator
+    return nav
+  }()
+
+  private lazy var chatListController: UIViewController = {
+    let controller = ChatListController()
+    let nav = NavigationController(rootViewController: controller)
+    let settingsImage = UIImage(named: "chat")
+    nav.tabBarItem = UITabBarItem(title: "Chats", image: settingsImage, tag: 4)
+    let coordinator = ChatListCoordinator(navigationController: nav)
+    self.childCoordinators.append(coordinator)
+    controller.coordinator = coordinator
+    return nav
+  }()
+
+  private lazy var settingsController: UIViewController = {
+    let controller = SettingsViewController()
+    let nav = NavigationController(rootViewController: controller)
+    let settingsImage = UIImage(named: "settings")
+    nav.tabBarItem = UITabBarItem(title: "Settings", image: settingsImage, tag: 4)
+    let coordinator = SettingsCoordinator(navigationController: nav)
+    self.childCoordinators.append(coordinator)
+    controller.coordinator = coordinator
+    return nav
+  }()
+
+  init(window: UIWindow) {
+    self.window = window
+    super.init()
+    window.rootViewController = rootViewController
+    window.makeKeyAndVisible()
+  }
+
+  public func start() {
+    showTab(index: 3)
+  }
+
+  public func showTab(index: Int) {
+    tabBarController.selectedIndex = index
+  }
+
+  public func presentLoginController() {
+    let accountSetupController = AccountSetupController()
+    let accountSetupNavigationController = UINavigationController(rootViewController: accountSetupController)
+    rootViewController.present(accountSetupNavigationController, animated: false, completion: nil)
+  }
 }
 
 class ContactListCoordinator: Coordinator {
-	let navigationController: UINavigationController
+  let navigationController: UINavigationController
 
-	var childCoordinators: [Coordinator] = []
+  var childCoordinators: [Coordinator] = []
 
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
 
-	func showContactDetail(contactId: Int) {
-		let contactDetailController = ContactDetailViewController(contactId: contactId)
-		let coordinator = ContactDetailCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		contactDetailController.coordinator = coordinator
-		navigationController.pushViewController(contactDetailController, animated: true)
-
-	}
+  func showContactDetail(contactId: Int) {
+    let contactDetailController = ContactDetailViewController(contactId: contactId)
+    let coordinator = ContactDetailCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    contactDetailController.coordinator = coordinator
+    navigationController.pushViewController(contactDetailController, animated: true)
+  }
 }
 
 // since mailbox and chatView -tab both use ChatViewController we want to be able to assign different functionality via coordinators -> therefore we override unneeded functions such as showChatDetail -> maybe find better solution in longterm
 class MailboxCoordinator: ChatViewCoordinator {
-	override func showChatDetail(chatId _: Int) {
-		// ignore for now
-	}
+  override func showChatDetail(chatId _: Int) {
+    // ignore for now
+  }
 }
 
 class ProfileCoordinator: Coordinator {
-	var rootViewController: UIViewController
+  var rootViewController: UIViewController
 
-	init(rootViewController: UIViewController) {
-		self.rootViewController = rootViewController
-	}
+  init(rootViewController: UIViewController) {
+    self.rootViewController = rootViewController
+  }
 }
 
 class ChatListCoordinator: Coordinator {
-	let navigationController: UINavigationController
-
-	var childCoordinators: [Coordinator] = []
-
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
-
-	func showNewChatController() {
-		let newChatVC = NewChatViewController()
-		let coordinator = NewChatCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		newChatVC.coordinator = coordinator
-		navigationController.pushViewController(newChatVC, animated: true)
-	}
-
-	func showChat(chatId: Int) {
-		let chatVC = ChatViewController(chatId: chatId)
-		let coordinator = ChatViewCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		chatVC.coordinator = coordinator
-		navigationController.pushViewController(chatVC, animated: true)
-	}
+  let navigationController: UINavigationController
+
+  var childCoordinators: [Coordinator] = []
+
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
+
+  func showNewChatController() {
+    let newChatVC = NewChatViewController()
+    let coordinator = NewChatCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    newChatVC.coordinator = coordinator
+    navigationController.pushViewController(newChatVC, animated: true)
+  }
+
+  func showChat(chatId: Int) {
+    let chatVC = ChatViewController(chatId: chatId)
+    let coordinator = ChatViewCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    chatVC.coordinator = coordinator
+    navigationController.pushViewController(chatVC, animated: true)
+  }
 }
 
 class SettingsCoordinator: Coordinator {
-	let navigationController: UINavigationController
+  let navigationController: UINavigationController
 
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
 
-	func showAccountSetupController() {
-		let accountSetupVC = AccountSetupController()
-		navigationController.pushViewController(accountSetupVC, animated: true)
-	}
+  func showAccountSetupController() {
+    let accountSetupVC = AccountSetupController()
+    navigationController.pushViewController(accountSetupVC, animated: true)
+  }
 }
 
 class NewChatCoordinator: Coordinator {
-	let navigationController: UINavigationController
-
-	private var childCoordinators: [Coordinator] = []
-
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
-
-	func showNewGroupController() {
-		let newGroupController = NewGroupViewController()
-		let coordinator = NewGroupCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		newGroupController.coordinator = coordinator
-		navigationController.pushViewController(newGroupController, animated: true)
-	}
-
-	func showQRCodeController() {
-		let controller = QrCodeReaderController()
-		// controller.delegate = self
-		// present(controller, animated: true, completion: nil)
-	}
-
-	func showNewContactController() {
-		let newContactController = NewContactController()
-		navigationController.pushViewController(newContactController, animated: true)
-	}
-
-	func showNewChat(contactId: Int) {
-		let chatId = dc_create_chat_by_contact_id(mailboxPointer, UInt32(contactId))
-		showChat(chatId: Int(chatId))
-	}
-
-	func showChat(chatId: Int) {
-		let chatViewController = ChatViewController(chatId: chatId)
-		let coordinator = ChatViewCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		chatViewController.coordinator = coordinator
-		navigationController.pushViewController(chatViewController, animated: true)
-		navigationController.viewControllers.remove(at: 1)
-	}
+  let navigationController: UINavigationController
+
+  private var childCoordinators: [Coordinator] = []
+
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
+
+  func showNewGroupController() {
+    let newGroupController = NewGroupViewController()
+    let coordinator = NewGroupCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    newGroupController.coordinator = coordinator
+    navigationController.pushViewController(newGroupController, animated: true)
+  }
+
+  func showQRCodeController() {
+    let controller = QrCodeReaderController()
+    // controller.delegate = self
+    // present(controller, animated: true, completion: nil)
+  }
+
+  func showNewContactController() {
+    let newContactController = NewContactController()
+    navigationController.pushViewController(newContactController, animated: true)
+  }
+
+  func showNewChat(contactId: Int) {
+    let chatId = dc_create_chat_by_contact_id(mailboxPointer, UInt32(contactId))
+    showChat(chatId: Int(chatId))
+  }
+
+  func showChat(chatId: Int) {
+    let chatViewController = ChatViewController(chatId: chatId)
+    let coordinator = ChatViewCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    chatViewController.coordinator = coordinator
+    navigationController.pushViewController(chatViewController, animated: true)
+    navigationController.viewControllers.remove(at: 1)
+  }
 }
 
 class ChatDetailCoordinator: Coordinator {
-	let navigationController: UINavigationController
+  let navigationController: UINavigationController
 
-	private var childCoordinators: [Coordinator] = []
+  private var childCoordinators: [Coordinator] = []
 
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
 
-	func showSingleChatEdit(contactId: Int) {
-		let newContactController = NewContactController(contactIdForUpdate: contactId)
-		navigationController.pushViewController(newContactController, animated: true)
-	}
+  func showSingleChatEdit(contactId: Int) {
+    let newContactController = NewContactController(contactIdForUpdate: contactId)
+    navigationController.pushViewController(newContactController, animated: true)
+  }
 
-	func showAddGroupMember(chatId: Int) {
-		let groupMemberViewController = AddGroupMembersViewController(chatId: chatId)
-		navigationController.pushViewController(groupMemberViewController, animated: true)
-	}
+  func showAddGroupMember(chatId: Int) {
+    let groupMemberViewController = AddGroupMembersViewController(chatId: chatId)
+    navigationController.pushViewController(groupMemberViewController, animated: true)
+  }
 }
 
 class ChatViewCoordinator: Coordinator {
-	let navigationController: UINavigationController
-
-	var childCoordinators: [Coordinator] = []
-
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
-
-	func showChatDetail(chatId: Int) {
-		let chat = MRChat(id: chatId)
-		let chatDetailViewController: ChatDetailViewController
-		switch chat.chatType  {
-		case .SINGLE:
-			chatDetailViewController = SingleChatDetailViewController(chatId: chatId)	// inherits from ChatDetailViewController
-		case .GROUP, .VERYFIEDGROUP:
-			chatDetailViewController = GroupChatDetailViewController(chatId: chatId) // inherits from ChatDetailViewController
-		}
-		let coordinator = ChatDetailCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		chatDetailViewController.coordinator = coordinator
-		navigationController.pushViewController(chatDetailViewController, animated: true)
-	}
+  let navigationController: UINavigationController
+
+  var childCoordinators: [Coordinator] = []
+
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
+
+  func showChatDetail(chatId: Int) {
+    let chat = MRChat(id: chatId)
+    let chatDetailViewController: ChatDetailViewController
+    switch chat.chatType {
+    case .SINGLE:
+      chatDetailViewController = SingleChatDetailViewController(chatId: chatId) // inherits from ChatDetailViewController
+    case .GROUP, .VERYFIEDGROUP:
+      chatDetailViewController = GroupChatDetailViewController(chatId: chatId) // inherits from ChatDetailViewController
+    }
+    let coordinator = ChatDetailCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    chatDetailViewController.coordinator = coordinator
+    navigationController.pushViewController(chatDetailViewController, animated: true)
+  }
 }
 
 class NewGroupCoordinator: Coordinator {
-	let navigationController: UINavigationController
+  let navigationController: UINavigationController
 
-	private var childCoordinators: [Coordinator] = []
+  private var childCoordinators: [Coordinator] = []
 
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
 
-	func showGroupNameController(contactIdsForGroup: Set<Int>) {
-		let groupNameController = GroupNameController(contactIdsForGroup: contactIdsForGroup)
-		let coordinator = GroupNameCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		groupNameController.coordinator = coordinator
-		navigationController.pushViewController(groupNameController, animated: true)
-	}
+  func showGroupNameController(contactIdsForGroup: Set<Int>) {
+    let groupNameController = GroupNameController(contactIdsForGroup: contactIdsForGroup)
+    let coordinator = GroupNameCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    groupNameController.coordinator = coordinator
+    navigationController.pushViewController(groupNameController, animated: true)
+  }
 }
 
 class GroupNameCoordinator: Coordinator {
-	let navigationController: UINavigationController
-
-	private var childCoordinators: [Coordinator] = []
-
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
-
-	func showGroupChat(chatId: Int) {
-		let chatViewController = ChatViewController(chatId: chatId)
-		let coordinator = ChatViewCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		chatViewController.coordinator = coordinator
-		navigationController.popToRootViewController(animated: false)
-		navigationController.pushViewController(chatViewController, animated: true)
-	}
+  let navigationController: UINavigationController
+
+  private var childCoordinators: [Coordinator] = []
+
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
+
+  func showGroupChat(chatId: Int) {
+    let chatViewController = ChatViewController(chatId: chatId)
+    let coordinator = ChatViewCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    chatViewController.coordinator = coordinator
+    navigationController.popToRootViewController(animated: false)
+    navigationController.pushViewController(chatViewController, animated: true)
+  }
 }
 
 class ContactDetailCoordinator: Coordinator {
-	let navigationController: UINavigationController
-
-	private var childCoordinators: [Coordinator] = []
-
-	init(navigationController: UINavigationController) {
-		self.navigationController = navigationController
-	}
-
-	func showChat(chatId: Int) {
-		let chatViewController = ChatViewController(chatId: chatId)
-		let coordinator = ChatViewCoordinator(navigationController: navigationController)
-		childCoordinators.append(coordinator)
-		chatViewController.coordinator = coordinator
-		navigationController.popToRootViewController(animated: false)
-		navigationController.pushViewController(chatViewController, animated: true)
-	}
-
+  let navigationController: UINavigationController
+
+  private var childCoordinators: [Coordinator] = []
+
+  init(navigationController: UINavigationController) {
+    self.navigationController = navigationController
+  }
+
+  func showChat(chatId: Int) {
+    let chatViewController = ChatViewController(chatId: chatId)
+    let coordinator = ChatViewCoordinator(navigationController: navigationController)
+    childCoordinators.append(coordinator)
+    chatViewController.coordinator = coordinator
+    navigationController.popToRootViewController(animated: false)
+    navigationController.pushViewController(chatViewController, animated: true)
+  }
 }

+ 9 - 9
deltachat-ios/DC/Wrapper.swift

@@ -341,9 +341,9 @@ class MRMessage: MessageType {
 }
 
 enum ChatType: Int {
-	case SINGLE = 100
-	case GROUP = 120
-	case VERYFIEDGROUP = 130
+  case SINGLE = 100
+  case GROUP = 120
+  case VERYFIEDGROUP = 130
 }
 
 class MRChat {
@@ -364,9 +364,9 @@ class MRChat {
     return Int(chatPointer.pointee.type)
   }
 
-	var chatType: ChatType {
-		return ChatType(rawValue: type) ?? ChatType.GROUP // group as fallback - shouldn't get here
-	}
+  var chatType: ChatType {
+    return ChatType(rawValue: type) ?? ChatType.GROUP // group as fallback - shouldn't get here
+  }
 
   var color: UIColor {
     return UIColor(netHex: Int(dc_chat_get_color(chatPointer)))
@@ -376,9 +376,9 @@ class MRChat {
     return dc_chat_is_verified(chatPointer) > 0
   }
 
-	var contactIds: [Int] {
-		return Utils.copyAndFreeArray(inputArray: dc_get_chat_contacts(mailboxPointer, UInt32(id)))
-	}
+  var contactIds: [Int] {
+    return Utils.copyAndFreeArray(inputArray: dc_get_chat_contacts(mailboxPointer, UInt32(id)))
+  }
 
   lazy var profileImage: UIImage? = { [unowned self] in
     let file = dc_chat_get_profile_image(chatPointer)

+ 1 - 1
deltachat-ios/Helper/Constants.swift

@@ -20,7 +20,7 @@ struct Constants {
     static let deltachatImapEmailKey = "__DELTACHAT_IMAP_EMAIL_KEY__"
     static let deltachatImapPasswordKey = "__DELTACHAT_IMAP_PASSWORD_KEY__"
   }
-	
+
   static let defaultShadow = UIImage(color: UIColor(hexString: "ff2b82"), size: CGSize(width: 1, height: 1))
   static let onlineShadow = UIImage(color: UIColor(hexString: "3ed67e"), size: CGSize(width: 1, height: 1))
 

+ 0 - 1
deltachat-ios/Helper/Utils.swift

@@ -15,7 +15,6 @@ struct Utils {
     return Utils.copyAndFreeArray(inputArray: cContacts)
   }
 
-
   static func getInitials(inputName: String) -> String {
     let nameParts = inputName.split(separator: " ")
     let initials: [Character] = nameParts.compactMap { part in part.capitalized.first }

+ 9 - 9
deltachat-ios/View/ActionCell.swift

@@ -17,11 +17,11 @@ class ActionCell: UITableViewCell {
     }
   }
 
-	var actionColor: UIColor? {
-		didSet {
-			actionLabel.textColor = actionColor ?? UIColor.systemBlue
-		}
-	}
+  var actionColor: UIColor? {
+    didSet {
+      actionLabel.textColor = actionColor ?? UIColor.systemBlue
+    }
+  }
 
   private lazy var actionLabel: UILabel = {
     let label = UILabel()
@@ -33,14 +33,14 @@ class ActionCell: UITableViewCell {
   // use this constructor if cell won't be reused
   convenience init(title: String) {
     self.init(style: .default, reuseIdentifier: nil)
-		actionTitle = title
-		selectionStyle = .none
-	}
+    actionTitle = title
+    selectionStyle = .none
+  }
 
   override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
     super.init(style: style, reuseIdentifier: reuseIdentifier)
     setupSubviews()
-		selectionStyle = .none
+    selectionStyle = .none
   }
 
   required init?(coder _: NSCoder) {

+ 3 - 5
deltachat-ios/View/ContactCell.swift

@@ -58,11 +58,9 @@ class ContactCell: UITableViewCell {
   }
 
   override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
-
-		super.init(style: style, reuseIdentifier: reuseIdentifier)
-		selectionStyle = .none
-		setupSubviews()
-
+    super.init(style: style, reuseIdentifier: reuseIdentifier)
+    selectionStyle = .none
+    setupSubviews()
   }
 
   private func setupSubviews() {

+ 6 - 6
deltachat-ios/View/GroupNameCell.swift

@@ -9,14 +9,14 @@
 import UIKit
 
 class GroupLabelCell: UITableViewCell {
-	var groupBadgeSize: CGFloat = 54
+  var groupBadgeSize: CGFloat = 54
 
   var groupNameUpdated: ((String) -> Void)? // use this callback to update editButton in navigationController
 
   lazy var groupBadge: InitialsBadge = {
     let badge = InitialsBadge(frame: .zero)
-		badge.layer.cornerRadius = groupBadgeSize / 2
-		badge.clipsToBounds = true
+    badge.layer.cornerRadius = groupBadgeSize / 2
+    badge.clipsToBounds = true
     badge.setColor(UIColor.lightGray)
     return badge
   }()
@@ -65,7 +65,7 @@ class GroupLabelCell: UITableViewCell {
     groupNameUpdated?(groupName)
   }
 
-	func getGroupName() -> String {
-		return inputField.text ?? ""
-	}
+  func getGroupName() -> String {
+    return inputField.text ?? ""
+  }
 }

+ 38 - 40
deltachat-ios/View/InitialsBadge.swift

@@ -8,47 +8,45 @@
 
 import UIKit
 
-
 // shall be used for contactCell/ groups
 
 class InitialsBadge: UIView {
-
-	private lazy var label: UILabel = {
-		let label = UILabel()
-		label.textAlignment = NSTextAlignment.center
-		label.textColor = UIColor.white
-		label.font = UIFont.systemFont(ofSize: 22)
-		// label.adjustsFontSizeToFitWidth = true
-		return label
-	}()
-
-	override init(frame: CGRect) {
-		super.init(frame: frame)
-		setupSubviews()
-
-		layer.cornerRadius = frame.width / 2
-		clipsToBounds = true
-	}
-	
-	required init?(coder aDecoder: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-	private func setupSubviews() {
-		addSubview(label)
-		label.translatesAutoresizingMaskIntoConstraints = false
-		label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 2).isActive = true
-		label.topAnchor.constraint(equalTo: topAnchor, constant: 2).isActive = true
-		label.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -2).isActive = true
-		label.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -2).isActive = true
-	}
-
-	func setColor(_ color: UIColor) {
-		backgroundColor = color
-	}
-
-	func setText(_ text: String) {
-		let initials = Utils.getInitials(inputName: text)
-		label.text = initials
-	}
+  private lazy var label: UILabel = {
+    let label = UILabel()
+    label.textAlignment = NSTextAlignment.center
+    label.textColor = UIColor.white
+    label.font = UIFont.systemFont(ofSize: 22)
+    // label.adjustsFontSizeToFitWidth = true
+    return label
+  }()
+
+  override init(frame: CGRect) {
+    super.init(frame: frame)
+    setupSubviews()
+
+    layer.cornerRadius = frame.width / 2
+    clipsToBounds = true
+  }
+
+  required init?(coder _: NSCoder) {
+    fatalError("init(coder:) has not been implemented")
+  }
+
+  private func setupSubviews() {
+    addSubview(label)
+    label.translatesAutoresizingMaskIntoConstraints = false
+    label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 2).isActive = true
+    label.topAnchor.constraint(equalTo: topAnchor, constant: 2).isActive = true
+    label.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -2).isActive = true
+    label.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -2).isActive = true
+  }
+
+  func setColor(_ color: UIColor) {
+    backgroundColor = color
+  }
+
+  func setText(_ text: String) {
+    let initials = Utils.getInitials(inputName: text)
+    label.text = initials
+  }
 }