Latest 1.0.1
Homepage https://github.com/CranberryYam/HYRouter
License MIT
Platforms ios 8.0
Authors

HYRouter

Language: Swift
Platform: iOS 8+
cocoapods compatible
License: MIT
Release version

HYRouter

Introduction

HYRouter is the router framework that I built while I was doing one of my app with module development. It helps you decouple ViewControllers, run all your ViewControllers in a debug UITableViewController and flexibly set up the main UITabbarController.

If you use traditinal navigation methods offered by Apple, you can’t decouple two modules. Each time when you navigate to the B_ViewController, you have to init an object of the B_ViewController. It means that you have to know the existence the B_ViewController Class. When the B_ViewController is from a different module, decoupling modules becomes very tough.

Feathers

  • [x] Navigate through the ViewController Identifier  
  • [x] Pass data between ViewControllers easily
  • [x] Support ViewController with storyboard or without storyboard
  • [x] Configure the main UITabBarController with a dictionary
  • [x] Setup entries for all ViewController in the dubug mode

Installation

You can install HYRouter via CocoaPods by adding it to your Podfile:

use_frameworks!

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

pod 'HYRouter'

And run pod install.

Usage

Router

1 – Implement the RouterController protocol

import HYRouter

class MyViewController:UIViewController, RouterController {
    var params: [String : Any]?
}

All data from previous ViewController will be here

2 – Prepare the data needed to pass

let param = RouterParams()
param["videoUrl"] = "https://video.com/id=123"

3 – Call Navigate method

navigate(controllerName: String, params:RouterParams,isPresent: Bool)
  • controllerName: When the next ViewController use storyboard, the controllerName is the stroyboard identifier. When doesn’t use storyboard, the controllerName is the ViewController class name
  • params: data is configured in a dictionary structure
  • isPresent: True for presentViewController, false for pushViewController

4 – Receive the data

import HYRouter

class MyViewController:UIViewController, RouterController {
    var params: [String : Any]? {
      didSet {
              guard let params = params else { return }
              if params.keys.contains("videoUrl")
              { self.urlString = params["videoUrl"] as? String }
          }
    }
}

DebugViewController

HYRouter

AppDelegate.swift
import HYRouter

let vcs = ["Record","ActityHisController","History"]
window?.rootViewController = DebugLaucher.tableController(controllers: vcs)

Main UITabBarController

AppDelegate.swift
import HYRouter

let vcs = ["Record","ActityHisController","History"]
window?.rootViewController = DebugLaucher.tabController(controllers: vcs)

Latest podspec

{
    "name": "HYRouter",
    "version": "1.0.1",
    "summary": "HYRouter is a Swift Router framework.",
    "homepage": "https://github.com/CranberryYam/HYRouter",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Henry Yi": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/CranberryYam/HYRouter.git",
        "tag": "1.0.1"
    },
    "source_files": "HYRouter/Classes/**/*"
}

Pin It on Pinterest

Share This