Skip to content

Instantly share code, notes, and snippets.

@Otbivnoe
Created January 31, 2018 12:15
Show Gist options
  • Save Otbivnoe/e17f9ec4de99056bf8f59a98dd34bb60 to your computer and use it in GitHub Desktop.
Save Otbivnoe/e17f9ec4de99056bf8f59a98dd34bb60 to your computer and use it in GitHub Desktop.
protocol ProfileRoute {
var profileTransition: Transition { get }
func openProfile(for user: User)
}
extension ProfileRoute where Self: RouterProtocol {
var profileTransition: Transition {
return ModalTransition()
}
func openProfile(for user: User) {
let router = ProfileRouter()
let profileViewController = ProfileViewController(router: router)
router.viewController = profileViewController
let transition = profileTransition // it's a calculated property so I saved it to the variable in order to have one instance
router.openTransition = transition
open(profileViewController, transition: transition)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment