diff --git a/Tusker/View Controllers/TimelineTableViewController.swift b/Tusker/View Controllers/TimelineTableViewController.swift index 7fb78803..28354913 100644 --- a/Tusker/View Controllers/TimelineTableViewController.swift +++ b/Tusker/View Controllers/TimelineTableViewController.swift @@ -9,6 +9,7 @@ import UIKit import MastodonKit import SwiftSoup +import SafariServices class TimelineTableViewController: UITableViewController { @@ -90,6 +91,8 @@ class TimelineTableViewController: UITableViewController { let status = statuses[indexPath.row] cell.updateUI(for: status) + + cell.delegate = self return cell } @@ -123,3 +126,18 @@ class TimelineTableViewController: UITableViewController { } } + +extension TimelineTableViewController: StatusTableViewCellDelegate { + func selected(mention: Mention) { + + } + + func selected(tag: MastodonKit.Tag) { + + } + + func selected(url: URL) { + let vc = SFSafariViewController(url: url) + present(vc, animated: true) + } +} diff --git a/Tusker/Views/StatusTableViewCell.swift b/Tusker/Views/StatusTableViewCell.swift index 16cedae9..cbeff0e4 100644 --- a/Tusker/Views/StatusTableViewCell.swift +++ b/Tusker/Views/StatusTableViewCell.swift @@ -10,8 +10,20 @@ import UIKit import MastodonKit import SwiftSoup +protocol StatusTableViewCellDelegate { + + func selected(mention: Mention) + + func selected(tag: MastodonKit.Tag) + + func selected(url: URL) + +} + class StatusTableViewCell: UITableViewCell { + var delegate: StatusTableViewCellDelegate? + @IBOutlet weak var displayNameLabel: UILabel! @IBOutlet weak var usernameLabel: UILabel! @IBOutlet weak var contentLabel: StatusContentLabel! @@ -64,15 +76,15 @@ class StatusTableViewCell: UITableViewCell { extension StatusTableViewCell: StatusContentLabelDelegate { func selected(mention: Mention) { - print("selected mention: \(mention.acct)") + delegate?.selected(mention: mention) } func selected(tag: MastodonKit.Tag) { - print("selected tag: \(tag.name)") + delegate?.selected(tag: tag) } func selected(url: URL) { - print("selected url: \(url)") + delegate?.selected(url: url) } }