Update alert UI and button changes

This commit is contained in:
Hariharan Mudaliar 2025-12-25 00:24:49 +05:30
commit 24009f7b81
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
7 changed files with 96 additions and 9 deletions

View file

@ -351,6 +351,8 @@ struct NotchClipboardList: View {
@State private var justCopiedId: UUID?
@State private var suppressionToken = UUID()
@State private var isSuppressing = false
@State private var showClearHistoryAlert = false
@State private var autoCloseToken = UUID()
var body: some View {
VStack(spacing: 0) {
@ -363,10 +365,10 @@ struct NotchClipboardList: View {
Spacer()
if !clipboardManager.clipboardHistory.isEmpty {
Button(action: { clipboardManager.clearHistory() }) {
Button(action: { showClearHistoryAlert = true }) {
Image(systemName: "trash")
.font(.system(size: 14))
.foregroundStyle(.white.opacity(0.6))
.foregroundStyle(.red)
.padding(6)
.background(Color.white.opacity(0.1))
.clipShape(Circle())
@ -432,6 +434,17 @@ struct NotchClipboardList: View {
.onDisappear {
updateSuppression(for: false)
}
.alert("Clear Clipboard History?", isPresented: $showClearHistoryAlert) {
Button("Clear History", role: .destructive) {
clipboardManager.clearHistory()
}
Button("Cancel", role: .cancel) {}
} message: {
Text("This removes every saved clipboard item from the notch tab.")
}
.onChange(of: showClearHistoryAlert) { _, isShowing in
vm.setAutoCloseSuppression(isShowing, token: autoCloseToken)
}
}
private func updateSuppression(for hovering: Bool) {
@ -513,6 +526,8 @@ struct NoteListView: View {
@State private var isSearchExpanded = false
@State private var suppressionToken = UUID()
@State private var isSuppressing = false
@State private var showClearNotesAlert = false
@State private var autoCloseToken = UUID()
var sortedNotes: [NoteItem] {
var filtered = searchText.isEmpty ? notes : notes.filter {
@ -575,11 +590,11 @@ struct NoteListView: View {
}
if !notes.isEmpty {
Button(action: onClearAll) {
Button(action: { showClearNotesAlert = true }) {
Image(systemName: "trash")
.font(.system(size: 14))
.frame(width: 16, height: 16)
.foregroundStyle(.white.opacity(0.6))
.foregroundStyle(.red)
.padding(5)
.background(Color.white.opacity(0.1))
.clipShape(Circle())
@ -710,6 +725,17 @@ struct NoteListView: View {
.onDisappear {
updateSuppression(for: false)
}
.alert("Delete All Notes?", isPresented: $showClearNotesAlert) {
Button("Delete", role: .destructive) {
onClearAll()
}
Button("Cancel", role: .cancel) {}
} message: {
Text("This permanently removes every saved note and its attachments.")
}
.onChange(of: showClearNotesAlert) { _, isShowing in
vm.setAutoCloseSuppression(isShowing, token: autoCloseToken)
}
}
private func updateSuppression(for hovering: Bool) {