Latest 0.8.2
Homepage https://github.com/roadmaptravel/RMRoute
License Apache License, Version 2.0
Platforms ios 8.0
Authors

CocoaPods Compatible
Twitter

RMRoute is a lightweight implementation to use routes in your iOS application.

Summary

RMRoute makes it easy to provide access to all your features from anywhere in your app. With bigger applications it’s sometimes handy to have entry points to your features, without referencing to them by class.

Features

  • [x] Registering & calling routes
  • [x] Pass parameters in route
  • [x] Routes case insensitive
  • [x] Swift 3 compatible
  • [ ] Named parameters

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3.0

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.0.0+ is required to build RMRoute.

To integrate RMRoute into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'RMRoute'
end

Then, run the following command:

$ pod install

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate Alamofire into your project manually.

Usage

Registering a route

Simple registration

Example without parameters

import RMRoute

RMRoute.register("about") { (delegate, animation, params) in

    // Just show the vc
    let vc = AboutViewController()
    delegate.animate(vc, animation: animation) // This is an UIViewController extension which handles the animation type

    return true
}
[RMRoute registerWithPath:@"about" action:^BOOL (UIViewController *delegate, RMRouteAnimation animation, NSArray *params) {

    // Just show the vc
    AboutViewController *vc = [[AboutViewController alloc] init];
    [delegate animate:vc animation:animation]; // This is an UIViewController extension which handles the animation type

    return YES;
}];

More advanced registration

Example with parameters. You can also use query string parameters: "faq/?itemId={itemId}".

import RMRoute

RMRoute.register("faq/{itemId}") { (delegate, animation, params) in

    let itemId = params[0]
    guard itemId.isEmpty == false else {
        return false
    }

    // Just show the vc
    let vc = FAQViewController(itemId)
    delegate.animate(vc, animation: animation)

    return true
}
[RMRoute registerWithPath:@"faq/{itemId}" action:^BOOL (UIViewController *delegate, RMRouteAnimation animation, NSArray *params) {

    NSString *itemId = params[0];

    if (itemId.length == 0) return NO;

    // Just show the vc
    FAQViewController *vc = [[FAQViewController alloc] initWithItemId:itemId];
    [delegate animate:vc animation:animation];

    return YES;
}];

Calling a route

Simple call

Example without parameters

import RMRoute

RMRoute.navigate("about", delegate: self, animation: .push)
[RMRoute navigate:@"about" delegate:self animation:RMRouteAnimationPush];

More advanced call

Example with parameters

import RMRoute

RMRoute.navigate("faq/12", delegate: self, animation: .present)
RMRoute.navigate("faq/?itemId=12", delegate: self, animation: .present)
[RMRoute navigate:@"faq/12" delegate:self animation:RMRouteAnimationPresent];
[RMRoute navigate:@"faq/?itemId=12" delegate:self animation:RMRouteAnimationPresent];

Credits

Credits to the Roadmap team to make this all possible! Really a great team, if you’re looking for a new challenge please get in contact with us! We’re always open to discuss the future with a good cup of coffee!

License

RMRoute is released under the Apache license. See LICENSE for details.

Latest podspec

{
    "name": "RMRoute",
    "version": "0.8.2",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/roadmaptravel/RMRoute",
    "authors": {
        "Roadmap": "[email protected]"
    },
    "summary": "A lightweight implementation to use routes in your application.",
    "source": {
        "git": "https://github.com/roadmaptravel/RMRoute.git",
        "tag": "0.8.2"
    },
    "ios": {
        "source_files": "RMRoute/Source/*.*",
        "requires_arc": true
    },
    "platforms": {
        "ios": "8.0"
    }
}

Pin It on Pinterest

Share This