Skip to content

Instantly share code, notes, and snippets.

@gwennguihal
Last active February 19, 2019 08:56
Show Gist options
  • Save gwennguihal/bd40bf02dab9327ced3600b1c0715e08 to your computer and use it in GitHub Desktop.
Save gwennguihal/bd40bf02dab9327ced3600b1c0715e08 to your computer and use it in GitHub Desktop.
import Foundation
import Collor
public class Builder {
private(set) unowned var sectionDescriptor: CollectionSectionDescribable
public private(set) var cells = [CollectionCellDescribable]()
public init(sectionDescriptor: CollectionSectionDescribable) {
self.sectionDescriptor = sectionDescriptor
}
@discardableResult public func add(cell: CollectionCellDescribable) -> CollectionCellDescribable {
cells.append(cell)
return cell
}
@discardableResult public func add(label: LabelAdapterProtocol) -> CollectionCellDescribable {
let cellDescriptor = LabelDescriptor(adapter: label)
return add(cell: cellDescriptor)
}
}
// A label Adapter
struct ALabelAdapter: LabelAdapterProtocol {
var label: NSAttributedString = "In tempus velit suscipit mauris aliquet egestas."
.withFont(.systemFont(ofSize: 12))
.withTextColor(.lightGray)
.withParagraphStyle(.center)
}
// In the collectionData, one line of code to add a text or a label
builder.add(label: ALabelAdapter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment