Files
GitHawk/Classes/Settings/SettingsReportSectionController.swift
2017-06-26 10:38:21 -04:00

40 lines
1.4 KiB
Swift

//
// SettingsReportSectionController.swift
// Freetime
//
// Created by Ryan Nystrom on 6/25/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import Foundation
import IGListKit
import SafariServices
final class SettingsReportSectionController: ListSectionController {
override init() {
super.init()
inset = UIEdgeInsets(top: 0, left: 0, bottom: Styles.Sizes.tableSectionSpacing, right: 0)
}
override func sizeForItem(at index: Int) -> CGSize {
guard let width = collectionContext?.containerSize.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: ButtonCell.self, for: self, at: index) as? ButtonCell
else { fatalError("Collection context must be set or cell incorrect type") }
cell.label.text = NSLocalizedString("Report a Bug", comment: "")
return cell
}
override func didSelectItem(at index: Int) {
guard let url = URL(string: "https://github.com/rnystrom/Freetime/issues/new")
else { fatalError("Should always create GitHub issue URL") }
let safari = SFSafariViewController(url: url)
viewController?.present(safari, animated: true)
}
}