Clipboard Floating Panel

This commit is contained in:
Hariharan Mudaliar 2025-08-12 23:38:10 +05:30
commit e583069870
12 changed files with 549 additions and 226 deletions

View file

@ -0,0 +1,55 @@
//
// ClipboardPanelManager.swift
// DynamicIsland
//
// Created by GitHub Copilot on 12/08/25.
//
import AppKit
import SwiftUI
class ClipboardPanelManager: ObservableObject {
static let shared = ClipboardPanelManager()
private var clipboardPanel: ClipboardPanel?
private init() {}
func showClipboardPanel() {
hideClipboardPanel() // Close any existing panel
let panel = ClipboardPanel()
panel.positionNearNotch()
self.clipboardPanel = panel
// Make the panel key and order front to ensure it can receive focus
panel.makeKeyAndOrderFront(nil)
panel.orderFrontRegardless()
// Activate the app to ensure proper focus handling
NSApp.activate(ignoringOtherApps: true)
// Ensure the panel becomes the key window for text input
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
panel.makeKey()
}
}
func hideClipboardPanel() {
clipboardPanel?.close()
clipboardPanel = nil
}
func toggleClipboardPanel() {
if let panel = clipboardPanel, panel.isVisible {
hideClipboardPanel()
} else {
showClipboardPanel()
}
}
var isPanelVisible: Bool {
return clipboardPanel?.isVisible ?? false
}
}