Initial commit

This commit is contained in:
Alex E. Tafoya
2026-09-17 15:15:45 -05:00
commit 87fe7927c4
36 changed files with 5113 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
// Notifier.swift
// GreenshotMac
//
// Small wrapper around UserNotifications with a Finder-reveal fallback.
import AppKit
import UserNotifications
@MainActor
enum Notifier {
private static var authorizationRequested = false
private static var lastSavedURL: URL?
static func show(title: String, body: String?, revealing url: URL? = nil) {
lastSavedURL = url ?? lastSavedURL
let center = UNUserNotificationCenter.current()
if !authorizationRequested {
authorizationRequested = true
center.requestAuthorization(options: [.alert, .sound]) { _, _ in }
}
let content = UNMutableNotificationContent()
content.title = title
if let body { content.body = body }
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil)
center.add(request, withCompletionHandler: nil)
}
static var mostRecentSavedURL: URL? { lastSavedURL }
static func revealMostRecent() {
guard let url = lastSavedURL, FileManager.default.fileExists(atPath: url.path) else { return }
NSWorkspace.shared.activateFileViewerSelecting([url])
}
}