Files
GitHawk/Classes/Issues/NeckLoad/IssueNeckLoadSectionController.swift
Ryan Nystrom 65959c7c14 Card inset design completely overhauled (#1396)
* card inset design completely overhauled

* respond to safe area changes
2018-01-13 12:37:00 -05:00

46 lines
1.5 KiB
Swift

//
// IssueNeckLoadSectionController.swift
// Freetime
//
// Created by Ryan Nystrom on 7/27/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import IGListKit
protocol IssueNeckLoadSectionControllerDelegate: class {
func didSelect(sectionController: IssueNeckLoadSectionController)
}
final class IssueNeckLoadSectionController: ListSectionController {
private weak var delegate: IssueNeckLoadSectionControllerDelegate?
private var loadingOverride = false
init(delegate: IssueNeckLoadSectionControllerDelegate) {
self.delegate = delegate
}
override func sizeForItem(at index: Int) -> CGSize {
guard let width = collectionContext?.insetContainerSize.width else { fatalError("Collection context must be set") }
return CGSize(width: width, height: Styles.Sizes.tableCellHeight)
}
override func cellForItem(at index: Int) -> UICollectionViewCell {
guard let cell = collectionContext?.dequeueReusableCell(of: IssueNeckLoadCell.self, for: self, at: index) as? IssueNeckLoadCell
else { fatalError("Missing collection context, cell incorrect type, or object missing") }
cell.configure(loading: loadingOverride)
return cell
}
override func didSelectItem(at index: Int) {
delegate?.didSelect(sectionController: self)
collectionContext?.performBatch(animated: trueUnlessReduceMotionEnabled, updates: { context in
self.loadingOverride = true
context.reload(self)
})
}
}