summaryrefslogtreecommitdiff
path: root/Sora/Views/Bookmarks/BookmarksView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sora/Views/Bookmarks/BookmarksView.swift')
-rw-r--r--Sora/Views/Bookmarks/BookmarksView.swift107
1 files changed, 55 insertions, 52 deletions
diff --git a/Sora/Views/Bookmarks/BookmarksView.swift b/Sora/Views/Bookmarks/BookmarksView.swift
index 83eda0e..b36ee45 100644
--- a/Sora/Views/Bookmarks/BookmarksView.swift
+++ b/Sora/Views/Bookmarks/BookmarksView.swift
@@ -1,69 +1,72 @@
import SwiftUI
struct BookmarksView: View {
- @EnvironmentObject var settings: Settings
- @EnvironmentObject var manager: BooruManager
- @Binding var selectedTab: Int
- @State private var bookmarksSearchText: String = ""
+ @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 filteredBookmarks: [Bookmark] {
+ guard !bookmarksSearchText.isEmpty else {
+ return settings.bookmarks
}
- var body: some View {
- NavigationStack {
- VStack {
- if settings.bookmarks.isEmpty {
- ContentUnavailableView("No Bookmarks",
- systemImage: "bookmark",
- description: Text("Add a bookmark by tapping the bookmark button on a search page."))
- } else {
- List {
- if filteredBookmarks.isEmpty, !bookmarksSearchText.isEmpty {
- Text("No bookmarks match your search")
- }
+ return settings.bookmarks
+ .filter {
+ $0.tags.joined(separator: " ").lowercased().contains(bookmarksSearchText.lowercased())
+ }
+ }
+
+ var body: some View {
+ NavigationStack {
+ VStack {
+ if settings.bookmarks.isEmpty {
+ ContentUnavailableView(
+ "No Bookmarks",
+ systemImage: "bookmark",
+ description: Text("Add a bookmark by tapping the bookmark button on a search page."))
+ } else {
+ List {
+ if filteredBookmarks.isEmpty, !bookmarksSearchText.isEmpty {
+ Text("No bookmarks match your search")
+ }
- ForEach(
- filteredBookmarks,
- id: \.self
- ) { bookmark in
- Button(action: {
- let previousProvider = settings.preferredBooru
+ ForEach(
+ filteredBookmarks,
+ id: \.self
+ ) { bookmark in
+ Button(action: {
+ let previousProvider = settings.preferredBooru
- settings.preferredBooru = bookmark.provider
- manager.searchText = bookmark.tags.joined(separator: " ")
- selectedTab = 0
+ settings.preferredBooru = bookmark.provider
+ manager.searchText = bookmark.tags.joined(separator: " ")
+ selectedTab = 0
- if previousProvider == settings.preferredBooru {
- manager.performSearch()
- }
- }) {
- BookmarkListItemView(bookmark: bookmark)
- }
- #if os(macOS)
- .buttonStyle(.plain)
- #endif
- }
- .onDelete(perform: settings.removeBookmark)
- }
- #if os(macOS)
- .listStyle(.plain)
- #endif
+ if previousProvider == settings.preferredBooru {
+ manager.performSearch()
}
+ }) {
+ BookmarkListItemView(bookmark: bookmark)
+ }
+ #if os(macOS)
+ .buttonStyle(.plain)
+ #endif
}
+ .onDelete(perform: settings.removeBookmark)
+ }
+ #if os(macOS)
+ .listStyle(.plain)
+ #endif
}
- .navigationTitle("Bookmarks")
- .searchable(text: $bookmarksSearchText)
+ }
}
+ .navigationTitle("Bookmarks")
+ .searchable(text: $bookmarksSearchText)
+ }
}
#Preview {
- BookmarksView(selectedTab: .constant(1))
- .environmentObject(Settings())
- .environmentObject(BooruManager(.yandere))
+ BookmarksView(selectedTab: .constant(1))
+ .environmentObject(Settings())
+ .environmentObject(BooruManager(.yandere))
}