BugFix: MouseOver and Add Feature: Clipboard settings

This commit is contained in:
Hariharan Mudaliar 2025-07-17 22:47:04 +05:30
commit 7137fcd255
7 changed files with 76 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import SwiftUI
struct ClipboardHistoryPopover: View {
@ObservedObject var clipboardManager = ClipboardManager.shared
@Binding var isPresented: Bool
@EnvironmentObject var vm: DynamicIslandViewModel
var body: some View {
VStack(alignment: .leading, spacing: 0) {
@ -56,6 +57,18 @@ struct ClipboardHistoryPopover: View {
.stroke(Color.gray.opacity(0.2), lineWidth: 1)
)
.shadow(color: .black.opacity(0.3), radius: 10, x: 0, y: 5)
.onHover { hovering in
// Close popover and notch when mouse exits
if !hovering {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
isPresented = false
// Also close the notch if no other popovers are active
if vm.notchState == .open && !vm.isBatteryPopoverActive {
vm.close()
}
}
}
}
}
@ViewBuilder

View file

@ -65,7 +65,7 @@ struct DynamicIslandHeader: View {
.buttonStyle(PlainButtonStyle())
}
if Defaults[.enableClipboardManager] {
if Defaults[.enableClipboardManager] && Defaults[.showClipboardIcon] {
Button(action: {
showClipboardPopover.toggle()
}) {
@ -138,6 +138,12 @@ struct DynamicIslandHeader: View {
}
.foregroundColor(.gray)
.environmentObject(vm)
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("ToggleClipboardPopover"))) { _ in
// Only toggle if clipboard is enabled
if Defaults[.enableClipboardManager] {
showClipboardPopover.toggle()
}
}
}
}