Browse Source

handle close profileInfoVC via handler in AppCoorinator

nayooti 5 years ago
parent
commit
60500c5dd1

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

@@ -4,6 +4,8 @@ import DcCore
 class ProfileInfoViewController: UITableViewController {
 
     weak var coordinator: EditSettingsCoordinator?
+    var onClose: VoidFunction?
+
     private let dcContext: DcContext
 
     private var displayName: String?
@@ -130,11 +132,8 @@ class ProfileInfoViewController: UITableViewController {
 
     @objc private func doneButtonPressed(_ sender: UIBarButtonItem) {
         dcContext.displayname = displayName
-        self.dismiss(animated: true, completion: nil)
-
-        if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
-            appDelegate.appCoordinator.presentTabBarController()
-        }
+        self.dismiss(animated: false, completion: nil) // not sure if this is needed
+        onClose?()
     }
 
     private func galleryButtonPressed(_ action: UIAlertAction) {

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

@@ -192,9 +192,14 @@ extension AppCoordinator: WelcomeCoordinator {
         profileInfoNav.modalPresentationStyle = .fullScreen
         let coordinator = EditSettingsCoordinator(dcContext: dcContext, navigationController: profileInfoNav)
         profileInfoController.coordinator = coordinator
+        profileInfoController.onClose = handleProfileInfoClosed
         welcomeController.present(profileInfoNav, animated: true, completion: nil)
     }
 
+    private func handleProfileInfoClosed() {
+        presentTabBarController()
+    }
+
     @objc private func cancelButtonPressed(_ sender: UIBarButtonItem) {
         loginController.dismiss(animated: true, completion: nil)
     }