Change how view controller delegate extensions work

This commit is contained in:
Shadowfacts 2018-09-03 18:46:20 -04:00
parent bd1f8fa20a
commit cd5d0c4a95
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
6 changed files with 15 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import UIKit
import MastodonKit
import SafariServices
extension UIViewController: StatusTableViewCellDelegate {
extension StatusTableViewCellDelegate where Self: UIViewController {
func selected(account: Account) {
// don't open if the account is the same as the current one
@ -59,6 +59,7 @@ extension UIViewController: StatusTableViewCellDelegate {
}
func showLargeImage(_ image: UIImage, description: String?, animatingFrom originView: UIView) {
guard let self = self as? UIViewController & LargeImageViewControllerDelegate else { return }
let vc = LargeImageViewController.create(image: image, description: description)
vc.delegate = self
var frame = originView.convert(originView.bounds, to: view)
@ -78,7 +79,7 @@ extension UIViewController: StatusTableViewCellDelegate {
}
extension UIViewController: LargeImageViewControllerDelegate {
extension LargeImageViewControllerDelegate where Self: UIViewController {
func closeLargeImage() {
dismiss(animated: true)
}

View File

@ -123,7 +123,7 @@ class ComposeViewController: UIViewController {
guard let status = status else { fatalError("postComplete segue can't occur without Status") }
guard let dest = segue.destination as? MainTabBarViewController,
let navController = dest.selectedViewController as? UINavigationController,
let topVC = navController.topViewController else { return }
let topVC = navController.topViewController as? StatusTableViewCellDelegate else { return }
topVC.selected(status: status)
}
}

View File

@ -120,3 +120,6 @@ class ConversationViewController: UIViewController, UITableViewDataSource, UITab
}
}
extension ConversationViewController: StatusTableViewCellDelegate {}
extension ConversationViewController: LargeImageViewControllerDelegate {}

View File

@ -138,3 +138,6 @@ class NotificationsTableViewController: UITableViewController {
}
}
extension NotificationsTableViewController: StatusTableViewCellDelegate {}
extension NotificationsTableViewController: LargeImageViewControllerDelegate {}

View File

@ -174,3 +174,5 @@ extension ProfileTableViewController: ProfileHeaderTableViewCellDelegate {
}
}
extension ProfileTableViewController: LargeImageViewControllerDelegate {}

View File

@ -132,3 +132,6 @@ class TimelineTableViewController: UITableViewController {
}
}
extension TimelineTableViewController: StatusTableViewCellDelegate {}
extension TimelineTableViewController: LargeImageViewControllerDelegate {}