Create a grid layout for IGList

Summary:
Rebase from #140:

Create a flow layout for IGList that does not newline sections. Closes #3

- [x] Minimum inter-item spacing
- [x] Minimum line spacing
- [x] Constant item size with constant layout time
- [x] Update layout on insert/delete/move
- [x] Unit Test
Closes https://github.com/Instagram/IGListKit/pull/225

Differential Revision: D4211469

Pulled By: rnystrom

fbshipit-source-id: f4710dbf195701098ac50f94b6b2aa8c801b2a83
This commit is contained in:
Bofei Zhu
2016-11-21 13:25:52 -08:00
committed by Facebook Github Bot
parent 4f97e58162
commit 1d3e58b9fd
10 changed files with 1165 additions and 569 deletions

View File

@@ -15,28 +15,35 @@
import UIKit
import IGListKit
protocol StoryboardLabelSectionControllerDelegate: class {
func removeSectionControllerWantsRemoved(_ sectionController: StoryboardLabelSectionController)
}
final class StoryboardLabelSectionController: IGListSectionController, IGListSectionType {
var object: String?
var object: Person?
weak var delegate: StoryboardLabelSectionControllerDelegate?
func numberOfItems() -> Int {
return 1
}
func sizeForItem(at index: Int) -> CGSize {
return CGSize(width: collectionContext!.containerSize.width, height: 55)
return CGSize(width: (self.object?.name.characters.count)! * 7, height: (self.object?.name.characters.count)! * 7)
}
func cellForItem(at index: Int) -> UICollectionViewCell {
let cell = collectionContext!.dequeueReusableCellFromStoryboard(withIdentifier: "cell", for: self, at: index) as! StoryboardCell
cell.textLabel.text = object
cell.textLabel.text = object?.name
return cell
}
func didUpdate(to object: Any) {
self.object = object as? String
self.object = object as? Person
}
func didSelectItem(at index: Int) {}
func didSelectItem(at index: Int) {
delegate?.removeSectionControllerWantsRemoved(self)
}
}