Przeglądaj źródła

remove EditSettingsCoordinator

B. Petersen 5 lat temu
rodzic
commit
03e6ad9210

+ 9 - 6
deltachat-ios/Controller/EditSettingsController.swift

@@ -2,9 +2,7 @@ import UIKit
 import DcCore
 
 class EditSettingsController: UITableViewController, MediaPickerDelegate {
-
     private let dcContext: DcContext
-    weak var coordinator: EditSettingsCoordinator?
     private var displayNameBackup: String?
     private var statusCellBackup: String?
 
@@ -22,7 +20,13 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
 
     private let tagAccountSettingsCell = 1
 
-    private var childCoordinators: Coordinator?
+    private lazy var mediaPicker: MediaPicker? = {
+        if let navigationController = self.parent as? UINavigationController {
+            return MediaPicker(navigationController: navigationController)
+        } else {
+            return nil
+        }
+    }()
 
     private lazy var statusCell: MultilineTextFieldCell = {
         let cell = MultilineTextFieldCell(description: String.localized("pref_default_status_label"),
@@ -137,11 +141,11 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
 
     // MARK: - actions
     private func galleryButtonPressed(_ action: UIAlertAction) {
-        coordinator?.showPhotoPicker(delegate: self)
+        mediaPicker?.showPhotoGallery(delegate: self)
     }
 
     private func cameraButtonPressed(_ action: UIAlertAction) {
-        coordinator?.showCamera(delegate: self)
+        mediaPicker?.showCamera(delegate: self)
     }
 
     private func deleteProfileIconPressed(_ action: UIAlertAction) {
@@ -186,4 +190,3 @@ class EditSettingsController: UITableViewController, MediaPickerDelegate {
     }
 
 }
-

+ 10 - 6
deltachat-ios/Controller/ProfileInfoViewController.swift

@@ -2,14 +2,18 @@ import UIKit
 import DcCore
 
 class ProfileInfoViewController: UITableViewController {
-
-    weak var coordinator: EditSettingsCoordinator?
     var onClose: VoidFunction?
-
     private let dcContext: DcContext
-
     private var displayName: String?
 
+    private lazy var mediaPicker: MediaPicker? = {
+        if let navigationController = self.parent as? UINavigationController {
+            return MediaPicker(navigationController: navigationController)
+        } else {
+            return nil
+        }
+    }()
+
     private lazy var doneButtonItem: UIBarButtonItem = {
         return UIBarButtonItem(
             title: String.localized("done"),
@@ -136,11 +140,11 @@ class ProfileInfoViewController: UITableViewController {
     }
 
     private func galleryButtonPressed(_ action: UIAlertAction) {
-        coordinator?.showPhotoPicker(delegate: self)
+        mediaPicker?.showPhotoGallery(delegate: self)
     }
 
     private func cameraButtonPressed(_ action: UIAlertAction) {
-        coordinator?.showCamera(delegate: self)
+        mediaPicker?.showCamera(delegate: self)
     }
 }
 

+ 0 - 2
deltachat-ios/Controller/SettingsController.swift

@@ -447,8 +447,6 @@ internal final class SettingsViewController: UITableViewController {
     func showEditSettingsController() {
         if let navigationController = self.parent as? UINavigationController {
             let editController = EditSettingsController(dcContext: dcContext)
-            let coordinator = EditSettingsCoordinator(dcContext: dcContext, navigationController: navigationController)
-            editController.coordinator = coordinator
             navigationController.pushViewController(editController, animated: true)
         }
     }

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

@@ -168,9 +168,6 @@ extension AppCoordinator: WelcomeCoordinator {
         let profileInfoController = ProfileInfoViewController(context: dcContext)
         let profileInfoNav = UINavigationController(rootViewController: profileInfoController)
         profileInfoNav.modalPresentationStyle = .fullScreen
-        let coordinator = EditSettingsCoordinator(dcContext: dcContext, navigationController: profileInfoNav)
-        profileInfoController.coordinator = coordinator
-        childCoordinators.append(coordinator)
         profileInfoController.onClose = handleLoginSuccess
         welcomeController?.present(profileInfoNav, animated: true, completion: nil)
     }
@@ -184,27 +181,6 @@ extension AppCoordinator: WelcomeCoordinator {
     }
 }
 
-// MARK: - EditSettingsCoordinator
-class EditSettingsCoordinator: Coordinator {
-    var dcContext: DcContext
-    let navigationController: UINavigationController
-    let mediaPicker: MediaPicker
-
-    init(dcContext: DcContext, navigationController: UINavigationController) {
-        self.dcContext = dcContext
-        self.navigationController = navigationController
-        self.mediaPicker = MediaPicker(navigationController: navigationController)
-    }
-
-    func showPhotoPicker(delegate: MediaPickerDelegate) {
-        mediaPicker.showPhotoGallery(delegate: delegate)
-    }
-
-    func showCamera(delegate: MediaPickerDelegate) {
-        mediaPicker.showCamera(delegate: delegate)
-    }
-}
-
 /*
  boilerplate - I tend to remove that interface (cyberta)
  */