// // UIViewController+StatusTableViewCellDelegate.swift // Tusker // // Created by Shadowfacts on 8/27/18. // Copyright © 2018 Shadowfacts. All rights reserved. // import UIKit import MastodonKit import SafariServices extension UIViewController: StatusTableViewCellDelegate { func selected(account: Account) { // don't open if the account is the same as the current one if let profileController = self as? ProfileTableViewController, profileController.account == account { return } guard let navigationController = navigationController else { fatalError("Can't show profile VC when not in navigation controller") } let vc = ProfileTableViewController.create(for: account) navigationController.pushViewController(vc, animated: true) } func selected(mention: Mention) { } func selected(tag: Tag) { } func selected(url: URL) { let vc = SFSafariViewController(url: url) present(vc, animated: true) } func selected(status: Status) { // don't open if the conversation is the same as the current one if let conversationController = self as? ConversationViewController, conversationController.mainStatus == status { return } guard let navigationController = navigationController else { fatalError("Can't show conversation VC when not in navigation controller") } let vc = ConversationViewController.create(for: status) navigationController.pushViewController(vc, animated: true) } func reply(to status: Status) { let vc = ComposeViewController.create(inReplyTo: status) present(vc, animated: true) } }