Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

TouchInstinct/TICoordinatorKit

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •