Parcourir la source

use 'self.navigationController?' instead of 'self.parent as? UINavigationController

B. Petersen il y a 5 ans
Parent
commit
bd3a0b71cc

+ 10 - 18
deltachat-ios/Controller/AccountSetupController.swift

@@ -846,27 +846,21 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
 
     // MARK: - coordinator
     func showCertCheckOptions() {
-        if let navigationController = self.parent as? UINavigationController {
-            let certificateCheckController = CertificateCheckController(dcContext: dcContext, sectionTitle: String.localized("login_certificate_checks"))
-            navigationController.pushViewController(certificateCheckController, animated: true)
-        }
+        let certificateCheckController = CertificateCheckController(dcContext: dcContext, sectionTitle: String.localized("login_certificate_checks"))
+        navigationController?.pushViewController(certificateCheckController, animated: true)
     }
 
     func showImapSecurityOptions() {
-        if let navigationController = self.parent as? UINavigationController {
-            let securitySettingsController = SecuritySettingsController(dcContext: dcContext, title: String.localized("login_imap_security"),
-                                                                          type: SecurityType.IMAPSecurity)
-            navigationController.pushViewController(securitySettingsController, animated: true)
-        }
+        let securitySettingsController = SecuritySettingsController(dcContext: dcContext, title: String.localized("login_imap_security"),
+                                                                      type: SecurityType.IMAPSecurity)
+        navigationController?.pushViewController(securitySettingsController, animated: true)
     }
 
     func showSmptpSecurityOptions() {
-        if let navigationController = self.parent as? UINavigationController {
-            let securitySettingsController = SecuritySettingsController(dcContext: dcContext,
-                                                                        title: String.localized("login_imap_security"),
-                                                                        type: SecurityType.SMTPSecurity)
-            navigationController.pushViewController(securitySettingsController, animated: true)
-        }
+        let securitySettingsController = SecuritySettingsController(dcContext: dcContext,
+                                                                    title: String.localized("login_imap_security"),
+                                                                    type: SecurityType.SMTPSecurity)
+        navigationController?.pushViewController(securitySettingsController, animated: true)
     }
 
     func openProviderInfo(provider: DcProvider) {
@@ -875,9 +869,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
     }
 
     func navigateBack() {
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popViewController(animated: true)
-        }
+        navigationController?.popViewController(animated: true)
     }
 }
 

+ 7 - 13
deltachat-ios/Controller/ChatListController.swift

