summaryrefslogtreecommitdiff
path: root/Sora/Views/BookmarksView.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-03-02 06:11:03 -0800
committerFuwn <[email protected]>2025-03-02 06:11:03 -0800
commitaeb074b5f308172ba50ac9ae0f5ac6e3159cacb7 (patch)
tree59502ad26db905dbf4c1003b6ec2c3b1e961ac0d /Sora/Views/BookmarksView.swift
parentfeat: Development commit (diff)
downloadsora-testing-aeb074b5f308172ba50ac9ae0f5ac6e3159cacb7.tar.xz
sora-testing-aeb074b5f308172ba50ac9ae0f5ac6e3159cacb7.zip
feat: Development commit
Diffstat (limited to 'Sora/Views/BookmarksView.swift')
-rw-r--r--Sora/Views/BookmarksView.swift90
1 files changed, 14 insertions, 76 deletions
diff --git a/Sora/Views/BookmarksView.swift b/Sora/Views/BookmarksView.swift
index ccef3f1..fa7734e 100644
--- a/Sora/Views/BookmarksView.swift
+++ b/Sora/Views/BookmarksView.swift
@@ -2,85 +2,23 @@ import SwiftUI
struct BookmarksView: View {
@EnvironmentObject var settings: SettingsManager
- @EnvironmentObject var manager: BooruManager
@Binding var selectedTab: Int
- @State private var bookmarksSearchText: String = ""
- @State private var isShowingRemoveAllConfirmation = false
-
- var filteredBookmarks: [SettingsBookmark] {
- guard !bookmarksSearchText.isEmpty else {
- return settings.bookmarks
- }
-
- return settings.bookmarks
- .filter { bookmark in
- bookmark.tags.joined(separator: " ").lowercased().contains(bookmarksSearchText.lowercased())
- }
- }
var body: some View {
- NavigationStack {
- VStack {
- if settings.bookmarks.isEmpty {
- ContentUnavailableView(
- "No Bookmarks",
- systemImage: "bookmark",
- description: Text("Tap the bookmark button on a search page to add a bookmark.")
- )
- } else {
- List {
- if filteredBookmarks.isEmpty, !bookmarksSearchText.isEmpty {
- Text("No bookmarks match your search")
- }
-
- ForEach(
- filteredBookmarks.sorted { $0.date > $1.date },
- id: \.self
- ) { bookmark in
- Button(action: {
- let previousProvider = settings.preferredBooru
-
- settings.preferredBooru = bookmark.provider
- manager.searchText = bookmark.tags.joined(separator: " ")
- selectedTab = 0
-
- if previousProvider == settings.preferredBooru {
- manager.performSearch(settings: settings)
- }
- }) {
- GenericItemView(
- item: bookmark,
- removeAction: settings.removeBookmark
- )
- }
- #if os(macOS)
- .buttonStyle(.plain)
- #endif
- }
- .onDelete(perform: settings.removeBookmark)
- }
- }
- }
- }
- .navigationTitle("Bookmarks")
- .searchable(text: $bookmarksSearchText)
- .toolbar {
- ToolbarItem {
- Button(action: {
- isShowingRemoveAllConfirmation = true
- }) {
- Label("Remove All Bookmarks", systemImage: "trash")
- }
- }
- }
- .confirmationDialog(
- "Are you sure you want to remove all bookmarks? This action cannot be undone.",
- isPresented: $isShowingRemoveAllConfirmation
- ) {
- Button("Remove All Bookmarks") {
- settings.bookmarks.removeAll()
- }
- }
+ GenericListView(
+ selectedTab: $selectedTab,
+ isPresented: .constant(false),
+ title: "Bookmarks",
+ emptyMessage: "No Bookmarks",
+ emptyIcon: "bookmark",
+ emptyDescription: "Tap the bookmark button on a search page to add a bookmark.",
+ removeAllMessage:
+ "Are you sure you want to remove all bookmarks? This action cannot be undone.",
+ removeAllButtonText: "Remove All Bookmarks",
+ items: settings.bookmarks,
+ removeAction: settings.removeBookmark,
+ removeActionUUID: settings.removeBookmark
+ ) { settings.bookmarks.removeAll() }
}
}