Add link long press actions
This commit is contained in:
parent
9576dad2d9
commit
4cb4f165e2
|
@ -38,6 +38,8 @@ protocol TuskerNavigationDelegate {
|
|||
func showLargeImage(_ image: UIImage, description: String?, animatingFrom originView: UIView)
|
||||
|
||||
func showMoreOptions(forStatus statusID: String)
|
||||
|
||||
func showMoreOptions(forURL url: URL)
|
||||
}
|
||||
|
||||
extension TuskerNavigationDelegate where Self: UIViewController {
|
||||
|
@ -136,11 +138,14 @@ extension TuskerNavigationDelegate where Self: UIViewController {
|
|||
|
||||
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let url = status.url {
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari", style: .default, handler: { (_) in
|
||||
let vc = SFSafariViewController(url: url)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Share", style: .default, handler: { _ in
|
||||
alert.addAction(UIAlertAction(title: "Copy", style: .default, handler: { (_) in
|
||||
UIPasteboard.general.url = url
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Share...", style: .default, handler: { (_) in
|
||||
let vc = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
|
@ -149,4 +154,21 @@ extension TuskerNavigationDelegate where Self: UIViewController {
|
|||
present(alert, animated: true)
|
||||
}
|
||||
|
||||
func showMoreOptions(forURL url: URL) {
|
||||
let alert = UIAlertController(title: nil, message: url.absoluteString, preferredStyle: .actionSheet)
|
||||
alert.addAction(UIAlertAction(title: "Open in Safari", style: .default, handler: { (_) in
|
||||
let vc = SFSafariViewController(url: url)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Copy", style: .default, handler: { (_) in
|
||||
UIPasteboard.general.url = url
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Share...", style: .default, handler: { (_) in
|
||||
let vc = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
||||
self.present(vc, animated: true)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
present(alert, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -117,7 +117,10 @@ class ContentLabel: TTTAttributedLabel {
|
|||
}
|
||||
|
||||
func linkLongPressed(_ label: TTTAttributedLabel!, _ link: TTTAttributedLabelLink!) {
|
||||
// todo: long press options
|
||||
guard let url = link.result.url else {
|
||||
return
|
||||
}
|
||||
navigationDelegate?.showMoreOptions(forURL: url)
|
||||
}
|
||||
|
||||
// MARK: - Navigation
|
||||
|
|
Loading…
Reference in New Issue