mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Clipboard Floating Panel
This commit is contained in:
parent
e29745f8f4
commit
e583069870
12 changed files with 549 additions and 226 deletions
|
|
@ -15,7 +15,6 @@ struct DynamicIslandHeader: View {
|
|||
@ObservedObject var coordinator = DynamicIslandViewCoordinator.shared
|
||||
@ObservedObject var clipboardManager = ClipboardManager.shared
|
||||
@StateObject var tvm = TrayDrop.shared
|
||||
@State private var showClipboardPopover = false
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
|
|
@ -63,25 +62,8 @@ struct DynamicIslandHeader: View {
|
|||
|
||||
if Defaults[.enableClipboardManager] && Defaults[.showClipboardIcon] {
|
||||
Button(action: {
|
||||
// Use the same smart logic as the keyboard shortcut
|
||||
let displayMode = Defaults[.clipboardDisplayMode]
|
||||
let shouldUseWindow: Bool
|
||||
|
||||
switch displayMode {
|
||||
case .window:
|
||||
shouldUseWindow = true
|
||||
case .popover:
|
||||
shouldUseWindow = false
|
||||
case .auto:
|
||||
// For header button clicks, prefer popover since user is already interacting with notch
|
||||
shouldUseWindow = false
|
||||
}
|
||||
|
||||
if shouldUseWindow {
|
||||
ClipboardWindowManager.shared.toggleClipboardWindow()
|
||||
} else {
|
||||
showClipboardPopover.toggle()
|
||||
}
|
||||
// Always use panel mode
|
||||
ClipboardPanelManager.shared.toggleClipboardPanel()
|
||||
}) {
|
||||
Capsule()
|
||||
.fill(.black)
|
||||
|
|
@ -94,18 +76,6 @@ struct DynamicIslandHeader: View {
|
|||
}
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.popover(isPresented: $showClipboardPopover, arrowEdge: .bottom) {
|
||||
ClipboardHistoryPopover(isPresented: $showClipboardPopover)
|
||||
.onAppear {
|
||||
vm.isClipboardPopoverActive = true
|
||||
}
|
||||
.onDisappear {
|
||||
vm.isClipboardPopoverActive = false
|
||||
}
|
||||
}
|
||||
.onChange(of: showClipboardPopover) { isOpen in
|
||||
vm.isClipboardPopoverActive = isOpen
|
||||
}
|
||||
.onAppear {
|
||||
if Defaults[.enableClipboardManager] && !clipboardManager.isMonitoring {
|
||||
clipboardManager.startMonitoring()
|
||||
|
|
@ -155,7 +125,7 @@ struct DynamicIslandHeader: View {
|
|||
.onChange(of: coordinator.shouldToggleClipboardPopover) { _ in
|
||||
// Only toggle if clipboard is enabled
|
||||
if Defaults[.enableClipboardManager] {
|
||||
showClipboardPopover.toggle()
|
||||
ClipboardPanelManager.shared.toggleClipboardPanel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ class DynamicIslandWindow: NSPanel {
|
|||
}
|
||||
|
||||
override var canBecomeKey: Bool {
|
||||
false
|
||||
true
|
||||
}
|
||||
|
||||
override var canBecomeMain: Bool {
|
||||
false
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue