IGListKit/Example/IGListKitExamples/SectionControllers/EmbeddedSectionController.swift
Bofei Zhu 59242c5b7e Add final to each class in Example
Summary: Closes https://github.com/Instagram/IGListKit/pull/173

Differential Revision: D4143811

Pulled By: rnystrom

fbshipit-source-id: 879ba9fa858648677fd2e3750bcf1815ac37ef18
2016-11-07 15:59:04 -08:00

50 lines
1.6 KiB
Swift

/**
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
final class EmbeddedSectionController: IGListSectionController, IGListSectionType {
var number: Int?
override init() {
super.init()
self.inset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 10)
}
func numberOfItems() -> Int {
return 1
}
func sizeForItem(at index: Int) -> CGSize {
let height = collectionContext?.containerSize.height ?? 0
return CGSize(width: height, height: height)
}
func cellForItem(at index: Int) -> UICollectionViewCell {
let cell = collectionContext!.dequeueReusableCell(of: CenterLabelCell.self, for: self, at: index) as! CenterLabelCell
let value = number ?? 0
cell.label.text = "\(value + 1)"
cell.backgroundColor = UIColor(red: 237/255.0, green: 73/255.0, blue: 86/255.0, alpha: 1)
return cell
}
func didUpdate(to object: Any) {
number = object as? Int
}
func didSelectItem(at index: Int) {}
}