All Projects → hyperoslo → Compass

hyperoslo / Compass

Licence: other
🌍 Compass helps you setup a central navigation system for your application

Programming Languages

swift
15916 projects
scheme
763 projects

Projects that are alternatives of or similar to Compass

Frontexpress
An Express.js-Style router for the front-end
Stars: ✭ 263 (-68.24%)
Mutual labels:  url, navigation
Url Parser
Parse URLs into nicely structured data
Stars: ✭ 118 (-85.75%)
Mutual labels:  url, navigation
Gknavigationbarviewcontroller
iOS自定义导航栏-导航栏联动
Stars: ✭ 637 (-23.07%)
Mutual labels:  navigation
Priority Navigation
Javascript implementation for Priority+ Navigation — no dependencies
Stars: ✭ 739 (-10.75%)
Mutual labels:  navigation
Turtlebot3
ROS packages for Turtlebot3
Stars: ✭ 673 (-18.72%)
Mutual labels:  navigation
Navaid
A navigation aid (aka, router) for the browser in 850 bytes~!
Stars: ✭ 648 (-21.74%)
Mutual labels:  navigation
Jetpack Mvvm Best Practice
是 难得一见 的 Jetpack MVVM 最佳实践!在 以简驭繁 的代码中,对 视图控制器 乃至 标准化开发模式 形成正确、深入的理解!
Stars: ✭ 6,950 (+739.37%)
Mutual labels:  navigation
Urlembeddedview
URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.
Stars: ✭ 633 (-23.55%)
Mutual labels:  url
Animatedbottombar
A customizable and easy to use BottomBar navigation view with sleek animations, with support for ViewPager, ViewPager2, NavController, and badges.
Stars: ✭ 797 (-3.74%)
Mutual labels:  navigation
Mapbox Navigation Ios
Turn-by-turn navigation logic and UI in Swift on iOS
Stars: ✭ 677 (-18.24%)
Mutual labels:  navigation
Uri.js
Javascript URL mutation library
Stars: ✭ 6,119 (+639.01%)
Mutual labels:  url
Webstack
WordPress 版 WebStack 导航主题 https://nav.iowen.cn
Stars: ✭ 662 (-20.05%)
Mutual labels:  navigation
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (-21.62%)
Mutual labels:  navigation
Ypnavigationbartransition
A Full functional UINavigationBar framework for making bar transition more natural! You don't need to call any UINavigationBar api, implementing YPNavigationBarConfigureStyle protocol for your view controller instead. (类似微信 iOS Navigation Bar 的切换方案)
Stars: ✭ 725 (-12.44%)
Mutual labels:  navigation
Gumshoe
A simple vanilla JS scrollspy script.
Stars: ✭ 640 (-22.71%)
Mutual labels:  navigation
Api
姬长信API For Docker 一个基于多种编程语言开源免费不限制提供生活常用,出行服务,开发工具,金融服务,通讯服务和公益大数据的平台.
Stars: ✭ 743 (-10.27%)
Mutual labels:  url
Androidnavigation
A library managing navigation, nested Fragment, StatusBar, Toolbar for Android
Stars: ✭ 636 (-23.19%)
Mutual labels:  navigation
Luxbar
🍸 Featherweight, Responsive, CSS Only Navigation Bar
Stars: ✭ 663 (-19.93%)
Mutual labels:  navigation
Better Link Movement Method
Attempts to improve how clickable links are detected, highlighted and handled in TextView
Stars: ✭ 684 (-17.39%)
Mutual labels:  url
Vscode Bookmarks
Bookmarks Extension for Visual Studio Code
Stars: ✭ 804 (-2.9%)
Mutual labels:  navigation

⚠️ DEPRECATED, NO LONGER MAINTAINED

Compass logo

Version Carthage Compatible License Platform CI Status Swift

Compass helps you setup a central navigation system for your application. This has many benefits, one of them being that controllers can now be decoupled, meaning that the list that presents the detail no longer knows about what its presenting. Controllers become agnostic and views stay stupid. The user experience stays the same but the logic and separation of concerns become clearer. The outcome is that your application will become more modular by default. Anything could potentially be presented from anywhere, but remember, with great power comes great responsibility.

Getting Started

Below are tutorials on how to use Compass

Setup

Step 1

First you need to register a URL scheme for your application.

Step 2

Now you need to configure Compass to use that URL scheme, a good place to do this is in your AppDelegate. Then configure all the routes you wish you support.

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  Navigator.scheme = "compass"
  Navigator.routes = ["profile:{username}", "login:{username}", "logout"]
  return true
}

Step 3

Register your location request handler

Navigator.handle = { [weak self] location in
  let arguments = location.arguments

  let rootController = self?.window.rootViewController as? UINavigationController

  switch location.path {
    case "profile:{username}":
      let profileController = ProfileController(title: arguments["username"])
      rootController?.pushViewController(profileController, animated: true)
    case "login:{username}":
      let loginController = LoginController(title: arguments["username"])
      rootController?.pushViewController(loginController, animated: true)
    case "logout":
      self?.clearLoginSession()
      self?.switchToLoginScreen()
    default: 
      break
  }
}

Step 4

Anywhere in your application, you can just use Navigator to navigate

@IBOutlet func logoutButtonTouched() {
  Navigator.navigate(urn: "logout")
}

Step 5

Optional. If you want to support deep linking, set up your application to respond to the URLs. Setting it up this way would mean that you could open any view from a push notification depending on the contents of the payload.

func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
  do {
    try Navigator.navigate(url: url)
  } catch {
    // Handle error
  }

  return true
}

Compass life hacks

Tip 1. Router

We also have some conventional tools for you that could be used to organize your route handling code and avoid huge switch cases.

  • Implement Routable protocol to keep your single route navigation code in one place:
struct ProfileRoute: Routable {

  func navigate(to location: Location, from currentController: CurrentController) throws {
    guard let username = location.arguments["username"] else { return }

    let profileController = ProfileController(title: username)
    currentController.navigationController?.pushViewController(profileController, animated: true)
  }
}
  • Create a Router instance and register your routes. Think of Router as a composite Routable
let router = Router()
router.routes = [
  "profile:{username}": ProfileRoute(),
  "logout": LogoutRoute()
]
  • Parse URL with Compass and navigate to the route with a help of your Router instance.
func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
  
  return handle(url)
}

func handle(_ url: URL) -> Bool {
  guard let location = Navigator.parse(url) else {
    return false
  }

  router.navigate(to: location, from: navigationController)

  return true
}

Tip 2. Multiple routers

You could set up multiple routers depending on app states. For example, you could have 2 routers for pre and post login.

let preLoginRouter = Router()
preLoginRouter.routes = [
  "profile:{username}" : ProfileRoute()
]

let postLoginRouter = Router()
postLoginRouter.routes = [
  "login:{username}" : LoginRoute()
]

let router = hasLoggedIn ? postLoginRouter : preLoginRouter
router.navigate(to: location, from: navigationController)

Installation

Compass is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Compass'

Compass is also available through Carthage. To install just write into your Cartfile:

github "hyperoslo/Compass"

Author

Hyper Interaktiv AS, [email protected]

Credits

The idea behind Compass came from John Sundell's tech talk "Components & View Models in the Cloud - how Spotify builds native, dynamic UIs"

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].