mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 14:50:32 +05:30
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,11 +210,13 @@ struct SearchView: View {
|
|||||||
Section {
|
Section {
|
||||||
FavoriteButton(item: favoriteItem)
|
FavoriteButton(item: favoriteItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "chevron.down.circle.fill")
|
HStack {
|
||||||
.foregroundColor(.accentColor)
|
Image(systemName: "magnifyingglass")
|
||||||
.imageScale(.medium)
|
Image(systemName: "chevron.down.circle.fill")
|
||||||
|
}
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
.imageScale(.medium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user