Skip to content

Instantly share code, notes, and snippets.

@gorozco58
Created January 13, 2017 19:06
Show Gist options
  • Save gorozco58/65674fb61d02f5d73713ed55768ba7a4 to your computer and use it in GitHub Desktop.
Save gorozco58/65674fb61d02f5d73713ed55768ba7a4 to your computer and use it in GitHub Desktop.
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