summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-02-28 03:27:29 -0800
committerFuwn <[email protected]>2025-02-28 03:27:29 -0800
commite127a2bc40316f5a44bb0e817c483a186d42b683 (patch)
tree74953972e30577fb2422c0143a49660bc3fb1783 /Sora/Views/Post/Grid/PostGridSearchHistoryView.swift
parentfeat: Development commit (diff)
downloadsora-testing-e127a2bc40316f5a44bb0e817c483a186d42b683.tar.xz
sora-testing-e127a2bc40316f5a44bb0e817c483a186d42b683.zip
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridSearchHistoryView.swift')
-rw-r--r--Sora/Views/Post/Grid/PostGridSearchHistoryView.swift73
1 files changed, 0 insertions, 73 deletions
diff --git a/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift b/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift
deleted file mode 100644
index be2d2ea..0000000
--- a/Sora/Views/Post/Grid/PostGridSearchHistoryView.swift
+++ /dev/null
@@ -1,73 +0,0 @@
-import SwiftUI
-
-struct PostGridSearchHistoryView: View {
- @EnvironmentObject private var manager: BooruManager
- @EnvironmentObject private var settings: SettingsManager
- @State private var searchText: String = ""
- @Binding var selectedTab: Int
-
- var filteredHistory: [BooruSearchQuery] {
- guard !searchText.isEmpty else {
- return settings.searchHistory
- }
-
- return settings.searchHistory
- .filter { query in
- query.tags
- .joined(separator: " ")
- .lowercased()
- .contains(searchText.lowercased())
- }
- }
-
- var body: some View {
- NavigationStack {
- VStack {
- if settings.searchHistory.isEmpty {
- ContentUnavailableView(
- "No History",
- systemImage: "magnifyingglass",
- description: Text("Recent searches will appear here.")
- )
- } else {
- List {
- if filteredHistory.isEmpty, !searchText.isEmpty {
- Text("No matching history found")
- }
-
- ForEach(filteredHistory, id: \.id) { query in
- Button(action: {
- let previousProvider = settings.preferredBooru
-
- settings.preferredBooru = query.provider
- manager.searchText = query.tags.joined(separator: " ")
- selectedTab = 0
-
- if previousProvider == settings.preferredBooru {
- manager.performSearch()
- }
- }) {
- PostGridSearchHistoryItemView(query: query)
- }
- #if os(macOS)
- .buttonStyle(.plain)
- #endif
- }
- .onDelete(perform: settings.removeSearchHistoryEntry)
- }
- #if os(macOS)
- .listStyle(.plain)
- #endif
- }
- }
- }
- .navigationTitle("Search History")
- .searchable(text: $searchText)
- }
-}
-
-#Preview {
- PostGridSearchHistoryView(selectedTab: .constant(0))
- .environmentObject(SettingsManager())
- .environmentObject(BooruManager(.safebooru))
-}