Open thevwu opened 7 years ago
The reason that BrickSection doesn't support repeat count is not the repeating itself, if when the repeat count changes on the fly. The current internal datamodel doesn't support inserting, deleting, moving sections. So if you don't invalidateRepeatCounts, this should be no issue to work
If I repeat a BrickSection 3 times, then all three Brick1s should have the same identifier. If it's a label brick, how do I pass a different text to all three Brick1s?
A BrickSection is a brick, so adding support to the internal data model to support inserting/deleting should be simple as the functionality technically already exists. It just has to be extrapolated.
If this BrickSection was repeated 3 times, then moving sections should be moving all 3 repeated sections due to how this would be implemented. If they wanted to move an individual section, then they should use an individual section instead of a repeated one.
As of right now, the only way to repeat two or more bricks in a sequence is to use collectionBrick.
Example, (Brick 1 Brick 2) (Brick 1 Brick 2)
We should be able to attach a "sectionIndex" to brickSections now, as brickSections are now a type of Bricks. This was more difficult in the past as we had a separate model for brickSections. The way to do this is when checking the repeatCount for a brick, check to see if it is a brickSection. If it's a brickSection, attach a sectionIndex based off of the repeatCount for the number of brickSections that are being repeated.
Adjusting the code in the function
static fileprivate func addSection(_ sectionIndexPaths: inout [Int: IndexPath], sectionCount: inout Int, bricks: [Brick], repeatCountDataSource: BrickRepeatCountDataSource?, atIndexPath indexPath: IndexPath? = nil, in collection: CollectionInfo)
in BrickModels.swift should do the trick. Just set BrickSection.sectionIndex = index instead of giving a fatalError saying it's not supported.