Skip to content

Instantly share code, notes, and snippets.

@brunomunizaf
Last active November 3, 2020 18:05
Show Gist options
  • Save brunomunizaf/0aac434513ed584e6f42e820ff386aaa to your computer and use it in GitHub Desktop.
Save brunomunizaf/0aac434513ed584e6f42e820ff386aaa to your computer and use it in GitHub Desktop.
protocol Pushing {
func push(_ target: UIViewController, from parent: UIViewController)
}
struct Pusher: Pushing {
func push(_ target: UIViewController, from parent: UIViewController) {
parent.navigationController?.pushViewController(target, animated: true)
}
}
protocol DashboardCoordinating {
func pushDashboardScreen(from parent: UIViewController)
}
final class DashboardCoordinator: DashboardCoordinating {
var pusher: Pushing = Pusher()
var dashboardScreenFactory: () -> UIViewController = DashboardScreen.init
func pushDashboardScreen(from parent: UIViewController) {
let screen = dashboardScreenFactory()
pusher.push(screen, from: parent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment