Skip to content

Commit

Permalink
Merge pull request #4 from tsuzukihashi/feature/sharesheet
Browse files Browse the repository at this point in the history
add: share description
  • Loading branch information
tsuzukihashi authored Jul 15, 2024
2 parents bfb4078 + 91851a5 commit 1b229cf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Sources/TsuzuKit/Utils/Share/ShareActivityItemSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Foundation
import LinkPresentation

public class ShareActivityItemSource: NSObject, UIActivityItemSource {
var shareText: String
var shareImage: UIImage?
var linkMetaData = LPLinkMetadata()
private let title: String
private let linkMetaData = LPLinkMetadata()

public init(shareText: String, shareImage: UIImage?) {
self.shareText = shareText
self.shareImage = shareImage
linkMetaData.title = shareText
public init(
title: String
) {
self.title = title
linkMetaData.title = title
super.init()
}

Expand Down
23 changes: 17 additions & 6 deletions Sources/TsuzuKit/Utils/Share/ShareSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@ import Foundation
import SwiftUI

public struct ShareSheet: UIViewControllerRepresentable {
let image: UIImage?
let text: String
private let image: UIImage?
private let title: String
private let description: String?

public init(image: UIImage?, text: String) {
public init(
title: String,
image: UIImage?,
description: String?
) {
self.title = title
self.image = image
self.text = text
self.description = description
}

public func makeUIViewController(context: Context) -> UIActivityViewController {
let itemSource = ShareActivityItemSource(shareText: text, shareImage: image)
var activityItems: [Any] = [text, itemSource]
let itemSource = ShareActivityItemSource(
title: title
)
var activityItems: [Any] = [itemSource]
if let image {
activityItems.append(image)
}
if let description {
activityItems.append(description)
}
let controller = UIActivityViewController(
activityItems: activityItems,
applicationActivities: nil
Expand Down

0 comments on commit 1b229cf

Please sign in to comment.