2019-09-05 16:49:17 +00:00
|
|
|
//
|
|
|
|
// OpenInSafariActivity.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 9/5/19.
|
|
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import SafariServices
|
|
|
|
|
|
|
|
class OpenInSafariActivity: UIActivity {
|
|
|
|
|
|
|
|
override class var activityCategory: UIActivity.Category {
|
|
|
|
return .action
|
|
|
|
}
|
|
|
|
override var activityType: UIActivity.ActivityType? {
|
|
|
|
return .openInSafari
|
|
|
|
}
|
|
|
|
|
|
|
|
override var activityTitle: String? {
|
|
|
|
return NSLocalizedString("Open in Safari", comment: "open in safari activity title")
|
|
|
|
}
|
|
|
|
override var activityImage: UIImage? {
|
|
|
|
return UIImage(systemName: "safari")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
|
|
|
|
for case is URL in activityItems {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
override func perform() {
|
|
|
|
activityDidFinish(true)
|
|
|
|
}
|
|
|
|
|
2020-09-13 19:51:06 +00:00
|
|
|
static func completionHandler(navigator: TuskerNavigationDelegate, url: URL) -> UIActivityViewController.CompletionWithItemsHandler {
|
2019-09-05 16:49:17 +00:00
|
|
|
return { (activityType, _, _, _) in
|
|
|
|
if activityType == .openInSafari {
|
2020-09-13 19:51:06 +00:00
|
|
|
navigator.show(SFSafariViewController(url: url))
|
2019-09-05 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|