Add confirmation alert when clearing all bookmarks

Changelog-Added: Add confirmation alert when clearing all bookmarks
Closes: #1016
This commit is contained in:
Swift
2023-04-25 22:20:19 -04:00
committed by William Casarin
parent e89c025d9d
commit 1394122542

View File

@@ -11,6 +11,7 @@ struct BookmarksView: View {
let state: DamusState let state: DamusState
private let noneFilter: (NostrEvent) -> Bool = { _ in true } private let noneFilter: (NostrEvent) -> Bool = { _ in true }
private let bookmarksTitle = NSLocalizedString("Bookmarks", comment: "Title of bookmarks view") private let bookmarksTitle = NSLocalizedString("Bookmarks", comment: "Title of bookmarks view")
@State private var clearAllAlert: Bool = false
@ObservedObject var manager: BookmarksManager @ObservedObject var manager: BookmarksManager
@@ -45,10 +46,17 @@ struct BookmarksView: View {
.toolbar { .toolbar {
if !bookmarks.isEmpty { if !bookmarks.isEmpty {
Button(NSLocalizedString("Clear All", comment: "Button for clearing bookmarks data.")) { 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()
}
}
} }
} }