ce55be4a-fb5f-4981-b507-0f4.../Sources/AirDropPlugin.swift
徐翔宇 c4080b5cb9 v1.0.0: initial AirDrop plugin for MioIsland
Quick-access AirDrop from the notch panel. Tap the card body, pick
files via NSOpenPanel, hand off to NSSharingService(.sendViaAirDrop).
No private APIs, no entitlements, no network — just a thin wrapper
around the same AirDrop API Finder uses.

Design constraint: drag-and-drop is intentionally not implemented.
MioIsland's notch panel auto-collapses on click-outside, which
breaks the Cmd-Tab-to-Finder / grab / drag-back workflow before
the drop target reaches. Tap-to-choose is rock solid by comparison.

Requires MioIsland host v2.2.0+ (panel size clamp floor was
lowered to 120pt in that release).
2026-04-22 08:20:47 +08:00

35 lines
901 B
Swift

//
// AirDropPlugin.swift
// MioIsland AirDrop Plugin
//
// Principal class. Module is `AirDropPlugin`, class is `AirDropPlugin`,
// so Info.plist NSPrincipalClass = "AirDropPlugin.AirDropPlugin".
//
// Wraps NSSharingService(.sendViaAirDrop) a public Apple API in a
// Mio Island panel. No private APIs, no entitlements, no network.
//
import AppKit
import SwiftUI
final class AirDropPlugin: NSObject, MioPlugin {
var id: String { "airdrop" }
var name: String { "AirDrop" }
var icon: String { "airplayaudio" }
var version: String { "1.0.0" }
func activate() {
NSLog("[mio-plugin-airdrop] activate")
}
func deactivate() {
NSLog("[mio-plugin-airdrop] deactivate")
}
func makeView() -> NSView {
let view = NSHostingView(rootView: ExpandedView())
view.autoresizingMask = [.width, .height]
return view
}
}