Git Product home page Git Product logo

acrouter's Introduction

ACRouter

CI Status Version License Platform

Introduce

A simple router for swift 中文文档

Process

sdf

Requirements

swift3+ and xcode8+

Installation

pod "ACRouter"

How To Use

  1. CustomViewController inherit ACRouterable, and implement the func of registerAction.
class CustomViewController: UIViewController, ACRouterable {
    static func registerAction(info: [String : AnyObject]) -> AnyObject {
        let newInstance = LoginViewController()
        if let title = info["username"] as? String {
            newInstance.title = title
        }
        return newInstance
    }
}
  1. RegisterRouter for your CustomViewController
ACRouter.addRouter("AA://bb/cc/:p1", classString: "CustomViewController")
  1. OpenURL in you application
ACRouter.openURL("AA://bb/cc/content?value1=testInfo")

Convenience

  • Quickly add multiple router
let registerDict = ["AA://bb/cc/:p1" : "CustomViewControllerOne", "AA://ee/ff" : "CustomViewControllerTwo"]
ACRouter.addRouter(registerDict)
  • Quickly genarate jump
ACRouter.generate(_ patternString: params:  jumpType: )

It will parse patternString and embed the params and the jumpType in it

  • Check the request URL
canOpenURL(_ urlString: )
  • remove router
removeRouter(_ patternString: )

Custom Use

  1. AddRouter
ACRouter.addRouter(patternString:  priority: handle: )

It will store pattern information, and sort by priority reverse order 2. RequestRouter

ACRouter.requestURL(urlString: userInfo: )

Request the real urlString, and response the pattern information and the queries which contain the userInfo. if exist the same key, it will embed in array.

Todo list

  • Add Interceptor for router
  • Add Test for router
  • Add openURL failed action
  • Add relocation
  • openURL not only support Viewcontroller jumping

Author

[email protected]

License

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

acrouter's People

Contributors

archerlly avatar stupidcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

acrouter's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.