NetunoNavigation 1.0.0

NetunoNavigation 1.0.0

Lucas Wottrich维护。



GitHub stars GitHub forks GitHub watchers

GitHub license platform Open Source Love

🔱NetunoNavigation🔱

如神一般导航。

NetunoNavigation是一个适用于iOS的pod,将导航提升到平台的新高度。

安装

您可以使用CocoaPods安装NetunoNavigation。

pod 'NetunoNavigation', '~> 1.0.0'

实现

在您使用 CocoaPods 安装 NetunoNavigation 后,您可以将 NetunoNavigation 导入到您的类中

import NetunoNavigation

当您导入导航后,就可以开始使用 Navigator 类,并实现它

import UIKit
import NetunoNavigation

class ExampleViewController : UIViewController {

	var navigate: Navigator?
	
	override  func  viewDidLoad() {
		super.viewDidLoad()
		self.navigate = Navigator(navigationController: self.navigationController)
	}	
}

这是如何开始使用此库的基础。

NetunoNavigate基本介绍

导航到另一个UIViewController

> to

Params 示例
_ currenctViewController UIViewController
viewControllerToGo T.Type
prepare ((T?) -> Void)? = nil

返回: Go

> toGo

如果你不需要使用prepare,则可以使用.toGo

Params 示例
_ currenctViewController UIViewController
viewControllerToGo T.Type
转场 Segue = .push:animated: Go.defaultAnimated

返回: 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()
导航到另一个Storyboard上的UIViewController

> to

Params 示例
_ storyboardToGo String
viewControllerToGo T.Type
prepare ((T?) -> Void)? = nil

返回: Go

> toGo

如果你不需要使用prepare,则可以使用.toGo

Params 示例
_ storyboardToGo String
viewControllerToGo T.Type
转场 Segue = .push:animated: Go.defaultAnimated

返回: 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()
导航到另一个UINavigationController

.newStack用于配置你想要导航的UINavigationController导航控制器和/或UIStoryboard故事板。要导航到另一个屏幕,你需要使用.to来配置UIViewController视图控制器和/或prepare准备以及.go来配置你想要打开屏幕的方式。但如果你只需要go,则可以使用.toGo.

如果你要导航到另一个Storyboard,使用storyboardToGo参数

> newStack

Params 示例
navControllerToGo String
_ storyboardToGo String? = nil

返回: Stack?

.to

Params 示例
viewControllerToGo T.Type
prepare ((T?) -> Void)? = nil

返回: StackGo

.go

Params 示例
_ style ModalStyleEnum = .none

返回: Void

**.newStack代码示例**
//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()
**.newStack使用.toGo的示例**
//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)

--

如果你不需要使用prepare,则可以使用.newStackToGo

> newStackToGo

Params 示例
_ navControllerToGo String
_ storyboardToGo String? = nil
viewControllerToGo T.Type? = nil
style ModalStyleEnum = .none

返回: 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)
)

Wiki

许可证

MIT许可证

版权(C)2020 Lucas Cruz Wottrich.