2016-10-25 22:17:45 +00:00
|
|
|
/**
|
|
|
|
|
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
The examples provided by Facebook are for non-commercial testing and evaluation
|
|
|
|
|
purposes only. Facebook reserves all rights not expressly granted.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
import IGListKit
|
|
|
|
|
|
2016-11-21 21:25:52 +00:00
|
|
|
protocol StoryboardLabelSectionControllerDelegate: class {
|
|
|
|
|
func removeSectionControllerWantsRemoved(_ sectionController: StoryboardLabelSectionController)
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 23:53:31 +00:00
|
|
|
final class StoryboardLabelSectionController: IGListSectionController, IGListSectionType {
|
2016-10-25 22:17:45 +00:00
|
|
|
|
2016-11-21 21:25:52 +00:00
|
|
|
var object: Person?
|
|
|
|
|
weak var delegate: StoryboardLabelSectionControllerDelegate?
|
2016-10-25 22:17:45 +00:00
|
|
|
|
|
|
|
|
func numberOfItems() -> Int {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func sizeForItem(at index: Int) -> CGSize {
|
2016-11-21 21:25:52 +00:00
|
|
|
return CGSize(width: (self.object?.name.characters.count)! * 7, height: (self.object?.name.characters.count)! * 7)
|
2016-10-25 22:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func cellForItem(at index: Int) -> UICollectionViewCell {
|
|
|
|
|
let cell = collectionContext!.dequeueReusableCellFromStoryboard(withIdentifier: "cell", for: self, at: index) as! StoryboardCell
|
2016-11-21 21:25:52 +00:00
|
|
|
cell.textLabel.text = object?.name
|
2016-10-25 22:17:45 +00:00
|
|
|
return cell
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func didUpdate(to object: Any) {
|
2016-11-21 21:25:52 +00:00
|
|
|
self.object = object as? Person
|
2016-10-25 22:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-21 21:25:52 +00:00
|
|
|
func didSelectItem(at index: Int) {
|
|
|
|
|
delegate?.removeSectionControllerWantsRemoved(self)
|
|
|
|
|
}
|
2016-10-25 22:17:45 +00:00
|
|
|
|
|
|
|
|
}
|