Эх сурвалжийг харах

newGroupViewController now inherits from GroupMemberViewController

Bastian van de Wetering 6 жил өмнө
parent
commit
9d96c4275d

+ 0 - 4
deltachat-ios.xcodeproj/project.pbxproj

@@ -8,7 +8,6 @@
 
 /* Begin PBXBuildFile section */
 		6795F63A82E94FF7CD2CEC0F /* Pods_deltachat_iosTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F7009234DB9408201A6CDCB /* Pods_deltachat_iosTests.framework */; };
-		7070FB3D20FDD9FE000DC258 /* NewGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7070FB3C20FDD9FE000DC258 /* NewGroupViewController.swift */; };
 		7070FB4020FF3421000DC258 /* dc_chat.c in Sources */ = {isa = PBXBuildFile; fileRef = 7070FB3E20FF3420000DC258 /* dc_chat.c */; };
 		7070FB4120FF3421000DC258 /* dc_smtp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7070FB3F20FF3421000DC258 /* dc_smtp.c */; };
 		7070FB5D20FF345F000DC258 /* dc_mimefactory.c in Sources */ = {isa = PBXBuildFile; fileRef = 7070FB4220FF345B000DC258 /* dc_mimefactory.c */; };
@@ -144,7 +143,6 @@
 		21EE28844E7A690D73BF5285 /* Pods-deltachat-iosTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-deltachat-iosTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-deltachat-iosTests/Pods-deltachat-iosTests.debug.xcconfig"; sourceTree = "<group>"; };
 		2F7009234DB9408201A6CDCB /* Pods_deltachat_iosTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_iosTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		6241BE1534A653E79AD5D01D /* Pods_deltachat_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
-		7070FB3C20FDD9FE000DC258 /* NewGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewGroupViewController.swift; sourceTree = "<group>"; };
 		7070FB3E20FF3420000DC258 /* dc_chat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dc_chat.c; sourceTree = "<group>"; };
 		7070FB3F20FF3421000DC258 /* dc_smtp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dc_smtp.c; sourceTree = "<group>"; };
 		7070FB4220FF345B000DC258 /* dc_mimefactory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dc_mimefactory.c; sourceTree = "<group>"; };
@@ -599,7 +597,6 @@
 				78E45E3F21D3D70700D4B15E /* ContactListController.swift */,
 				78ED838E21D5927A00243125 /* ProfileViewController.swift */,
 				78E45E3921D3CFBC00D4B15E /* SettingsController.swift */,
-				7070FB3C20FDD9FE000DC258 /* NewGroupViewController.swift */,
 				7070FB9A2101ECBB000DC258 /* GroupNameController.swift */,
 				AE851ACF227DF50900ED86F0 /* SingleChatDetailViewController.swift */,
 				AEE6EC3E2282C59C00EDC689 /* AddGroupMembersViewController.swift */,
@@ -952,7 +949,6 @@
 				7070FB6D20FF345F000DC258 /* dc_imex.c in Sources */,
 				7070FB6620FF345F000DC258 /* dc_param.c in Sources */,
 				7070FB9220FF4118000DC258 /* dc_imap.c in Sources */,
-				7070FB3D20FDD9FE000DC258 /* NewGroupViewController.swift in Sources */,
 				7070FB7720FF345F000DC258 /* dc_qr.c in Sources */,
 				78E45E4421D3F14A00D4B15E /* UIImage+Extension.swift in Sources */,
 				70B08FCD21073B910097D3EA /* NewGroupMemberChoiceController.swift in Sources */,

+ 38 - 5
deltachat-ios/Controller/AddGroupMembersViewController.swift

@@ -8,6 +8,28 @@
 
 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)
+	}
+}
+
 class AddGroupMembersViewController: GroupMembersViewController {
 
 	private var chatId: Int?
@@ -24,7 +46,6 @@ class AddGroupMembersViewController: GroupMembersViewController {
 		}
 	}
 
-
 	private lazy var chat: MRChat? = {
 		if let chatId = chatId {
 			return MRChat(id: chatId)
@@ -48,11 +69,15 @@ class AddGroupMembersViewController: GroupMembersViewController {
 	}()
 
 
-	convenience init(chatId: Int) {
-		self.init(nibName: nil, bundle: nil)
+	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
@@ -75,8 +100,7 @@ class AddGroupMembersViewController: GroupMembersViewController {
 		tableView.reloadData()
 	}
 }
-
-
+ 	
 class GroupMembersViewController : UITableViewController {
 
 	let contactCellReuseIdentifier = "contactCell"
@@ -89,6 +113,15 @@ class GroupMembersViewController : UITableViewController {
 
 	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)
 	}

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

@@ -59,6 +59,7 @@ class NewChatViewController: UITableViewController {
 
   init() {
     super.init(style: .grouped)
+		hidesBottomBarWhenPushed = true
   }
 
   required init?(coder _: NSCoder) {
@@ -79,8 +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
     }

+ 0 - 80
deltachat-ios/Controller/NewGroupViewController.swift

@@ -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)
-  }
-}

+ 0 - 1
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -155,7 +155,6 @@ class ChatListCoordinator: Coordinator {
 		let coordinator = NewChatCoordinator(navigationController: navigationController)
 		childCoordinators.append(coordinator)
 		newChatVC.coordinator = coordinator
-		newChatVC.hidesBottomBarWhenPushed = true
 		navigationController.pushViewController(newChatVC, animated: true)
 	}