Created
January 13, 2017 19:06
-
-
Save gorozco58/65674fb61d02f5d73713ed55768ba7a4 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 | |
protocol Transitionable: class { | |
weak var navigationCoordinator: CoordinatorType? { get } | |
} | |
protocol CoordinatorType: class { | |
var baseController: UIViewController { get } | |
func performTransition(transition: Transition) | |
} | |
enum Transition { | |
case showRepository(Repository) | |
} | |
class MainCoordinator: CoordinatorType { | |
var baseController: UIViewController | |
init() { | |
let viewModel = RepositoryViewModel() | |
self.baseController = UINavigationController(rootViewController: MainViewController(viewModel: viewModel)) | |
viewModel.navigationCoordinator = self | |
} | |
func performTransition(transition: Transition) { | |
switch transition { | |
case .showRepository(let repository): | |
UIApplication.shared.open(URL(string: repository.url)!, options: [:], completionHandler: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment