diff options
author | Nicholas Tay <nick@windblume.net> | 2022-07-18 10:24:49 +1000 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-07-18 10:26:05 +1000 |
commit | 338256206f5e11d7e21a714dedb461ae89281526 (patch) | |
tree | a67e03473a2f2e749e58b2babe532ace9d396826 /foray/Coordinators | |
parent | 8b255702c674bf1bfeca96697711f6e4f088dfdb (diff) | |
download | forayios-338256206f5e11d7e21a714dedb461ae89281526.tar.gz forayios-338256206f5e11d7e21a714dedb461ae89281526.tar.bz2 forayios-338256206f5e11d7e21a714dedb461ae89281526.zip |
Custom share sheet icons and load them with UIImage
Found that LPLinkMetadata + NSItemProvider can actually use UIImage. I
think this is better now since not using a bundle load and can use
assets.
Diffstat (limited to '')
-rw-r--r-- | foray/Coordinators/ForayCoordinator.swift | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/foray/Coordinators/ForayCoordinator.swift b/foray/Coordinators/ForayCoordinator.swift index 972bfb8..70febce 100644 --- a/foray/Coordinators/ForayCoordinator.swift +++ b/foray/Coordinators/ForayCoordinator.swift @@ -39,7 +39,7 @@ class ForayCoordinator: Coordinator { } func share(item: PenguinItemViewModel) { - let itemSource = ForayLinkPresentationSource(title: "\(item.name) (#\(item.id))", shareURL: URL(string: "https://nick.tay.blue/")!) + let itemSource = ForayLinkPresentationSource(title: "\(item.name) (#\(item.id))", shareURL: URL(string: "https://nick.tay.blue/")!, image: item.icon) let activity = UIActivityViewController(activityItems: [itemSource], applicationActivities: nil) navigationController.present(activity, animated: true) } @@ -61,9 +61,9 @@ class ForayLinkPresentationSource: NSObject, UIActivityItemSource { return metadata.originalURL } - init(title: String, shareURL: URL) { + init(title: String, shareURL: URL, image: UIImage? = nil) { metadata = LPLinkMetadata() - metadata.iconProvider = NSItemProvider(contentsOf: Bundle.main.url(forResource: "spy", withExtension: "png")) + metadata.iconProvider = NSItemProvider(object: image ?? UIImage.fromAsset(.spy)) metadata.originalURL = shareURL metadata.url = shareURL metadata.title = title |