Last active
January 5, 2020 12:10
-
-
Save zafarivaev/d1d62aa34cbb788d00ef8b1b619e9c27 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
import UIKit | |
class QuotesRouter: PresenterToRouterQuotesProtocol { | |
// MARK: Static methods | |
static func createModule() -> UINavigationController { | |
print("QuotesRouter creates the Quotes module.") | |
let viewController = QuotesViewController() | |
let navigationController = UINavigationController(rootViewController: viewController) | |
let presenter: ViewToPresenterQuotesProtocol & InteractorToPresenterQuotesProtocol = QuotesPresenter() | |
viewController.presenter = presenter | |
viewController.presenter?.router = QuotesRouter() | |
viewController.presenter?.view = viewController | |
viewController.presenter?.interactor = QuotesInteractor() | |
viewController.presenter?.interactor?.presenter = presenter | |
return navigationController | |
} | |
// MARK: - Navigation | |
func pushToQuoteDetail(on view: PresenterToViewQuotesProtocol, with quote: APIQuote) { | |
print("QuotesRouter is instructed to push QuoteDetailViewController onto the navigation stack.") | |
let quoteDetailViewController = QuoteDetailRouter.createModule(with: quote) | |
let viewController = view as! QuotesViewController | |
viewController.navigationController? | |
.pushViewController(quoteDetailViewController, animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment