Skip to content
A architecture builder helping you to build your project.
Swift Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
SwiftScaffold
.gitignore
.swift-version
.travis.yml
LICENSE
README.md
SwiftScaffold.podspec
_Pods.xcodeproj

README.md

SwiftScaffold

SwiftScaffold is a architecture builder, which helps you to create a well-structured project. SwiftScaffold now mainly focus on the MVVM-Coordinator pattern. 🏗️

If you're looking for an introduction to MVVM, there you're.

Structure

Cooridnator

The role of coordinator is to navigate the app, like transition, present, pop and so on. Every screen should have one coordinaor handling the navigation of it.

ViewModel

(TBD)

View

(TBD)

Controller

(TBD)

Usage

Coordinator

In this project, Coordinator is basically just a protocol. Object confirming this protocol is a domain specific coordinator in your project. Here, all you need to implement is the rootViewController:

class BaseCoordinator: Coordinator {
    var rootViewController: CoordinatorManagedViewController = AnyViewController()
}

The CoordinatorManagedViewController is a type alias, which is defined like this:

public typealias CoordinatorManagedViewController = UIViewController & CoordinatorManaged

That is, you need to implement your view controller to conform the CoordinatorManaged, so that it could be managed by the coordinator. The implemetation is easy, too:

private class AnyViewController: CoordinatorManagedViewController {

    func open(from viewController: UIViewController) {
		// Define the presenting transition here
		viewController.present(self, animated: true, completion: nil)
    }

    func close() {
    	// Define the close transition here 
		self.dismiss(animated: true, completion: nil)
    }
}

Once the implementation is finished, we can use the coordinator like this:

// This represent current screen 
let mainCoordinator = BaseCoordinator() 

// Create another coordinator for the next screen
let detailCoordinator = DetailCoordinator() 

// This will present the root controller of detailCoordinator
mainCoordinator.present(coordinator: detailCoordinator)  

We are all set 🏗️.

With the help of this, you're able to write test for all navigation, and separate the responsibility of routing.

Requirements

Installation

Currently, SwiftScaffold is NOT available through CocoaPods. Please stay tuned and I'll update one the project finished.

Author

ShihTing Huang, koromiko1104@gmail.com

License

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

You can’t perform that action at this time.