@@ -362,25 +362,19 @@ class ChatListController: UITableViewController {
 
     // MARK: - coordinator
     func showNewChatController() {
-        if let navigationController = self.parent as? UINavigationController {
-            let newChatVC = NewChatViewController(dcContext: dcContext)
-            navigationController.pushViewController(newChatVC, animated: true)
-        }
+        let newChatVC = NewChatViewController(dcContext: dcContext)
+        navigationController?.pushViewController(newChatVC, animated: true)
     }
 
     func showChat(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let chatVC = ChatViewController(dcContext: dcContext, chatId: chatId)
-            navigationController.pushViewController(chatVC, animated: true)
-        }
+        let chatVC = ChatViewController(dcContext: dcContext, chatId: chatId)
+        navigationController?.pushViewController(chatVC, animated: true)
     }
 
     func showArchive() {
-        if let navigationController = self.parent as? UINavigationController {
-            let viewModel = ChatListViewModel(dcContext: dcContext, isArchive: true)
-            let controller = ChatListController(dcContext: dcContext, viewModel: viewModel)
-            navigationController.pushViewController(controller, animated: true)
-        }
+        let viewModel = ChatListViewModel(dcContext: dcContext, isArchive: true)
+        let controller = ChatListController(dcContext: dcContext, viewModel: viewModel)
+        navigationController?.pushViewController(controller, animated: true)
     }
 
     func showNewChat(contactId: Int) {

+ 21 - 29
deltachat-ios/Controller/ChatViewController.swift

@@ -64,7 +64,7 @@ class ChatViewController: MessagesViewController {
     var previewView: UIView?
 
     private lazy var mediaPicker: MediaPicker? = {
-        if let navigationController = self.parent as? UINavigationController {
+        if let navigationController = navigationController {
             return MediaPicker(navigationController: navigationController)
         } else {
             return nil
@@ -641,39 +641,33 @@ class ChatViewController: MessagesViewController {
 
     // MARK: - coordinator
     func navigateBack() {
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popViewController(animated: true)
-        }
+        navigationController?.popViewController(animated: true)
     }
 
     func showChatDetail(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let chat = dcContext.getChat(chatId: chatId)
-            switch chat.chatType {
-            case .SINGLE:
-                if let contactId = chat.contactIds.first {
-                    let viewModel = ContactDetailViewModel(contactId: contactId, chatId: chatId, context: dcContext)
-                    let contactDetailController = ContactDetailViewController(viewModel: viewModel)
-                    navigationController.pushViewController(contactDetailController, animated: true)
-                }
-            case .GROUP, .VERIFIEDGROUP:
-                let groupChatDetailViewController = GroupChatDetailViewController(chatId: chatId, dcContext: dcContext)
-                navigationController.pushViewController(groupChatDetailViewController, animated: true)
+        let chat = dcContext.getChat(chatId: chatId)
+        switch chat.chatType {
+        case .SINGLE:
+            if let contactId = chat.contactIds.first {
+                let viewModel = ContactDetailViewModel(contactId: contactId, chatId: chatId, context: dcContext)
+                let contactDetailController = ContactDetailViewController(viewModel: viewModel)
+                navigationController?.pushViewController(contactDetailController, animated: true)
             }
+        case .GROUP, .VERIFIEDGROUP:
+            let groupChatDetailViewController = GroupChatDetailViewController(chatId: chatId, dcContext: dcContext)
+            navigationController?.pushViewController(groupChatDetailViewController, animated: true)
         }
     }
 
     func showContactDetail(of contactId: Int, in chatOfType: ChatType, chatId: Int?) {
-        if let navigationController = self.parent as? UINavigationController {
-            let viewModel = ContactDetailViewModel(contactId: contactId, chatId: chatId, context: dcContext )
-            let contactDetailController = ContactDetailViewController(viewModel: viewModel)
-            navigationController.pushViewController(contactDetailController, animated: true)
-        }
+        let viewModel = ContactDetailViewModel(contactId: contactId, chatId: chatId, context: dcContext )
+        let contactDetailController = ContactDetailViewController(viewModel: viewModel)
+        navigationController?.pushViewController(contactDetailController, animated: true)
     }
 
     func showChat(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController, let appDelegate = UIApplication.shared.delegate as? AppDelegate {
-            navigationController.popToRootViewController(animated: false)
+        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
+            navigationController?.popToRootViewController(animated: false)
             appDelegate.appCoordinator.showChat(chatId: chatId)
         }
     }
@@ -695,12 +689,10 @@ class ChatViewController: MessagesViewController {
     }
 
     func showMediaGallery(currentIndex: Int, mediaUrls urls: [URL]) {
-        if let navigationController = self.parent as? UINavigationController {
-            let betterPreviewController = PreviewController(currentIndex: currentIndex, urls: urls)
-            let nav = UINavigationController(rootViewController: betterPreviewController)
-            nav.modalPresentationStyle = .fullScreen
-            navigationController.present(nav, animated: true)
-        }
+        let betterPreviewController = PreviewController(currentIndex: currentIndex, urls: urls)
+        let nav = UINavigationController(rootViewController: betterPreviewController)
+        nav.modalPresentationStyle = .fullScreen
+        navigationController?.present(nav, animated: true)
     }
 }
 

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

@@ -278,18 +278,14 @@ class ContactDetailViewController: UITableViewController {
 
     // MARK: - coordinator
     func showChat(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let chatViewController = ChatViewController(dcContext: viewModel.context, chatId: chatId)
-            navigationController.popToRootViewController(animated: false)
-            navigationController.pushViewController(chatViewController, animated: true)
-        }
+        let chatViewController = ChatViewController(dcContext: viewModel.context, chatId: chatId)
+        navigationController?.popToRootViewController(animated: false)
+        navigationController?.pushViewController(chatViewController, animated: true)
     }
 
     func showEditContact(contactId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let editContactController = EditContactController(dcContext: viewModel.context, contactIdForUpdate: contactId)
-            navigationController.pushViewController(editContactController, animated: true)
-        }
+        let editContactController = EditContactController(dcContext: viewModel.context, contactIdForUpdate: contactId)
+        navigationController?.pushViewController(editContactController, animated: true)
     }
 
     func showDocuments() {
@@ -311,14 +307,14 @@ class ContactDetailViewController: UITableViewController {
             }
         }
         previewController = PreviewController(currentIndex: 0, urls: mediaUrls)
-        if let navigationController = self.parent as? UINavigationController, let previewController = previewController {
-            navigationController.pushViewController(previewController, animated: true)
+        if let previewController = previewController {
+            navigationController?.pushViewController(previewController, animated: true)
         }
     }
 
 
     func deleteChat() {
-        guard let chatId = viewModel.chatId, let navigationController = self.parent as? UINavigationController else {
+        guard let chatId = viewModel.chatId else {
             return
         }
 
@@ -330,21 +326,17 @@ class ContactDetailViewController: UITableViewController {
             NotificationCenter.default.post(name: dcNotificationChatDeletedInChatDetail, object: nil, userInfo: ["chat_id": chatId])
         }
 
-        func showArchive() {
-            navigationController.popToRootViewController(animated: false) // in main ChatList now
-            let chatlistVM = ChatListViewModel(dcContext: viewModel.context, isArchive: true)
-            let controller = ChatListController(dcContext: viewModel.context, viewModel: chatlistVM)
-            navigationController.pushViewController(controller, animated: false)
-        }
-
         CATransaction.begin()
         CATransaction.setCompletionBlock(notifyToDeleteChat)
 
         let chat = viewModel.context.getChat(chatId: chatId)
         if chat.isArchived {
-            showArchive()
+            navigationController?.popToRootViewController(animated: false) // in main ChatList now
+            let chatlistVM = ChatListViewModel(dcContext: viewModel.context, isArchive: true)
+            let controller = ChatListController(dcContext: viewModel.context, viewModel: chatlistVM)
+            navigationController?.pushViewController(controller, animated: false)
         } else {
-            navigationController.popToRootViewController(animated: true) // in main ChatList now
+            navigationController?.popToRootViewController(animated: true) // in main ChatList now
         }
         CATransaction.commit()
     }

+ 2 - 4
deltachat-ios/Controller/EditGroupViewController.swift

@@ -12,7 +12,7 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
     var avatarSelectionCell: AvatarSelectionCell
 
     private lazy var mediaPicker: MediaPicker? = {
-        if let navigationController = self.parent as? UINavigationController {
+        if let navigationController = navigationController {
             return MediaPicker(navigationController: navigationController)
         } else {
             return nil
@@ -132,8 +132,6 @@ class EditGroupViewController: UITableViewController, MediaPickerDelegate {
 
     // MARK: - coordinator
     func navigateBack() {
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popViewController(animated: true)
-        }
+        navigationController?.popViewController(animated: true)
     }
 }

+ 38 - 56
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -191,39 +191,29 @@ class GroupChatDetailViewController: UIViewController {
 
     // MARK: - coordinator
     func showSingleChatEdit(contactId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let editContactController = EditContactController(dcContext: dcContext, contactIdForUpdate: contactId)
-            navigationController.pushViewController(editContactController, animated: true)
-        }
+        let editContactController = EditContactController(dcContext: dcContext, contactIdForUpdate: contactId)
+        navigationController?.pushViewController(editContactController, animated: true)
     }
 
     func showAddGroupMember(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let groupMemberViewController = AddGroupMembersViewController(chatId: chatId)
-            navigationController.pushViewController(groupMemberViewController, animated: true)
-        }
+        let groupMemberViewController = AddGroupMembersViewController(chatId: chatId)
+        navigationController?.pushViewController(groupMemberViewController, animated: true)
     }
 
     func showQrCodeInvite(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let qrInviteCodeController = QrInviteViewController(dcContext: dcContext, chatId: chatId)
-            navigationController.pushViewController(qrInviteCodeController, animated: true)
-        }
+        let qrInviteCodeController = QrInviteViewController(dcContext: dcContext, chatId: chatId)
+        navigationController?.pushViewController(qrInviteCodeController, animated: true)
     }
 
     func showGroupChatEdit(chat: DcChat) {
-        if let navigationController = self.parent as? UINavigationController {
-            let editGroupViewController = EditGroupViewController(dcContext: dcContext, chat: chat)
-            navigationController.pushViewController(editGroupViewController, animated: true)
-        }
+        let editGroupViewController = EditGroupViewController(dcContext: dcContext, chat: chat)
+        navigationController?.pushViewController(editGroupViewController, animated: true)
     }
 
     func showContactDetail(of contactId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let viewModel = ContactDetailViewModel(contactId: contactId, chatId: nil, context: dcContext)
-            let contactDetailController = ContactDetailViewController(viewModel: viewModel)
-            navigationController.pushViewController(contactDetailController, animated: true)
-        }
+        let viewModel = ContactDetailViewModel(contactId: contactId, chatId: nil, context: dcContext)
+        let contactDetailController = ContactDetailViewController(viewModel: viewModel)
+        navigationController?.pushViewController(contactDetailController, animated: true)
     }
 
     func showDocuments() {
@@ -234,49 +224,41 @@ class GroupChatDetailViewController: UIViewController {
         presentPreview(for: DC_MSG_IMAGE, messageType2: DC_MSG_GIF, messageType3: DC_MSG_VIDEO)
     }
 
-    private func presentPreview(for messageType: Int32, messageType2: Int32, messageType3: Int32) {
-        if let navigationController = self.parent as? UINavigationController {
-            let messageIds = dcContext.getChatMedia(chatId: chatId, messageType: messageType, messageType2: messageType2, messageType3: messageType3)
-            var mediaUrls: [URL] = []
-            for messageId in messageIds {
-                let message = DcMsg.init(id: messageId)
-                if let url = message.fileURL {
-                    mediaUrls.insert(url, at: 0)
-                }
+private func presentPreview(for messageType: Int32, messageType2: Int32, messageType3: Int32) {
+        let messageIds = dcContext.getChatMedia(chatId: chatId, messageType: messageType, messageType2: messageType2, messageType3: messageType3)
+        var mediaUrls: [URL] = []
+        for messageId in messageIds {
+            let message = DcMsg.init(id: messageId)
+            if let url = message.fileURL {
+                mediaUrls.insert(url, at: 0)
             }
-            let previewController = PreviewController(currentIndex: 0, urls: mediaUrls)
-            navigationController.pushViewController(previewController, animated: true)
         }
+        let previewController = PreviewController(currentIndex: 0, urls: mediaUrls)
+        navigationController?.pushViewController(previewController, animated: true)
     }
 
     func deleteChat() {
-        if let navigationController = self.parent as? UINavigationController {
-            /*
-            app will navigate to chatlist or archive and delete the chat there
-            notify chatList/archiveList to delete chat AFTER is is visible
-            */
-            func notifyToDeleteChat() {
-                NotificationCenter.default.post(name: dcNotificationChatDeletedInChatDetail, object: nil, userInfo: ["chat_id": self.chatId])
-            }
-
-            func showArchive() {
-                navigationController.popToRootViewController(animated: false) // in main ChatList now
-                let viewModel = ChatListViewModel(dcContext: dcContext, isArchive: true)
-                let controller = ChatListController(dcContext: dcContext, viewModel: viewModel)
-                navigationController.pushViewController(controller, animated: false)
-            }
+        /*
+        app will navigate to chatlist or archive and delete the chat there
+        notify chatList/archiveList to delete chat AFTER is is visible
+        */
+        func notifyToDeleteChat() {
+            NotificationCenter.default.post(name: dcNotificationChatDeletedInChatDetail, object: nil, userInfo: ["chat_id": self.chatId])
+        }
 
-            CATransaction.begin()
-            CATransaction.setCompletionBlock(notifyToDeleteChat)
+        CATransaction.begin()
+        CATransaction.setCompletionBlock(notifyToDeleteChat)
 
-            let chat = dcContext.getChat(chatId: chatId)
-            if chat.isArchived {
-                showArchive()
-            } else {
-                navigationController.popToRootViewController(animated: true) // in main ChatList now
-            }
-            CATransaction.commit()
+        let chat = dcContext.getChat(chatId: chatId)
+        if chat.isArchived {
+            navigationController?.popToRootViewController(animated: false) // in main ChatList now
+            let viewModel = ChatListViewModel(dcContext: dcContext, isArchive: true)
+            let controller = ChatListController(dcContext: dcContext, viewModel: viewModel)
+            navigationController?.pushViewController(controller, animated: false)
+        } else {
+            navigationController?.popToRootViewController(animated: true) // in main ChatList now
         }
+        CATransaction.commit()
     }
 }
 

+ 3 - 5
deltachat-ios/Controller/GroupMembersViewController.swift

@@ -220,11 +220,9 @@ class AddGroupMembersViewController: GroupMembersViewController {
 
     // MARK: - coordinator
     func showNewContactController() {
-        if let navigationController = self.parent as? UINavigationController {
-            let newContactController = NewContactController(dcContext: dcContext)
-            newContactController.openChatOnSave = false
-            navigationController.pushViewController(newContactController, animated: true)
-        }
+        let newContactController = NewContactController(dcContext: dcContext)
+        newContactController.openChatOnSave = false
+        navigationController?.pushViewController(newContactController, animated: true)
     }
 }
 

+ 10 - 18
deltachat-ios/Controller/NewChatViewController.swift

@@ -329,17 +329,13 @@ class NewChatViewController: UITableViewController {
 
     // MARK: - coordinator
     func showNewGroupController(isVerified: Bool) {
-        if let navigationController = self.parent as? UINavigationController {
-            let newGroupController = NewGroupController(dcContext: dcContext, isVerified: isVerified)
-            navigationController.pushViewController(newGroupController, animated: true)
-        }
+        let newGroupController = NewGroupController(dcContext: dcContext, isVerified: isVerified)
+        navigationController?.pushViewController(newGroupController, animated: true)
     }
 
     func showNewContactController() {
-        if let navigationController = self.parent as? UINavigationController {
-            let newContactController = NewContactController(dcContext: dcContext)
-            navigationController.pushViewController(newContactController, animated: true)
-        }
+        let newContactController = NewContactController(dcContext: dcContext)
+        navigationController?.pushViewController(newContactController, animated: true)
     }
 
     func showNewChat(contactId: Int) {
@@ -348,19 +344,15 @@ class NewChatViewController: UITableViewController {
     }
 
     func showChat(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
-            navigationController.pushViewController(chatViewController, animated: true)
-            navigationController.viewControllers.remove(at: 1)
-        }
+        let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
+        navigationController?.pushViewController(chatViewController, animated: true)
+        navigationController?.viewControllers.remove(at: 1)
     }
 
     func showContactDetail(contactId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let viewModel = ContactDetailViewModel(contactId: contactId, chatId: nil, context: dcContext)
-            let contactDetailController = ContactDetailViewController(viewModel: viewModel)
-            navigationController.pushViewController(contactDetailController, animated: true)
-        }
+        let viewModel = ContactDetailViewModel(contactId: contactId, chatId: nil, context: dcContext)
+        let contactDetailController = ContactDetailViewController(viewModel: viewModel)
+        navigationController?.pushViewController(contactDetailController, animated: true)
     }
 }
 

+ 3 - 7
deltachat-ios/Controller/NewContactController.swift

@@ -101,17 +101,13 @@ class NewContactController: UITableViewController {
 
     // MARK: - coordinator
     func navigateBack() {
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popViewController(animated: true)
-        }
+        navigationController?.popViewController(animated: true)
     }
 
     func showChat(chatId: Int) {
         let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popToRootViewController(animated: false)
-            navigationController.pushViewController(chatViewController, animated: true)
-        }
+        navigationController?.popToRootViewController(animated: false)
+        navigationController?.pushViewController(chatViewController, animated: true)
     }
 }
 

+ 13 - 21
deltachat-ios/Controller/NewGroupController.swift

@@ -26,7 +26,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
     private let sectionGroupMembers = 2
 
     private lazy var mediaPicker: MediaPicker? = {
-        if let navigationController = self.parent as? UINavigationController {
+        if let navigationController = navigationController {
             return MediaPicker(navigationController: navigationController)
         } else {
             return nil
@@ -344,11 +344,9 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
 
     // MARK: - coordinator
     func showGroupChat(chatId: Int) {
-        if let navigationController = self.parent as? UINavigationController {
-            let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
-            navigationController.popToRootViewController(animated: false)
-            navigationController.pushViewController(chatViewController, animated: true)
-        }
+        let chatViewController = ChatViewController(dcContext: dcContext, chatId: chatId)
+        navigationController?.popToRootViewController(animated: false)
+        navigationController?.pushViewController(chatViewController, animated: true)
     }
 
     func showPhotoPicker(delegate: MediaPickerDelegate) {
@@ -362,32 +360,26 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
     func showQrCodeInvite(chatId: Int) {
         let qrInviteCodeController = QrInviteViewController(dcContext: dcContext, chatId: chatId)
         qrInviteCodeController.onDismissed = onQRInviteCodeControllerDismissed
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.pushViewController(qrInviteCodeController, animated: true)
-        }
+        navigationController?.pushViewController(qrInviteCodeController, animated: true)
     }
 
     func showAddMembers(preselectedMembers: Set<Int>, isVerified: Bool) {
-        if let navigationController = self.parent as? UINavigationController {
-            let newGroupController = NewGroupAddMembersViewController(preselected: preselectedMembers,
-                                                                      isVerified: isVerified)
-            newGroupController.onMembersSelected = onGroupMembersSelected(_:)
-            navigationController.pushViewController(newGroupController, animated: true)
-        }
+        let newGroupController = NewGroupAddMembersViewController(preselected: preselectedMembers,
+                                                                  isVerified: isVerified)
+        newGroupController.onMembersSelected = onGroupMembersSelected(_:)
+        navigationController?.pushViewController(newGroupController, animated: true)
     }
 
     func onQRInviteCodeControllerDismissed() {
-        if let navigationController = self.parent as? UINavigationController, let groupNameController = navigationController.topViewController as? NewGroupController {
+        if let groupNameController = navigationController?.topViewController as? NewGroupController {
             groupNameController.updateGroupContactIdsOnQRCodeInvite()
         }
     }
 
     func onGroupMembersSelected(_ memberIds: Set<Int>) {
-        if let navigationController = self.parent as? UINavigationController {
-            navigationController.popViewController(animated: true)
-            if let groupNameController = navigationController.topViewController as? NewGroupController {
-                groupNameController.updateGroupContactIdsOnListSelection(memberIds)
-            }
+        navigationController?.popViewController(animated: true)
+        if let groupNameController = navigationController?.topViewController as? NewGroupController {
+            groupNameController.updateGroupContactIdsOnListSelection(memberIds)
         }
     }
 }

+ 1 - 1
deltachat-ios/Controller/ProfileInfoViewController.swift

@@ -7,7 +7,7 @@ class ProfileInfoViewController: UITableViewController {
     private var displayName: String?
 
     private lazy var mediaPicker: MediaPicker? = {
-        if let navigationController = self.parent as? UINavigationController {
+        if let navigationController = navigationController {
             return MediaPicker(navigationController: navigationController)
         } else {
             return nil

+ 11 - 24
deltachat-ios/Controller/SettingsController.swift

@@ -444,45 +444,32 @@ internal final class SettingsViewController: UITableViewController {
 
     // MARK: - coordinator
     func showEditSettingsController() {
-        if let navigationController = self.parent as? UINavigationController {
-            let editController = EditSettingsController(dcContext: dcContext)
-            navigationController.pushViewController(editController, animated: true)
-        }
+        let editController = EditSettingsController(dcContext: dcContext)
+        navigationController?.pushViewController(editController, animated: true)
     }
 
     func showClassicMail() {
-        if let navigationController = self.parent as? UINavigationController {
-            let settingsClassicViewController = SettingsClassicViewController(dcContext: dcContext)
-            navigationController.pushViewController(settingsClassicViewController, animated: true)
-        }
+        let settingsClassicViewController = SettingsClassicViewController(dcContext: dcContext)
+        navigationController?.pushViewController(settingsClassicViewController, animated: true)
     }
 
     func showBlockedContacts() {
-        if let navigationController = self.parent as? UINavigationController {
-            let blockedContactsController = BlockedContactsViewController()
-            navigationController.pushViewController(blockedContactsController, animated: true)
-        }
+        let blockedContactsController = BlockedContactsViewController()
+        navigationController?.pushViewController(blockedContactsController, animated: true)
     }
 
     func showAutodelOptions() {
-        if let navigationController = self.parent as? UINavigationController {
-            let settingsAutodelOverviewController = SettingsAutodelOverviewController(dcContext: dcContext)
-            navigationController.pushViewController(settingsAutodelOverviewController, animated: true)
-        }
+        let settingsAutodelOverviewController = SettingsAutodelOverviewController(dcContext: dcContext)
+        navigationController?.pushViewController(settingsAutodelOverviewController, animated: true)
     }
 
     func showContactRequests() {
-        if let navigationController = self.parent as? UINavigationController {
-            let deaddropViewController = MailboxViewController(dcContext: dcContext, chatId: Int(DC_CHAT_ID_DEADDROP))
-            navigationController.pushViewController(deaddropViewController, animated: true)
-        }
+        let deaddropViewController = MailboxViewController(dcContext: dcContext, chatId: Int(DC_CHAT_ID_DEADDROP))
+        navigationController?.pushViewController(deaddropViewController, animated: true)
     }
 
     func showHelp() {
-        if let navigationController = self.parent as? UINavigationController {
-            let helpViewController = HelpViewController()
-            navigationController.pushViewController(helpViewController, animated: true)
-        }
+        navigationController?.pushViewController(HelpViewController(), animated: true)
     }
 
     func showDebugToolkit() {