Skip to content

Instantly share code, notes, and snippets.

@caldofran
Last active March 6, 2020 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caldofran/f8b346eb9146efcfd4839eab66fc56c1 to your computer and use it in GitHub Desktop.
Save caldofran/f8b346eb9146efcfd4839eab66fc56c1 to your computer and use it in GitHub Desktop.
Simple Navigator implementation
class Navigator {
func handle(navigation: Navigation, animated: Bool = true) {
switch navigation {
case .section(let section):
tabBarController().selectedIndex = section.rawValue
case .modal(let screen):
topMostViewController().present(
screen.viewController(),
animated: animated
)
case .push(let screen):
currentNavigationController().pushViewController(
screen.viewController(),
animated: animated
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment