Created
May 20, 2022 10:23
-
-
Save tifoaudii/f3976834845752835b2fbb74025b5482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol UIFactory { | |
func createTaskViewController(navigationDelegate: TaskViewControllerNavigationDelegate) -> UIViewController | |
func createAddTaskViewController(didAddNewTask: @escaping () -> Void) -> UIViewController | |
} | |
final class ViewControllerFactory: UIFactory { | |
private let coreDataStack: CoreDataStack | |
init(coreDataStack: CoreDataStack) { | |
self.coreDataStack = coreDataStack | |
} | |
func createTaskViewController(navigationDelegate: TaskViewControllerNavigationDelegate) -> UIViewController { | |
let presenter = TaskViewDefaultPresenter(dataStore: coreDataStack) | |
let taskViewController = TaskViewController(presenter: presenter, navigationDelegate: navigationDelegate) | |
return taskViewController | |
} | |
func createAddTaskViewController(didAddNewTask: @escaping () -> Void) -> UIViewController { | |
let presenter = AddTaskViewDefaultPresenter(dataStore: coreDataStack) | |
let addTaskViewController = AddTaskViewController(presenter: presenter) | |
presenter.didAddNewTask = { | |
addTaskViewController.dismiss(animated: true, completion: nil) | |
didAddNewTask() | |
} | |
return addTaskViewController | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment