Latest 1.1.2
Homepage https://github.com/akane/Magellan
License MIT
Platforms ios 8.0, requires ARC
Authors ,

Nabigeta

Build Status

Nabigeta provides simple API to declare routes for navigation. Compatible with trait environments.

Usage

Declare your routes into a file, like your AppDelegate.

import Nabigeta

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  var navigation: Navigation! = nil

  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.navigation = Navigation(traitProvider: self.window!)

    self.navigation.router = { context in
        switch(context) {
          case is Author:
            return Route(AuthorViewController.self)

          case is Book:
            return Route(BookViewController.self)
              .present { trait in
                  switch(trait.horizontalClass, trait.verticalClass) {
                    case (.Compact, .Compact):
                      return PresentationPush()
                    default:
                      return PresentationModal()
                  }
              }
        }
    }
  }
}

class AuthorViewController : UIViewController, Navigable {
    func didNavigate(to author: Author) {
      print("Navigated to /(author.name) controller")
    }
}

class BookViewController {
  func didTapAuthor() {
    self.navigate(to: self.author) // AuthorViewController is displayed!
  }
}

Advanced Usage

Presentation

Nabigeta provides some default Presentation strategies:

  • PresentationPush
  • PresentationModal
  • PresentationPopover
  • PresentationSegue

If none of them feed your needs, you can provide your own custom presentation just by creating a class/struct implementing the PresentationStrategy protocol.

Stopping navigation

Navigate back

You can cancel navigation from source controller:

  bookViewController.navigateBack() // come back to BookViewController

You can also stop navigation from destination controller:

  authorViewController.navigationTerminated(status: .Canceled) // dismiss AuthorViewController

You can also be notified when navigations are stopped:

  bookViewController
    .navigate(to: self.author)
    .onTerminate { status in
      if status == .Canceled {
        print("author controller cancelled")
      }
    }

Latest podspec

{
    "name": "Magellan",
    "version": "1.1.2",
    "source": {
        "git": "https://github.com/akane/Magellan.git",
        "tag": "1.1.2"
    },
    "summary": "Define your navigation through routes in one and powerful way",
    "description": "Navigation Service to route your controllers based on parameters. Asbtract everything about NavigationController. No need to care about it!",
    "homepage": "https://github.com/akane/Magellan",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": [
        "pjechris",
        "akane"
    ],
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Sources/Magellan/**/*.swift",
    "prefix_header_file": "Sources/Magellan.h",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This