mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-05-24 03:08:05 +00:00
31 lines
811 B
Swift
31 lines
811 B
Swift
import UIKit
|
|
import Foundation
|
|
|
|
@MainActor
|
|
enum StatusEditorUTTypeSupported: String, CaseIterable {
|
|
case url = "public.url"
|
|
case text = "public.text"
|
|
case image = "public.image"
|
|
case jpeg = "public.jpeg"
|
|
case png = "public.png"
|
|
|
|
func loadItemContent(item: NSItemProvider) async throws -> Any? {
|
|
let result = try await item.loadItem(forTypeIdentifier: rawValue)
|
|
if self == .jpeg || self == .png,
|
|
let imageURL = result as? URL,
|
|
let data = try? Data(contentsOf: imageURL),
|
|
let image = UIImage(data: data) {
|
|
return image
|
|
}
|
|
if let url = result as? URL {
|
|
return url.absoluteString
|
|
} else if let text = result as? String {
|
|
return text
|
|
} else if let image = result as? UIImage {
|
|
return image
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
}
|