diff options
| author | Christian Cleberg <[email protected]> | 2026-04-12 22:52:33 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-04-12 22:52:33 -0500 |
| commit | 72f860e0e171f6aac4e7d896e7a571147dbcb5c5 (patch) | |
| tree | c62c9c9325292f65e6f72372a38b35760cc937b1 /Hutch/Views/Tickets/TicketListView.swift | |
| parent | 576bb6c2432a15f5138771c06019b55fd2244e15 (diff) | |
| download | hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.tar.gz hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.tar.bz2 hutch-72f860e0e171f6aac4e7d896e7a571147dbcb5c5.zip | |
feat: add search and recent queries
Implements: https://todo.sr.ht/~ccleberg/hutch/47
Implements: https://todo.sr.ht/~ccleberg/hutch/48
Diffstat (limited to 'Hutch/Views/Tickets/TicketListView.swift')
| -rw-r--r-- | Hutch/Views/Tickets/TicketListView.swift | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Hutch/Views/Tickets/TicketListView.swift b/Hutch/Views/Tickets/TicketListView.swift index bd2236c..d2548d7 100644 --- a/Hutch/Views/Tickets/TicketListView.swift +++ b/Hutch/Views/Tickets/TicketListView.swift @@ -328,8 +328,25 @@ struct TicketListView: View { .searchable( text: $vm.searchText, placement: .navigationBarDrawer(displayMode: .always), - prompt: "Search tickets" + prompt: "Search tickets in \(tracker.name)" ) + .searchSuggestions { + if viewModel.searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { + RecentSearchSuggestions( + title: "Recent Ticket Searches", + entries: viewModel.recentSearches + ) { query in + vm.searchText = query + } onClear: { + viewModel.clearRecentSearches() + } + } + } + .onSubmit(of: .search) { + let query = viewModel.searchText.trimmingCharacters(in: .whitespacesAndNewlines) + guard !query.isEmpty else { return } + viewModel.recordRecentSearch(query) + } .overlay { if viewModel.isLoading, viewModel.tickets.isEmpty { SRHTLoadingStateView(message: "Loading tickets…") @@ -341,7 +358,11 @@ struct TicketListView: View { ) } else if !viewModel.searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, viewModel.filteredTickets.isEmpty { - ContentUnavailableView.search(text: viewModel.searchText) + ContentUnavailableView( + "No Ticket Matches", + systemImage: "magnifyingglass", + description: Text("No tickets in \(tracker.name) matched “\(viewModel.searchText)”.") + ) } else if viewModel.filteredTickets.isEmpty, viewModel.error == nil { ContentUnavailableView( "No Tickets", |
