//
//  NSItemProvider+Extensions.swift
//  RNShareMenu
//
//  Created by Gustavo Parreira on 29/07/2020.
//

import MobileCoreServices
import UniformTypeIdentifiers

public extension NSItemProvider {
    
    var isFileURL: Bool {
        if #available(iOS 15.0, *) {
            return hasItemConformingToTypeIdentifier(UTType.fileURL.identifier)
        }
        return hasItemConformingToTypeIdentifier(kUTTypeFileURL as String)
    }
    
    var isText: Bool {
        if #available(iOS 15.0, *) {
            return hasItemConformingToTypeIdentifier(UTType.text.identifier)
        }
        return hasItemConformingToTypeIdentifier(kUTTypeText as String)
    }

    var isURL: Bool {
        if #available(iOS 15.0, *) {
            return hasItemConformingToTypeIdentifier(UTType.url.identifier)
        }
        return hasItemConformingToTypeIdentifier(kUTTypeURL as String) && !isFileURL
    }
}
