Last active
February 27, 2019 08:11
-
-
Save gwennguihal/82abeae3fe0354437d924827d82860c9 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
| 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 | |
| } | |
| // error if empty section | |
| guard let lastIndex = cells.indices.last else { | |
| fatalError("End block in a no empty section") | |
| } | |
| // check if startItemIndex does exist | |
| guard cells.indices.contains(block.startItemIndex) else { | |
| fatalError("Add a cell after startDecorationBlock(:) and before calling endDecorationBlock()") | |
| } | |
| block.endItemIndex = lastIndex | |
| decorationBlocks.append(block) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment