Skip to content

appfoundry/direkt

Repository files navigation

Direkt

Carthage

Direkt is a Swift port of DRYNavigationManager.

Like the original, it is meant for projects which do not rely on Storyboard segues, providing separation of navigation and view controller logic code. It follows same architectural concept, but leverages Swift programming techniques to provide more type safety and native API feel.

Usage

Library defines a few core protocols that the users will be working with:

  • Navigator - Core objects responsible for navigation flow. Their task is to run the transition code e.g. pushing a view controller onto the navigation stack.
  • NavigationManager - The task of those objects, as the name suggests, is to manage navigators. Meaning the object will need to create given navigator instance upon navigation request. BaseNavigationManager is an open implementaion of the protocol that you can use directly or extend.
  • Resolver protocol type used for dependencies resolution.

Example implementation of Navigator pushing a view controller onto the navigation stack:

func navigate(using input: String, from hostViewController: UIViewController, resolver: Resolver) throws {
    guard let navigationController = hostViewController.navigationController else {
        throw Error.missingNavigationController
    }

    try navigationController.pushViewController(
        resolver.resolve(HelloViewController.self, input: input),
        animated: true
    )
}

Example

In the repository you can find an example project.

  1. Clone the repository - git clone https://github.com/appfoundry/direkt.git
  2. Run carthage build --platform iOS from the Example directory
  3. Explore the example project

Installation

CocoaPods

Add the line pod "Direkt" to your Podfile

Carthage

Add the line github "appfoundry/direkt" to your Cartfile and update your Carthage copy-frameworks script accordingly.

Swift Package Manager Support

Direkt is also available through Swift Package Manager.\n Swift Package Manager is now integrated into Xcode 11. You can add your package by going to "File" then "Swift Packages" then "Add Package Dependency..." Paste the repository's URL into the field above then click "next". Xcode will walk you through the rest of the steps. You can learn more at this WWDC talk.

Authors

Author E-mail
Joris Dubois joris.dubois@appfoundry.be
Jonathan Esposito jonathan.esposito@appfoundry.be
Jens Goeman jens.goeman@appfoundry.be
Damian Malarczyk damian.malarczyk@appfoundry.be

License

Direkt is available under the MIT license. See the LICENSE file for more info.