From 3709628a936316c66f57a57fa7ee9f7d9bfb9752 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 11 Oct 2022 14:57:09 +0800 Subject: [PATCH] Update the advanced search suggestions + typeahead when selected --- .../App/Views/Home/LibrarySearchView.swift | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/LibrarySearchView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/LibrarySearchView.swift index 2fe81163c..6369f9ac4 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/LibrarySearchView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/LibrarySearchView.swift @@ -21,12 +21,15 @@ struct LibrarySearchView: View { } func performTypeahead(_ searchTerm: String) { - Task { await viewModel.search(dataService: self.dataService, searchTerm: searchTerm) } + Task { + await viewModel.search(dataService: self.dataService, searchTerm: searchTerm) + } } func setSearchTerm(_ searchTerm: String) { viewModel.searchTerm = searchTerm searchBar?.becomeFirstResponder() + performTypeahead(searchTerm) } func performSearch(_ searchTerm: String) { @@ -116,23 +119,26 @@ struct LibrarySearchView: View { VStack { List { if viewModel.searchTerm.count == 0 { - Section("Recent Searches") { - ForEach(recents, id: \.self) { term in - recentSearchRow(term) + if recents.count > 0 { + Section("Recent Searches") { + ForEach(recents, id: \.self) { term in + recentSearchRow(term) + } } } + Section("Narrow with advanced search") { - (Text("**site:** ") + Text("site or domain (eg omnivore.app)")) + (Text("**in:** ") + Text("filter to inbox, archive, or all")) + .foregroundColor(.appGrayText) + .onTapGesture { setSearchTerm("is:") } + + (Text("**title:** ") + Text("search for a specific title")) .foregroundColor(.appGrayText) .onTapGesture { setSearchTerm("site:") } - (Text("**author:** ") + Text("author name")) + (Text("**has:highlights** ") + Text("any saved read with highlights")) .foregroundColor(.appGrayText) - .onTapGesture { setSearchTerm("author:") } - - (Text("**is:** ") + Text("read or unread")) - .foregroundColor(.appGrayText) - .onTapGesture { setSearchTerm("is:") } + .onTapGesture { setSearchTerm("has:highlights") } Button(action: {}, label: { Text("[More on Advanced Search](https://omnivore.app/help/search)")