even more tests 😭

This commit is contained in:
Francesco 2025-05-31 18:00:35 +02:00
parent abbbdc00ee
commit 99d5e6f6cd
2 changed files with 61 additions and 60 deletions

View file

@ -72,6 +72,5 @@ struct SearchResultsGrid: View {
.padding(.top) .padding(.top)
.padding() .padding()
} }
.navigationViewStyle(StackNavigationViewStyle())
} }
} }

View file

@ -120,70 +120,72 @@ struct SearchContent: View {
let onClearHistory: () -> Void let onClearHistory: () -> Void
var body: some View { var body: some View {
VStack(spacing: 0) { NavigationView {
if selectedModule == nil { VStack(spacing: 0) {
VStack(spacing: 8) { if selectedModule == nil {
Image(systemName: "questionmark.app") VStack(spacing: 8) {
.font(.largeTitle) Image(systemName: "questionmark.app")
.foregroundColor(.secondary) .font(.largeTitle)
Text("No Module Selected") .foregroundColor(.secondary)
.font(.headline) Text("No Module Selected")
Text("Please select a module from settings") .font(.headline)
.font(.caption) Text("Please select a module from settings")
.foregroundColor(.secondary) .font(.caption)
.foregroundColor(.secondary)
}
.padding()
.frame(maxWidth: .infinity)
.background(Color(.systemBackground))
.shadow(color: Color.black.opacity(0.1), radius: 2, y: 1)
} }
.padding()
.frame(maxWidth: .infinity) if searchQuery.isEmpty {
.background(Color(.systemBackground)) if !searchHistory.isEmpty {
.shadow(color: Color.black.opacity(0.1), radius: 2, y: 1) SearchHistorySection(title: "Recent Searches") {
} VStack(spacing: 0) {
Divider()
if searchQuery.isEmpty { .padding(.horizontal, 16)
if !searchHistory.isEmpty {
SearchHistorySection(title: "Recent Searches") { ForEach(searchHistory.indices, id: \.self) { index in
VStack(spacing: 0) { SearchHistoryRow(
Divider() text: searchHistory[index],
.padding(.horizontal, 16) onTap: {
onHistoryItemSelected(searchHistory[index])
ForEach(searchHistory.indices, id: \.self) { index in },
SearchHistoryRow( onDelete: {
text: searchHistory[index], onHistoryItemDeleted(index)
onTap: { },
onHistoryItemSelected(searchHistory[index]) showDivider: index < searchHistory.count - 1
}, )
onDelete: { }
onHistoryItemDeleted(index) HStack {
}, Button(action: onClearHistory) {
showDivider: index < searchHistory.count - 1 Text("Clear")
) .foregroundColor(.accentColor)
} }
HStack { .frame(maxWidth: .infinity, alignment: .center)
Button(action: onClearHistory) {
Text("Clear")
.foregroundColor(.accentColor)
} }
.frame(maxWidth: .infinity, alignment: .center)
} }
} }
.padding(.vertical)
} }
.padding(.vertical) } else {
} if let module = selectedModule {
} else { if !searchItems.isEmpty {
if let module = selectedModule { SearchResultsGrid(
if !searchItems.isEmpty { items: searchItems,
SearchResultsGrid( columns: columns,
items: searchItems, selectedModule: module,
columns: columns, cellWidth: cellWidth
selectedModule: module, )
cellWidth: cellWidth } else {
) SearchStateView(
} else { isSearching: isSearching,
SearchStateView( hasNoResults: hasNoResults,
isSearching: isSearching, columnsCount: columnsCount,
hasNoResults: hasNoResults, cellWidth: cellWidth
columnsCount: columnsCount, )
cellWidth: cellWidth }
)
} }
} }
} }