From 12e10f9389cbf84de9afd6a9abdd744b1db1b6a9 Mon Sep 17 00:00:00 2001 From: Ryo Tsuzukihashi Date: Mon, 15 Jul 2024 15:27:25 +0900 Subject: [PATCH] Update ShareSheet.swift --- Sources/TsuzuKit/Utils/Share/ShareSheet.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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