mirror of
https://github.com/yattee/yattee.git
synced 2025-04-28 07:50:33 +05:30
Improve search suggestions layout, add separate button for search/append
This commit is contained in:
parent
04df9551ba
commit
2a75d0a1d4
@ -7,12 +7,7 @@ struct SearchSuggestions: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
Button {
|
Button {
|
||||||
state.changeQuery { query in
|
runQueryAction()
|
||||||
query.query = state.queryText
|
|
||||||
state.fieldIsFocused = false
|
|
||||||
}
|
|
||||||
|
|
||||||
recents.addQuery(state.queryText)
|
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "magnifyingglass")
|
Image(systemName: "magnifyingglass")
|
||||||
@ -20,28 +15,45 @@ struct SearchSuggestions: View {
|
|||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding(.vertical, 5)
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onHover(perform: onHover(_:))
|
.onHover(perform: onHover(_:))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ForEach(visibleSuggestions, id: \.self) { suggestion in
|
ForEach(visibleSuggestions, id: \.self) { suggestion in
|
||||||
Button {
|
HStack {
|
||||||
state.queryText = suggestion
|
Button {
|
||||||
} label: {
|
state.queryText = suggestion
|
||||||
HStack {
|
runQueryAction()
|
||||||
Image(systemName: "arrow.up.left.circle")
|
} label: {
|
||||||
.foregroundColor(.secondary)
|
HStack {
|
||||||
HStack(spacing: 0) {
|
Image(systemName: "magnifyingglass")
|
||||||
Text(state.suggestionsText)
|
HStack(spacing: 0) {
|
||||||
.lineLimit(1)
|
Text(state.suggestionsText)
|
||||||
.layoutPriority(2)
|
.lineLimit(1)
|
||||||
.foregroundColor(.secondary)
|
.layoutPriority(2)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
|
||||||
Text(querySuffix(suggestion))
|
Text(querySuffix(suggestion))
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.layoutPriority(1)
|
.layoutPriority(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Button {
|
||||||
|
state.queryText = suggestion
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "arrow.up.left.circle")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.padding(.vertical, 5)
|
||||||
|
.buttonStyle(.plain)
|
||||||
}
|
}
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
.onHover(perform: onHover(_:))
|
.onHover(perform: onHover(_:))
|
||||||
@ -53,6 +65,15 @@ struct SearchSuggestions: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func runQueryAction() {
|
||||||
|
state.changeQuery { query in
|
||||||
|
query.query = state.queryText
|
||||||
|
state.fieldIsFocused = false
|
||||||
|
}
|
||||||
|
|
||||||
|
recents.addQuery(state.queryText)
|
||||||
|
}
|
||||||
|
|
||||||
private var visibleSuggestions: [String] {
|
private var visibleSuggestions: [String] {
|
||||||
state.querySuggestions.collection.filter {
|
state.querySuggestions.collection.filter {
|
||||||
$0.compare(state.queryText, options: .caseInsensitive) != .orderedSame
|
$0.compare(state.queryText, options: .caseInsensitive) != .orderedSame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user