From e8e2f8f87949f2dd89c72aec01bf53802a0061ff Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 27 Aug 2018 15:23:59 -0400 Subject: [PATCH] Add opening URLs in SFSafariViewController --- .../TimelineTableViewController.swift | 18 ++++++++++++++++++ Tusker/Views/StatusTableViewCell.swift | 18 +++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) 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) } }