Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created January 14, 2021 03:05
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 azamsharp/51f9a8658dfe89e6504e0b37111ca993 to your computer and use it in GitHub Desktop.
Save azamsharp/51f9a8658dfe89e6504e0b37111ca993 to your computer and use it in GitHub Desktop.
class Navigator {
static func navigate<T: View>(_ route: Route, content: () -> T) -> AnyView {
switch route {
case .detail(let country):
return
NavigationLink(
destination: DetailView(country: country)) {
content()
}.toAnyView()
case .aboutUs:
return Text("About Us").toAnyView()
case .addCountry:
return Text("Add Country").toAnyView()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment