mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-29 08:04:32 +00:00
Restored files from old Mac, force pushing
This commit is contained in:
parent
5dd95228b8
commit
5040381840
126 changed files with 10431 additions and 67 deletions
40
DynamicIsland/components/Shelf/AirDrop.swift
Normal file
40
DynamicIsland/components/Shelf/AirDrop.swift
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// AirDrop.swift
|
||||
// NotchDrop
|
||||
//
|
||||
// Created by 秋星桥 on 2024/7/7.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AirDrop: NSObject, NSSharingServiceDelegate {
|
||||
let files: [URL]
|
||||
|
||||
init(files: [URL]) {
|
||||
self.files = files
|
||||
super.init()
|
||||
}
|
||||
|
||||
func begin() {
|
||||
do {
|
||||
try sendEx(files)
|
||||
} catch {
|
||||
NSAlert.popError(error)
|
||||
}
|
||||
}
|
||||
|
||||
private func sendEx(_ files: [URL]) throws {
|
||||
guard let service = NSSharingService(named: .sendViaAirDrop) else {
|
||||
throw NSError(domain: "AirDrop", code: 1, userInfo: [
|
||||
NSLocalizedDescriptionKey: NSLocalizedString("AirDrop service not available", comment: ""),
|
||||
])
|
||||
}
|
||||
guard service.canPerform(withItems: files) else {
|
||||
throw NSError(domain: "AirDrop", code: 2, userInfo: [
|
||||
NSLocalizedDescriptionKey: NSLocalizedString("AirDrop service not available", comment: ""),
|
||||
])
|
||||
}
|
||||
service.delegate = self
|
||||
service.perform(withItems: files)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue