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
| public struct IfLet<T: OptionalType>: Content { | |
| let data: T | |
| let builder: (T.Wrapped) -> Content | |
| public init(_ data: T, @ContentBuilder _ builder: @escaping (T.Wrapped) -> Content) { | |
| self.data = data | |
| self.builder = builder | |
| } | |
| public var contents: [Content]? { |
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
| public struct Map<Data: Collection>: Content { | |
| var data: Data | |
| var mapClosure: (Data.Element) -> Content | |
| public init(_ data: Data, @ContentBuilder _ mapClosure: @escaping (Data.Element) -> Content) { | |
| self.data = data | |
| self.builder = builder | |
| } | |
| public var contents: [Content]? { | |
| return data.map { mapClosure($0) } |
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
| public class DataSource: NSObject { | |
| public var sections = [Section]() | |
| } | |
| extension DataSource: UITableViewDataSource { | |
| public func numberOfSections(in tableView: UITableView) -> Int { | |
| return sections.count | |
| } | |
| public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
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
| lazy var dataSource = DataSource { | |
| Section { | |
| LabelCell(HeaderAdapter(label: "Example")) | |
| Spacer(32) | |
| } | |
| model.items.ui.map { item in | |
| Section { | |
| Spacer() |
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
| override func reloadData() { | |
| super.reloadData() | |
| //... | |
| let section = RandomSectionDescriptor().reloadSection { cells in | |
| let titleItem = TitleDescriptor(adapter: TeamTitleAdapter(team: team)) | |
| cells.append(titleItem) | |
| team.members.forEach { member in |
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 | |
| import CollorAPI | |
| final class SampleCollectionData: CollorAPI.CollectionData { | |
| override func reloadData() { | |
| super.reloadData() | |
| addSection().horizontalInset(.big).reloadSection { builder in | |
| let block = builder.startDecorationBlock(type: .whiteBordered) |
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
| addSection().reloadSection { builder in | |
| builder.journeyTimeline { timelineBuilder in | |
| timelineBuilder.departure(...) | |
| timelineBuilder.add(verticalSpace: ...) | |
| timelineBuilder.info(descriptor: ...) | |
| timelineBuilder.segmentArrival(..) | |
| timelineBuilder.segmentDeparture(...) | |
| timelineBuilder.info(descriptor: ...) | |
| timelineBuilder.arrival(...) |
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
| override open func prepare() { | |
| super.prepare() | |
| //... | |
| let decorationBlocks = collectionViewData.sections | |
| .compactMap { $0 as? SectionDescriptor } | |
| .flatMap { $0.decorationBlocks } | |
| // ... | |
| // after computing vertical spaces | |
| decorationBlocks.forEach { decorationBlock in |
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
| public func startDecorationBlock(type: DecorationBlockType) -> DecorationBlock { | |
| let startindex = cells.indices.last.flatMap { $0 + 1 } ?? 0 // start the decorationView after the last cell | |
| let decorationBlock = DecorationBlock(type: type, startItemIndex: startindex, sectionDescriptor: sectionDescriptor) | |
| return decorationBlock | |
| } | |
| public func endDecorationBlock(_ block: DecorationBlock?) { | |
| guard let block = block else { | |
| return | |
| } |
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
| public final class DecorationBlock { | |
| public let type: DecorationBlockType | |
| unowned var sectionDescriptor: CollectionSectionDescribable | |
| var startItemIndex: Int | |
| var endItemIndex: Int | |
| var firstIndexPath: IndexPath? { | |
| guard let sectionIndex = sectionDescriptor.index else { |
NewerOlder