From 9e437797d98a84c03c7d0261426df0be0973ae78 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 28 Apr 2022 16:57:06 -0700 Subject: [PATCH] Improves CopyDeepLinkActivity * Uses SF Symbol instead of bundled image * Actually calls activityDidFinish(_:) --- Delta/Deep Linking/CopyDeepLinkActivity.swift | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Delta/Deep Linking/CopyDeepLinkActivity.swift b/Delta/Deep Linking/CopyDeepLinkActivity.swift index 3dfc956..7e54bc7 100644 --- a/Delta/Deep Linking/CopyDeepLinkActivity.swift +++ b/Delta/Deep Linking/CopyDeepLinkActivity.swift @@ -15,6 +15,8 @@ extension UIActivity.ActivityType class CopyDeepLinkActivity: UIActivity { + private var deepLink: URL? + override class var activityCategory: UIActivity.Category { return .action } @@ -28,7 +30,7 @@ class CopyDeepLinkActivity: UIActivity } override var activityImage: UIImage? { - return UIImage(named: "Link") + return UIImage(symbolNameIfAvailable: "link") ?? UIImage(named: "Link") } override func canPerform(withActivityItems activityItems: [Any]) -> Bool @@ -47,7 +49,19 @@ class CopyDeepLinkActivity: UIActivity { guard let game = activityItems.first(where: { $0 is Game }) as? Game else { return } - let deepLink = URL(action: .launchGame(identifier: game.identifier)) - UIPasteboard.general.url = deepLink + self.deepLink = URL(action: .launchGame(identifier: game.identifier)) + } + + override func perform() + { + if let deepLink = self.deepLink + { + UIPasteboard.general.url = deepLink + self.activityDidFinish(true) + } + else + { + self.activityDidFinish(false) + } } }