Swiftpack.co - Package - TouchInstinct/TICoordinatorKit

TICoordinatorKit

A framework for performing navigation in iOS application.

Supporting custom navigation controllers

In ModalRoutable protocol there is a group of methods called presentChild:

presentChild(_:navigationControllerFactory:) -> StackRoutable?
presentChild(_:navigationControllerFactory:animated:) -> StackRoutable?

These methods wrap given module in navigation controller and present the wrapper. The navigationControllerFactory argument is a closure of type (UIViewController) -> UINavigationController. For example:

router.presentChild(module, 
                    navigationControllerFactory: { 
                      UINavigationController(rootViewController: $0) 
                    }, 
                    animated: true)

To simplify this method call (or in case your application has custom implementation of UINavigationController), you may consider creating a standalone NavigationControllerFactory:

// ModalRoutable+NavigationControllerFactory.swift
import TICoordinatorKit

extension ModalRoutable {

    // MARK: - Navigation Controller Factory

    private var factory: ModalRoutable.NavigationControllerFactory {

        return { 
            CustomNavigationController(rootViewController: $0)
        }
    }

    // MARK: - Defaults

    func presentChild(_ module: Presentable?) -> StackRoutable? {
        return presentChild(module, navigationControllerFactory: factory)
    }

    func presentChild(_ module: Presentable?, animated: Bool) -> StackRoutable? {
        return presentChild(module, navigationControllerFactory: factory, animated: animated)
    }
}

License

See the LICENSE file for more info.

Github

link
Stars: 1

Dependencies

Used By

Total: 0