@@ -24,6 +24,7 @@ struct SearchView: View {
2424 @State private var selectedSearchItem : SearchItem ?
2525 @State private var isSearching = false
2626 @State private var searchText = " "
27+ @State private var hasNoResults = false
2728
2829 private var selectedModule : ScrapingModule ? {
2930 guard let id = selectedModuleId else { return nil }
@@ -55,6 +56,19 @@ struct SearchView: View {
5556 if isSearching {
5657 ProgressView ( )
5758 . padding ( )
59+ } else if hasNoResults {
60+ VStack ( spacing: 8 ) {
61+ Image ( systemName: " magnifyingglass " )
62+ . font ( . largeTitle)
63+ . foregroundColor ( . secondary)
64+ Text ( " No Results Found " )
65+ . font ( . headline)
66+ Text ( " Try different keywords/titles " )
67+ . font ( . caption)
68+ . foregroundColor ( . secondary)
69+ }
70+ . padding ( )
71+ . frame ( maxWidth: . infinity)
5872 }
5973
6074 LazyVGrid ( columns: [ GridItem ( . adaptive( minimum: 150 ) ) ] , spacing: 16 ) {
@@ -128,22 +142,27 @@ struct SearchView: View {
128142 private func performSearch( ) {
129143 guard !searchText. isEmpty, let module = selectedModule else {
130144 searchItems = [ ]
145+ hasNoResults = false
131146 return
132147 }
133148
134149 isSearching = true
150+ hasNoResults = false
151+
135152 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.5 ) {
136153 Task {
137154 do {
138155 let jsContent = try moduleManager. getModuleContent ( module)
139156 jsController. loadScript ( jsContent)
140157 jsController. fetchSearchResults ( keyword: searchText, module: module) { items in
141158 searchItems = items
159+ hasNoResults = items. isEmpty
142160 isSearching = false
143161 }
144162 } catch {
145163 print ( " Error loading module: \( error) " )
146164 isSearching = false
165+ hasNoResults = true
147166 }
148167 }
149168 }
@@ -181,4 +200,4 @@ struct SearchBar: View {
181200 )
182201 }
183202 }
184- }
203+ }
0 commit comments