|
@@ -1,80 +0,0 @@
|
|
|
-//
|
|
|
-// NewGroupViewController.swift
|
|
|
-// deltachat-ios
|
|
|
-//
|
|
|
-// Created by Alla Reinsch on 17.07.18.
|
|
|
-// Copyright © 2018 Jonas Reinsch. All rights reserved.
|
|
|
-//
|
|
|
-
|
|
|
-import UIKit
|
|
|
-
|
|
|
-class NewGroupViewController: UITableViewController {
|
|
|
- weak var coordinator: NewGroupCoordinator?
|
|
|
-
|
|
|
- let contactCellReuseIdentifier = "xyz"
|
|
|
- var contactIds: [Int] = Utils.getContactIds()
|
|
|
- var contactIdsForGroup: Set<Int> = [] {
|
|
|
- didSet {
|
|
|
- let c = contactIdsForGroup.count
|
|
|
- navigationItem.prompt = "\(c) members and me"
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override func viewDidLoad() {
|
|
|
- super.viewDidLoad()
|
|
|
- title = "New Group"
|
|
|
- navigationItem.prompt = "0 members and me"
|
|
|
- tableView.register(ContactCell.self, forCellReuseIdentifier: contactCellReuseIdentifier)
|
|
|
- navigationController?.navigationBar.prefersLargeTitles = false
|
|
|
- let groupCreationNextButton = UIBarButtonItem(title: "Next", style: .done, target: self, action: #selector(nextButtonPressed))
|
|
|
- navigationItem.rightBarButtonItem = groupCreationNextButton
|
|
|
- }
|
|
|
-
|
|
|
- override func didReceiveMemoryWarning() {
|
|
|
- super.didReceiveMemoryWarning()
|
|
|
- }
|
|
|
-
|
|
|
- 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.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 contactIdsForGroup.contains(contactId) {
|
|
|
- contactIdsForGroup.remove(contactId)
|
|
|
- cell.accessoryType = .none
|
|
|
- } else {
|
|
|
- contactIdsForGroup.insert(contactId)
|
|
|
- cell.accessoryType = .checkmark
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @objc func nextButtonPressed() {
|
|
|
- coordinator?.showGroupNameController(contactIdsForGroup: contactIdsForGroup)
|
|
|
- }
|
|
|
-}
|