2021-10-26 22:59:59 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ShareSheet: UIViewControllerRepresentable {
|
|
|
|
typealias Callback = (_ activityType: UIActivity.ActivityType?,
|
|
|
|
_ completed: Bool,
|
2024-08-18 12:46:51 +00:00
|
|
|
_ returnedItems: [Any],
|
2021-10-26 22:59:59 +00:00
|
|
|
_ error: Error?) -> Void
|
|
|
|
|
|
|
|
let activityItems: [Any]
|
|
|
|
let applicationActivities = [UIActivity]()
|
|
|
|
let excludedActivityTypes = [UIActivity.ActivityType]()
|
|
|
|
let callback: Callback? = nil
|
|
|
|
|
|
|
|
func makeUIViewController(context _: Context) -> UIActivityViewController {
|
|
|
|
let controller = UIActivityViewController(
|
|
|
|
activityItems: activityItems,
|
|
|
|
applicationActivities: applicationActivities
|
|
|
|
)
|
|
|
|
|
|
|
|
controller.excludedActivityTypes = excludedActivityTypes
|
2024-08-18 12:46:51 +00:00
|
|
|
|
|
|
|
controller.completionWithItemsHandler = { activityType, completed, returnedItems, error in
|
|
|
|
callback?(activityType, completed, returnedItems ?? [], error)
|
|
|
|
}
|
2021-10-26 22:59:59 +00:00
|
|
|
|
|
|
|
return controller
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateUIViewController(_: UIActivityViewController, context _: Context) {}
|
|
|
|
}
|