Router based navigation solution for iOS application
- extension for UIViewController
- extension for UINavigationController
- iOS 10.0+
To integrate GBKRouterProtocol into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'GBKRouterProtocol', :git => 'git@gitlab.gbksoft.net:gbksoft-mobile-department/ios/gbkrouterprotocol.git'
Then, run the following command:
$ pod install
Usage of library require import GBKRouterProtocol
somewhere in the source file.
For Router should be used next naming:
- (Module_Name)Router.swift
For example:
- LoginRouter.swift
If context is UIViewController
import UIKit
import GBKRouterProtocol
struct LoginRouter: GBKRouterProtocol {
var context: UIViewController!
func openLogin() {
let loginController = LoginViewController()
present(controller: loginController)
}
}
If context is UINavigationController
import UIKit
import GBKRouterProtocol
struct LoginRouter: GBKRouterProtocol {
var context: UINavigationController!
func openLogin() {
let loginController = LoginViewController()
push(controller: loginController)
}
}
Next in code we should call:
// For UIViewController
LoginRouter(in: self).openLogin(). // where self is current UIViewController
// For UINavigationController
LoginRouter(in: navigationController).openLogin()
- extension for UITabBarController