Navigate like a god.
NetunoNavigation is a pod to iOS to take navigation to the next level on the platform.
You can install NetunoNavigation with CocoaPods.
pod 'NetunoNavigation', '~> 1.0.0'After you install NetunoNavigation with CocoaPods you can to import NetunoNavigation into your class:
import NetunoNavigationWhen you to import navigation you can start utilize Navigator class, and implement it:
import UIKit
import NetunoNavigation
class ExampleViewController : UIViewController {
var navigate: Navigator?
override func viewDidLoad() {
super.viewDidLoad()
self.navigate = Navigator(navigationController: self.navigationController)
}
}This is the basic of how to start to use this pod.
Navigate to another UIViewController
> to
| Params | Example |
|---|---|
| _ currenctViewController | UIViewController |
| viewControllerToGo | T.Type |
| prepare | ((T?) -> Void)? = nil |
Return: Go
> toGo
if you don't need to use prepare you can use .toGo:
| Params | Example |
|---|---|
| _ currenctViewController | UIViewController |
| viewControllerToGo | T.Type |
| segue | Segue = .push(animated: Go.defaultAnimated) |
Return: Bool
//Transparent
toGo<T: UIViewController>(
_ currentViewController: String
viewControllerToGo _: T.Type
segue: Segue = .push(animated: Go.defaultAnimated)
)
to<T: UIViewController>(
_ currentViewController: UIViewController
viewControllerToGo _: T.Type
prepare: ((T?) -> Void)? = nil
) -> Go
.go(
segue: Segue = .push(animated: Go.defaultAnimated)
) -> Bool
//Example without prepare you can use `toGo`
navigator.toGo(self, viewControllerToGo: AnotherViewController.self)
//Example with prepare
navigator.to(self, viewControllerToGo: AnotherViewController.self) { nextViewController: AnotherViewController? in
nextViewController.title = "New Title"
}.go()Navigate to another UIViewController on another Storyboard
> to
| Params | Example |
|---|---|
| _ storyboardToGo | String |
| viewControllerToGo | T.Type |
| prepare | ((T?) -> Void)? = nil |
Return: Go
> toGo
if you don't need to use prepare you can use .toGo:
| Params | Example |
|---|---|
| _ storyboardToGo | String |
| viewControllerToGo | T.Type |
| segue | Segue = .push(animated: Go.defaultAnimated) |
Return: Bool
//Transparent
toGo<T: UIViewController>(
_ storyboardToGo: String
viewControllerToGo _: T.Type
segue: Segue = .push(animated: Go.defaultAnimated)
)
to<T: UIViewController>(
_ storyboardToGo: String
viewControllerToGo _: T.Type
prepare: ((T?) -> Void)? = nil
) -> Go
.go(
segue: Segue = .push(animated: Go.defaultAnimated)
) -> Bool
//Example without prepare you can use `toGo`
navigator.toGo("AnotherStoryboard", viewControllerToGo: AnotherViewController.self)
//Example with prepare
navigator.to("AnotherStoryboard", viewControllerToGo: AnotherViewController.self) { nextViewController: AnotherViewController? in
nextViewController.title = "New Title"
}.go()Navigate to another UINavigationController
.newStack is used to configure UINavigationController and/or UIStoryboard that you want to navigate.
To navigate to another screen you need to use .to to configure UIViewController and/or prepare and .go to configure how you want to open your screen.
But if you want only go you can use .toGo.
If you want to navigate to another Storyboard use storyboardToGo param
> newStack
| Params | Example |
|---|---|
| navControllerToGo | String |
| _ storyboardToGo | String? = nil |
Return: Stack?
.to
| Params | Example |
|---|---|
| viewControllerToGo | T.Type |
| prepare | ((T?) -> Void)? = nil |
Return: StackGo
.go
| Params | Example |
|---|---|
| _ style | ModalStyleEnum = .none |
Return: Void
**Code .newStack example**
//Transparent
.newStack(
navControllerToGo: String,
_ storyboardToGo: String? = nil
) -> Stack?
.to<T: UIViewController>(
viewControllerToGo: T.Type,
prepare: ((T?) -> Void)? = nil
) -> StackGo
.go(
_ style: ModalStyleEnum = .none
)
//Example same storyboard
let stack = navigate.newStack("NavigationControllerToGo")
//Example another storyboard
let another = navigate.newStack("NavigationControllerToGo", "AnotherStoryboard")
//Without prepare
stack.to(AnotherViewController.self).go()
//With prepare
stack.to(AnotherViewController.self) { nextViewController in
nextViewController.title = "new title"
}.go()**Code .newStack with .toGo example**
//Transparent
.newStack(
navControllerToGo: String,
_ storyboardToGo: String? = nil
) -> Stack?
.toGo<T: UIViewController>(
_ viewControllerToGo: T.Type? = nil
style: ModalStyleEnum = .modal(modalTransitionStyle: .crossDissolve, modalPresentationStyle: .fullScreen, animated: true, completion: nil)
) -> Stack
//Example
navigate.newStack("NavigationControllerToGo")
.toGo(AnotherViewController.self)--
If you don't need to use prepare you can use .newStackToGo:
> newStackToGo
| Params | Example |
|---|---|
| _ navControllerToGo | String |
| _ storyboardToGo | String? = nil |
| viewControllerToGo | T.Type? = nil |
| style | ModalStyleEnum = .none |
Return: Stack?
//Transparent
newStackToGo<T: UIViewController>(
_ navControllerToGo: String,
_ storyboardToGo: String? = nil,
viewControllerToGo: T.Type,
style: ModalStyleEnum = .none
) -> Stack?
//Example same storyboard
navigate.newStackToGo("NavigationControllerToGo", viewControllerToGo: AnotherViewController.self, .default)
//Example another storyboard
navigate.newStackToGo(
"NavigationControllerToGo", //navControllerToGo
"AnotherStoryboard", //storyboardToGo
viewControllerToGo: AnotherViewController.self,
style: .default(animated: true, completion: nil)
)Copyright (c) 2020 Lucas Cruz Wottrich.