From 1394122542b5258da1ffc8d2b0164bf8dfa3fe44 Mon Sep 17 00:00:00 2001 From: Swift Date: Tue, 25 Apr 2023 22:20:19 -0400 Subject: [PATCH] Add confirmation alert when clearing all bookmarks Changelog-Added: Add confirmation alert when clearing all bookmarks Closes: #1016 --- damus/Views/BookmarksView.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/damus/Views/BookmarksView.swift b/damus/Views/BookmarksView.swift index 53b918df..553d95fb 100644 --- a/damus/Views/BookmarksView.swift +++ b/damus/Views/BookmarksView.swift @@ -11,6 +11,7 @@ struct BookmarksView: View { let state: DamusState private let noneFilter: (NostrEvent) -> Bool = { _ in true } private let bookmarksTitle = NSLocalizedString("Bookmarks", comment: "Title of bookmarks view") + @State private var clearAllAlert: Bool = false @ObservedObject var manager: BookmarksManager @@ -45,10 +46,17 @@ struct BookmarksView: View { .toolbar { if !bookmarks.isEmpty { Button(NSLocalizedString("Clear All", comment: "Button for clearing bookmarks data.")) { - manager.clearAll() + clearAllAlert = true } } } + .alert(NSLocalizedString("Are you sure you want to delete all of your bookmarks?", comment: "Alert for deleting all of the bookmarks."), isPresented: $clearAllAlert) { + Button(NSLocalizedString("Cancel", comment: "Cancel deleting bookmarks."), role: .cancel) { + } + Button(NSLocalizedString("Continue", comment: "Continue with bookmarks.")) { + manager.clearAll() + } + } } }