import AppKit import SwiftUI struct AccessibilityDragView: View { let bundleURL: URL let onDismiss: () -> Void @Environment(\.colorSchemeContrast) private var contrast var body: some View { HStack(spacing: 16) { Button(action: reveal) { Image(nsImage: NSWorkspace.shared.icon(forFile: bundleURL.path)) .resizable() .scaledToFit() .frame(width: 64, height: 64) } .buttonStyle(.plain) .onDrag { Self.itemProvider(bundleURL: bundleURL) } .accessibilityLabel(UIStrings.text("Drag Parcel into the Accessibility list")) .accessibilityHint( UIStrings.text("Drag the icon into the list above, or activate to reveal Parcel in Finder.") ) .accessibilityIdentifier("permissions.dragIcon") VStack(alignment: .leading, spacing: 8) { Text(UIStrings.text("↑ Drag Parcel into the list above")) .font(.headline) .fixedSize(horizontal: false, vertical: true) Button(UIStrings.text("Reveal Parcel in Finder"), action: reveal) .accessibilityIdentifier("permissions.reveal") } Spacer(minLength: 0) Button(UIStrings.text("Close"), systemImage: "xmark", action: onDismiss) .labelStyle(.iconOnly) .buttonStyle(.borderless) .accessibilityIdentifier("permissions.close") } .padding(16) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(nsColor: .windowBackgroundColor), in: RoundedRectangle(cornerRadius: 14)) .overlay { RoundedRectangle(cornerRadius: 14) .stroke( Color.primary.opacity(contrast == .increased ? 1 : 0.2), lineWidth: contrast == .increased ? 2 : 1 ) .allowsHitTesting(false) } .onExitCommand(perform: onDismiss) } static func itemProvider(bundleURL: URL) -> NSItemProvider { precondition(bundleURL.isFileURL) return NSItemProvider(object: bundleURL as NSURL) } private func reveal() { NSWorkspace.shared.activateFileViewerSelecting([bundleURL]) } }