diff --git a/Classes/Notifications/NoNewNotificationsCell.swift b/Classes/Notifications/NoNewNotificationsCell.swift index e24814271..c7f741333 100644 --- a/Classes/Notifications/NoNewNotificationsCell.swift +++ b/Classes/Notifications/NoNewNotificationsCell.swift @@ -9,17 +9,17 @@ import UIKit import SnapKit -protocol ReviewGitHubAccessDelegate: class { - func reviewGitHubAccessButtonTapped() +protocol NoNewNotificationsCellReviewAccessDelegate: class { + func didTapReviewAccess(cell: NoNewNotificationsCell) } final class NoNewNotificationsCell: UICollectionViewCell { - let emojiLabel = UILabel() - let messageLabel = UILabel() - let shadow = CAShapeLayer() - let reviewGitHubAccessButton = UIButton() - weak var reviewGitHubAccessDelegate: ReviewGitHubAccessDelegate? + private let emojiLabel = UILabel() + private let messageLabel = UILabel() + private let shadow = CAShapeLayer() + private let reviewGitHubAccessButton = UIButton() + private weak var reviewGitHubAccessDelegate: NoNewNotificationsCellReviewAccessDelegate? override init(frame: CGRect) { super.init(frame: frame) @@ -116,10 +116,11 @@ final class NoNewNotificationsCell: UICollectionViewCell { // MARK: Public API - func configure(emoji: String, - message: String, - reviewGitHubAccessDelegate: ReviewGitHubAccessDelegate?) - { + func configure( + emoji: String, + message: String, + reviewGitHubAccessDelegate: NoNewNotificationsCellReviewAccessDelegate? + ) { emojiLabel.text = emoji messageLabel.text = message self.reviewGitHubAccessDelegate = reviewGitHubAccessDelegate @@ -152,7 +153,7 @@ final class NoNewNotificationsCell: UICollectionViewCell { } @objc func reviewGitHubAccessButtonTapped() { - reviewGitHubAccessDelegate?.reviewGitHubAccessButtonTapped() + reviewGitHubAccessDelegate?.didTapReviewAccess(cell: self) } } diff --git a/Classes/Notifications/NoNewNotificationsSectionController.swift b/Classes/Notifications/NoNewNotificationsSectionController.swift index 598c0b00e..006104ab1 100644 --- a/Classes/Notifications/NoNewNotificationsSectionController.swift +++ b/Classes/Notifications/NoNewNotificationsSectionController.swift @@ -9,16 +9,15 @@ import UIKit import IGListKit -final class NoNewNotificationSectionController: ListSwiftSectionController { +final class NoNewNotificationSectionController: ListSwiftSectionController, +NoNewNotificationsCellReviewAccessDelegate { private let layoutInsets: UIEdgeInsets private let loader = InboxZeroLoader() - weak var reviewGitHubAccessDelegate: ReviewGitHubAccessDelegate? - init(layoutInsets: UIEdgeInsets, reviewGitHubAccessDelegate: ReviewGitHubAccessDelegate) { + init(layoutInsets: UIEdgeInsets) { self.layoutInsets = layoutInsets super.init() - self.reviewGitHubAccessDelegate = reviewGitHubAccessDelegate loader.load { [weak self] success in if success { self?.update() @@ -42,12 +41,23 @@ final class NoNewNotificationSectionController: ListSwiftSectionController ListSwiftPair { let layoutInsets = view.safeAreaInsets return ListSwiftPair.pair("empty-notification-value", { - return NoNewNotificationSectionController( - layoutInsets: layoutInsets, - reviewGitHubAccessDelegate: self - ) + return NoNewNotificationSectionController(layoutInsets: layoutInsets) }) } @@ -310,13 +306,4 @@ ReviewGitHubAccessDelegate didSingleTapTab() } - // MARK: ReviewGitHubAccessDelegate - func reviewGitHubAccessButtonTapped() { - //copied/pasted from SettingsViewController... could consolidate - guard let url = URL(string: "https://github.com/settings/connections/applications/\(Secrets.GitHub.clientId)") - else { fatalError("Should always create GitHub issue URL") } - // iOS 11 login uses SFAuthenticationSession which shares credentials with Safari.app - UIApplication.shared.open(url) - } - }