diff --git a/Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift b/Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift index 6a73496..937c971 100644 --- a/Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift +++ b/Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift @@ -3,10 +3,10 @@ import LinkPresentation public class ShareActivityItemSource: NSObject, UIActivityItemSource { var shareText: String - var shareImage: UIImage + var shareImage: UIImage? var linkMetaData = LPLinkMetadata() - public init(shareText: String, shareImage: UIImage) { + public init(shareText: String, shareImage: UIImage?) { self.shareText = shareText self.shareImage = shareImage linkMetaData.title = shareText diff --git a/Sources/TsuzuKit/Utils/Share/ShareSheet.swift b/Sources/TsuzuKit/Utils/Share/ShareSheet.swift index 475b5cf..c8acdc7 100644 --- a/Sources/TsuzuKit/Utils/Share/ShareSheet.swift +++ b/Sources/TsuzuKit/Utils/Share/ShareSheet.swift @@ -2,18 +2,20 @@ import Foundation import SwiftUI public struct ShareSheet: UIViewControllerRepresentable { - let image: UIImage + let image: UIImage? let text: String - public init(photo: UIImage, text: String) { - self.image = photo + public init(image: UIImage?, text: String) { + self.image = image self.text = text } public func makeUIViewController(context: Context) -> UIActivityViewController { let itemSource = ShareActivityItemSource(shareText: text, shareImage: image) - let activityItems: [Any] = [image, text, itemSource] - + var activityItems: [Any] = [text, itemSource] + if let image { + activityItems.append(image) + } let controller = UIActivityViewController( activityItems: activityItems, applicationActivities: nil