Navigation, controllers and views separated, like food should be.
Branch: master
Clone or download
Latest commit a7b9461 Jan 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources/zenith Router fix for console logging: Jan 22, 2019
Tests initial commit Sep 17, 2018
.gitignore Clean up and readme file for release Jan 22, 2019
LICENSE Clean up and readme file for release Jan 22, 2019
Package.swift initial commit Sep 17, 2018
README.md
VERSION Version bump Jan 22, 2019
zenith.podspec initial commit Sep 17, 2018

README.md

Zenith

Zenith is a framework for simple and smart seperation of the view controller and view management, leaving your controller to manage interactions and other "controller" like things. As well as a Router to simplify navigation through your app.

Requirements

  • iOS 11.0+
  • Xcode 9.0
  • Swift 4.0

Installation

CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift.
To learn more about setting up your project for CocoaPods, please refer to the official documentation.
To integrate Zenith into your Xcode project using CocoaPods, you have to add it to your project's Podfile:

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

use_frameworks!

target '<Your Target Name>' do
  pod 'Zenith', '~> 1.0'
end

Afterwards, run the following command:

$ pod install

Usage

Zenith allows the view controller to hand off view layout and management to a component.

import UIKit
import Zenith

class MyViewComponent : ViewComponent {
  private lazy var label:UILabel = {
    let label = UILabel()
    label.textAlignment = .center
    label.text = "Hello, world"
    
    return label
  }()
  
  override func setupConstraints() {
    label.addConstraints([
      // Add constraints here
    ])
  }
  
  override func render() -> UIView {
    return children(
     label
    )
  }
}

class MyViewController : ViewController<MyViewComponent> {
  // Your view controller will now load the component and
  // present it, like normal.
}

Zenith also features a router to simplify navigation.

import Zenith

enum MyRoute : RouteOption {
  case home
  case about

  var controller:UIViewController {
    switch self {
    case .home:
      return UINavigationController(rootViewController: MyHomeViewController)
    case .about:
      return UINavigationController(rootViewController: MyAboutViewController)
    }
  }
}

// Create an instance of your router, where you can access it anywhere.

let router = Router<MyRoute>()
router.move(.home)

Credits

Zenith is written and maintained by Wess Cope.
Twitter: @wesscope.

License

Zenith is released under the MIT License.
See LICENSE for details.