Add opening URLs in SFSafariViewController

This commit is contained in:
Shadowfacts 2018-08-27 15:23:59 -04:00
parent e512afbd5c
commit c5caa81a22
2 changed files with 33 additions and 3 deletions

View File

@ -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)
}
}

View File

@ -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)
}
}