mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add support for sharing URLs and text. (#3546)
* Add support for sharing URLs and text. * Fix a bug where a stored draft would overwrite the shared text. * Add tests.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
extension NSItemProvider {
|
||||
@@ -15,6 +15,19 @@ extension NSItemProvider {
|
||||
let fileExtension: String
|
||||
}
|
||||
|
||||
func loadTransferable<T: Transferable>(type transferableType: T.Type) async -> T? {
|
||||
try? await withCheckedContinuation { continuation in
|
||||
_ = loadTransferable(type: T.self) { result in
|
||||
continuation.resume(returning: result)
|
||||
}
|
||||
}
|
||||
.get()
|
||||
}
|
||||
|
||||
func loadString() async -> String? {
|
||||
try? await loadItem(forTypeIdentifier: UTType.text.identifier) as? String
|
||||
}
|
||||
|
||||
func storeData() async -> URL? {
|
||||
guard let contentType = preferredContentType else {
|
||||
MXLog.error("Invalid NSItemProvider: \(self)")
|
||||
|
||||
Reference in New Issue
Block a user