mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Search improvements
This commit is contained in:
parent
e3daa738ce
commit
784fc8cfc6
@ -30,16 +30,10 @@ struct SearchSuggestions: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "magnifyingglass")
|
Image(systemName: "magnifyingglass")
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
if suggestion.hasPrefix(state.suggestionsText.lowercased()) {
|
Text(suggestion)
|
||||||
Text(state.suggestionsText.lowercased())
|
|
||||||
.lineLimit(1)
|
|
||||||
.layoutPriority(2)
|
|
||||||
.foregroundColor(.secondary)
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(querySuffix(suggestion))
|
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.layoutPriority(1)
|
.layoutPriority(1)
|
||||||
|
.truncationMode(.head)
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||||
.contentShape(Rectangle())
|
.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)
|
#if os(macOS)
|
||||||
private func onHover(_ inside: Bool) {
|
private func onHover(_ inside: Bool) {
|
||||||
if inside {
|
if inside {
|
||||||
|
@ -33,8 +33,8 @@ struct SearchTextField: View {
|
|||||||
.textFieldStyle(.plain)
|
.textFieldStyle(.plain)
|
||||||
#else
|
#else
|
||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
.padding(.leading, 5)
|
.padding(.horizontal, 5)
|
||||||
.padding(.trailing, 10)
|
.padding(.trailing, state.queryText.isEmpty ? 0 : 10)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if !state.queryText.isEmpty {
|
if !state.queryText.isEmpty {
|
||||||
|
@ -210,9 +210,11 @@ struct SearchView: View {
|
|||||||
Section {
|
Section {
|
||||||
FavoriteButton(item: favoriteItem)
|
FavoriteButton(item: favoriteItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "magnifyingglass")
|
||||||
Image(systemName: "chevron.down.circle.fill")
|
Image(systemName: "chevron.down.circle.fill")
|
||||||
|
}
|
||||||
.foregroundColor(.accentColor)
|
.foregroundColor(.accentColor)
|
||||||
.imageScale(.medium)
|
.imageScale(.medium)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user