diff --git a/Tusker/Activities/UIActivity+Types.swift b/Tusker/Activities/UIActivity+Types.swift index 1f5d9a182c..4fc0de39b8 100644 --- a/Tusker/Activities/UIActivity+Types.swift +++ b/Tusker/Activities/UIActivity+Types.swift @@ -11,8 +11,12 @@ import UIKit extension UIActivity.ActivityType { static let openInSafari = UIActivity.ActivityType("\(Bundle.main.bundleIdentifier!).open_in_safari") + + // Account static let sendMessageMentioningAccount = UIActivity.ActivityType("\(Bundle.main.bundleIdentifier!).send_message_mentioning_account") static let followAccount = UIActivity.ActivityType("\(Bundle.main.bundleIdentifier!).follow_account") static let unfollowAccount = UIActivity.ActivityType("\(Bundle.main.bundleIdentifier!).unfollow_account") + // Status + } diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index 7f51b8e4d1..a6ae82b25a 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -146,25 +146,16 @@ extension TuskerNavigationDelegate where Self: UIViewController { present(gallery(attachments: attachments, sourceViews: sourceViews, startIndex: startIndex), animated: true) } - private func moreOptions(forURL url: URL) -> UIAlertController { - let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - alert.title = url.absoluteString - 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)) - return alert + private func moreOptions(forURL url: URL) -> UIViewController { + let customActivites: [UIActivity] = [ + OpenInSafariActivity() + ] + let activityController = UIActivityViewController(activityItems: [url], applicationActivities: customActivites) + activityController.completionWithItemsHandler = OpenInSafariActivity.completionHandler(viewController: self, url: url) + return activityController } - private func moreOptions(forStatus statusID: String) -> UIAlertController { + private func moreOptions(forStatus statusID: String) -> UIViewController { guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID)") } guard let url = status.url else { fatalError("Missing url for status \(statusID)") } return moreOptions(forURL: url)