Function bodies 10 total
AppDelegate class · swift · L4-L83 (80 LOC)NotchSoGood/App/AppDelegate.swift
class AppDelegate: NSObject, NSApplicationDelegate {
let updaterController: SPUStandardUpdaterController
private let demoController = DemoWindowController()
override init() {
updaterController = SPUStandardUpdaterController(
startingUpdater: true,
updaterDelegate: nil,
userDriverDelegate: nil
)
super.init()
}
func applicationDidFinishLaunching(_ notification: Notification) {}
func application(_ application: NSApplication, open urls: [URL]) {
// Capture the previously active app BEFORE processing URLs,
// so we can give focus back — URL scheme delivery activates our app.
let previousApp = NSWorkspace.shared.frontmostApplication
for url in urls {
guard url.scheme == "notchsogood" else { continue }
handleNotchURL(url)
}
// Immediately yield focus back to whatever the user was using
if let previousApp,
previousApNotificationManager class · swift · L4-L257 (254 LOC)NotchSoGood/App/NotificationManager.swift
class NotificationManager: ObservableObject {
static let shared = NotificationManager()
@Published var soundEnabled: Bool {
didSet {
UserDefaults.standard.set(soundEnabled, forKey: "soundEnabled")
SoundManager.shared.isEnabled = soundEnabled
}
}
@Published var showOnComplete: Bool {
didSet { UserDefaults.standard.set(showOnComplete, forKey: "showOnComplete") }
}
@Published var showOnQuestion: Bool {
didSet { UserDefaults.standard.set(showOnQuestion, forKey: "showOnQuestion") }
}
@Published var showOnPermission: Bool {
didSet { UserDefaults.standard.set(showOnPermission, forKey: "showOnPermission") }
}
@Published var showSessionPill: Bool {
didSet {
UserDefaults.standard.set(showSessionPill, forKey: "showSessionPill")
if !showSessionPill {
windowController.hideSessionPill()
} else if hasActiveSession {
refresSoundManager class · swift · L4-L39 (36 LOC)NotchSoGood/Audio/SoundManager.swift
class SoundManager {
static let shared = SoundManager()
var isEnabled = true
private init() {}
func play(for type: NotificationType) {
guard isEnabled else { return }
let soundName = type.soundName
// Try system sounds first
if let soundURL = findSystemSound(named: soundName) {
NSSound(contentsOf: soundURL, byReference: true)?.play()
return
}
// Fallback: use NSSound by name
NSSound(named: NSSound.Name(soundName))?.play()
}
private func findSystemSound(named name: String) -> URL? {
let systemSoundsPath = "/System/Library/Sounds"
let extensions = ["aiff", "caf", "wav"]
for ext in extensions {
let url = URL(fileURLWithPath: systemSoundsPath)
.appendingPathComponent(name)
.appendingPathExtension(ext)
if FileManager.default.fileExists(atPath: url.path) {
return url
}
DemoWindowController class · swift · L586-L636 (51 LOC)NotchSoGood/Views/DemoView.swift
class DemoWindowController {
private var window: NSWindow?
private var retainedWindow: NSWindow? // prevent premature dealloc
func open(animation: String? = nil) {
if let old = window {
// Remove SwiftUI content first so onDisappear fires and timers cancel.
old.contentView = nil
// Order out instead of close to avoid dealloc during animation flush.
old.orderOut(nil)
// Hold a reference briefly so AppKit can finish draining animations.
retainedWindow = old
DispatchQueue.main.async { [weak self] in
self?.retainedWindow = nil
}
window = nil
}
let view: AnyView
let size: NSSize
if let animation {
view = AnyView(AnimationPreviewView(animationName: animation))
size = NSSize(width: 300, height: 300)
} else {
view = AnyView(DemoView())
size = NSSize(width: 800, TransparentHostingView class · swift · L5-L21 (17 LOC)NotchSoGood/Windows/NotchPanel.swift
class TransparentHostingView: NSHostingView<AnyView> {
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
// Remove the default opaque background NSHostingView draws
guard let layer = self.layer else { return }
layer.backgroundColor = .clear
}
override var isOpaque: Bool { false }
override func draw(_ dirtyRect: NSRect) {
// Don't draw any background
NSColor.clear.setFill()
dirtyRect.fill()
super.draw(dirtyRect)
}
}NotchPanel class · swift · L23-L58 (36 LOC)NotchSoGood/Windows/NotchPanel.swift
class NotchPanel: NSPanel {
var onCancel: (() -> Void)?
init(contentRect: NSRect) {
super.init(
contentRect: contentRect,
styleMask: [.nonactivatingPanel, .fullSizeContentView, .borderless],
backing: .buffered,
defer: false
)
isFloatingPanel = true
level = .statusBar + 1
collectionBehavior = [.stationary, .canJoinAllSpaces, .fullScreenAuxiliary, .ignoresCycle]
isOpaque = false
backgroundColor = .clear
hasShadow = false
titleVisibility = .hidden
titlebarAppearsTransparent = true
isMovableByWindowBackground = false
hidesOnDeactivate = false
animationBehavior = .none
ignoresMouseEvents = true
}
override var canBecomeKey: Bool { false }
override var canBecomeMain: Bool { false }
override func cancelOperation(_ sender: Any?) {
if let onCancel {
onCancel()
} else {
orPillHoverMonitor class · swift · L62-L117 (56 LOC)NotchSoGood/Windows/NotchPanel.swift
class PillHoverMonitor: ObservableObject {
@Published var isHovered = false
/// Mouse position in screen coordinates, updated at 30fps for eye tracking.
@Published var mouseScreenPosition: NSPoint = .zero
private var timer: Timer?
private weak var panel: NotchPanel?
/// Collapsed pill rect in screen coordinates — used to detect hover-in.
var collapsedScreenRect: NSRect = .zero
/// Expanded pill rect in screen coordinates — used to detect hover-out (prevents flicker).
var expandedScreenRect: NSRect = .zero
func start(panel: NotchPanel) {
stop()
self.panel = panel
panel.ignoresMouseEvents = true
// Use Timer + RunLoop.main .common mode directly (not scheduledTimer, which would double-add)
let t = Timer(timeInterval: 1.0 / 30.0, repeats: true) { [weak self] _ in
self?.update()
}
RunLoop.main.add(t, forMode: .common)
timer = t
}
func stop() {
timer?.invalRepobility · code-quality intelligence platform · https://repobility.com
NotificationHoverMonitor class · swift · L121-L154 (34 LOC)NotchSoGood/Windows/NotchPanel.swift
class NotificationHoverMonitor {
private var timer: Timer?
private weak var panel: NotchPanel?
/// The visible notification rect in screen coordinates.
var contentScreenRect: NSRect = .zero
func start(panel: NotchPanel) {
stop()
self.panel = panel
panel.ignoresMouseEvents = true
let t = Timer(timeInterval: 1.0 / 30.0, repeats: true) { [weak self] _ in
self?.update()
}
RunLoop.main.add(t, forMode: .common)
timer = t
}
func stop() {
timer?.invalidate()
timer = nil
panel?.ignoresMouseEvents = true
}
private func update() {
guard let panel else { return }
let mouse = NSEvent.mouseLocation
let inside = contentScreenRect.insetBy(dx: -4, dy: -4).contains(mouse)
panel.ignoresMouseEvents = !inside
}
deinit { stop() }
}PillDataSource class · swift · L5-L8 (4 LOC)NotchSoGood/Windows/NotchWindowController.swift
class PillDataSource: ObservableObject {
@Published var sessions: [NotificationManager.SessionInfo] = []
@Published var primaryStartTime: Date = Date()
}NotchWindowController class · swift · L10-L239 (230 LOC)NotchSoGood/Windows/NotchWindowController.swift
class NotchWindowController {
private var panel: NotchPanel?
private var pillPanel: NotchPanel?
private var dismissTimer: Timer?
private var isDismissing = false
private var hasPillSession = false
private let pillHoverMonitor = PillHoverMonitor()
private let notifHoverMonitor = NotificationHoverMonitor()
private let pillDataSource = PillDataSource()
// Pill sizing constants (must match SessionPillView)
private let wingExpanded: CGFloat = 110
private let wingCollapsed: CGFloat = 56
private let maxDropHeight: CGFloat = 160
// MARK: - Session Pill
func showSessionPill(sessions: [NotificationManager.SessionInfo], primaryStartTime: Date) {
hasPillSession = true
let hasNotch = NotchGeometry.hasNotch
let geo = NotchGeometry.calculate()
let notchW = geo?.notchWidth ?? 185
let notchH = geo?.notchHeight ?? 32
// Panel stays at max size for smooth SwiftUI animations
// Must match