1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 05:40:32 +05:30
yattee/iOS/ShareSheet.swift

32 lines
1.1 KiB
Swift
Raw Normal View History

2021-10-27 04:29:59 +05:30
import Foundation
import SwiftUI
struct ShareSheet: UIViewControllerRepresentable {
typealias Callback = (_ activityType: UIActivity.ActivityType?,
_ completed: Bool,
_ returnedItems: [Any],
2021-10-27 04:29:59 +05:30
_ 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
controller.completionWithItemsHandler = { activityType, completed, returnedItems, error in
callback?(activityType, completed, returnedItems ?? [], error)
}
2021-10-27 04:29:59 +05:30
return controller
}
func updateUIViewController(_: UIActivityViewController, context _: Context) {}
}