diff options
Diffstat (limited to 'Sora/Views/BookmarksView.swift')
| -rw-r--r-- | Sora/Views/BookmarksView.swift | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/Sora/Views/BookmarksView.swift b/Sora/Views/BookmarksView.swift deleted file mode 100644 index 7c206ac..0000000 --- a/Sora/Views/BookmarksView.swift +++ /dev/null @@ -1,72 +0,0 @@ -import SwiftUI - -struct BookmarksView: View { - @EnvironmentObject var settings: Settings - @EnvironmentObject var manager: BooruManager - @Binding var selectedTab: Int - @State private var bookmarksSearchText: String = "" - - var filteredBookmarks: [Bookmark] { - guard !bookmarksSearchText.isEmpty else { - return settings.bookmarks - } - - return settings.bookmarks - .filter { $0.tags.joined(separator: " ").lowercased().contains(bookmarksSearchText.lowercased()) } - } - - var body: some View { - NavigationStack { - if settings.bookmarks.isEmpty { - VStack { - Spacer() - - Text("There are no bookmarks yet. Add a bookmark by tapping the bookmark button in the bottom left corner of a search page.") - .padding() - - Spacer() - } - } else { - List { - if filteredBookmarks.isEmpty { - Text("No bookmarks found.") - } - - ForEach(filteredBookmarks, 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() - } - }) { - let badgeView = Text(bookmark.provider.rawValue.capitalized) - - HStack { - Text(bookmark.tags.joined(separator: ", ")) - .foregroundStyle(.primary) - - Text(bookmark.createdAt.formatted()) - .foregroundColor(.secondary) - } - .badge(badgeView) - } - } - .onDelete(perform: settings.removeBookmark) - } - } - } - .navigationTitle("Bookmarks") - .searchable(text: $bookmarksSearchText) - } -} - -#Preview { - BookmarksView(selectedTab: .constant(1)) - .environmentObject(Settings()) - .environmentObject(BooruManager(.yandere)) -} |