Files
GitHawk/Classes/PullRequestReviews/PullRequestReviewReplySectionController.swift
Ryan Nystrom ec4807d415 Reply to Pull Request Review comments (#1483)
* wip

* reply cell shows up in comments

* focus on reply model and scroll to reply

* api to create PR comment replies

* reply working

* clean and code reuse

* even more reuse

* organize
2018-02-04 19:08:34 -05:00

41 lines
1.4 KiB
Swift

//
// PullRequestReviewReplySectionController.swift
// Freetime
//
// Created by Ryan Nystrom on 1/29/18.
// Copyright © 2018 Ryan Nystrom. All rights reserved.
//
import Foundation
import IGListKit
protocol PullRequestReviewReplySectionControllerDelegate: class {
func didSelect(replySectionController: PullRequestReviewReplySectionController, reply: PullRequestReviewReplyModel)
}
final class PullRequestReviewReplySectionController: ListGenericSectionController<PullRequestReviewReplyModel> {
private weak var delegate: PullRequestReviewReplySectionControllerDelegate?
init(delegate: PullRequestReviewReplySectionControllerDelegate) {
self.delegate = delegate
}
override func sizeForItem(at index: Int) -> CGSize {
guard let width = collectionContext?.insetContainerSize.width else { return .zero }
return CGSize(width: width, height: Styles.Sizes.tableCellHeight)
}
override func cellForItem(at index: Int) -> UICollectionViewCell {
guard let cell = collectionContext?.dequeueReusableCell(of: PullRequestReviewReplyCell.self, for: self, at: index) as? PullRequestReviewReplyCell
else { fatalError("Missing context or wrong cell") }
return cell
}
override func didSelectItem(at index: Int) {
guard let object = self.object else { return }
delegate?.didSelect(replySectionController: self, reply: object)
}
}