Last active
February 19, 2019 08:56
-
-
Save gwennguihal/bd40bf02dab9327ced3600b1c0715e08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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