TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Dec 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Christoffer Winterkvist, Vadym Markov.
Brick is a generic view model for both basic and complex scenarios. Mapping a basic table view cells is as easy as pie, if you have more properties, you can use the meta
dictionary to add all additional properties that you might need. It also supports relations so that you can nest view models inside of view models.
public struct Item: Mappable {
public var index = 0
public var title = ""
public var subtitle = ""
public var text = ""
public var image = ""
public var kind = ""
public var action: String?
public var size = CGSize(width: 0, height: 0)
public var meta = [String : AnyObject]()
}
UITableViewCell
it is normally used for textLabel.text
but you are free to use it as you like.UITableViewCell
it is normally used for detailTextLabel.text
.Item
reuseIdentifier
of your UITableViewCell
or UICollectionViewCell
.UITableViewCell
/UICollectionViewCell
, or be manually set by the height calculations inside of your view.let item = Item(
title: "John Hyperseed",
subtitle: "Build machine",
meta: [
"operatingSystem" : "OS X",
"xcodeVersion" : 7.3
])
print(item.meta("operatingSystem", "")) // prints "OS X"
print(item.meta("xcodeVersion", 0.0)) // prints 7.3
Brick is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Brick'
Brick is also available through Carthage. To install just write into your Cartfile:
github "hyperoslo/Brick"
Hyper Interaktiv AS, [email protected]
We would love you to contribute to Brick, check the CONTRIBUTING file for more info.
Brick is available under the MIT license. See the LICENSE file for more info.