1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 14:20:32 +05:30

Search improvements

This commit is contained in:
Arkadiusz Fal 2022-12-11 14:28:16 +01:00
parent e3daa738ce
commit 784fc8cfc6
3 changed files with 10 additions and 18 deletions

View File

@ -30,16 +30,10 @@ struct SearchSuggestions: View {
HStack {
Image(systemName: "magnifyingglass")
HStack(spacing: 0) {
if suggestion.hasPrefix(state.suggestionsText.lowercased()) {
Text(state.suggestionsText.lowercased())
.lineLimit(1)
.layoutPriority(2)
.foregroundColor(.secondary)
}
Text(querySuffix(suggestion))
Text(suggestion)
.lineLimit(1)
.layoutPriority(1)
.truncationMode(.head)
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
@ -90,10 +84,6 @@ struct SearchSuggestions: View {
}
}
private func querySuffix(_ suggestion: String) -> String {
suggestion.replacingFirstOccurrence(of: state.suggestionsText.lowercased(), with: "")
}
#if os(macOS)
private func onHover(_ inside: Bool) {
if inside {

View File

@ -33,8 +33,8 @@ struct SearchTextField: View {
.textFieldStyle(.plain)
#else
.textFieldStyle(.roundedBorder)
.padding(.leading, 5)
.padding(.trailing, 10)
.padding(.horizontal, 5)
.padding(.trailing, state.queryText.isEmpty ? 0 : 10)
#endif
if !state.queryText.isEmpty {

View File

@ -210,9 +210,11 @@ struct SearchView: View {
Section {
FavoriteButton(item: favoriteItem)
}
} label: {
HStack {
Image(systemName: "magnifyingglass")
Image(systemName: "chevron.down.circle.fill")
}
.foregroundColor(.accentColor)
.imageScale(.medium)
}