Skip to content

Commit

Permalink
Merge pull request #3 from tsuzukihashi/fix/sharesheet
Browse files Browse the repository at this point in the history
Fix/sharesheet
  • Loading branch information
tsuzukihashi authored Jul 15, 2024
2 parents 6bc3b1f + 12e10f9 commit bfb4078
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions Sources/TsuzuKit/Utils/Share/ShareSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bfb4078

Please sign in to comment.