From 320ce31337ed60cae24a0374fa2d6d79237a6bfe Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 18 Feb 2025 23:39:51 -0800 Subject: feat: Development commit --- Sora/Views/SearchSuggestionsView.swift | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Sora/Views/SearchSuggestionsView.swift (limited to 'Sora/Views/SearchSuggestionsView.swift') diff --git a/Sora/Views/SearchSuggestionsView.swift b/Sora/Views/SearchSuggestionsView.swift new file mode 100644 index 0000000..cae8d43 --- /dev/null +++ b/Sora/Views/SearchSuggestionsView.swift @@ -0,0 +1,21 @@ +import SwiftUI + +struct SearchSuggestionsView: View { + var tags: [MoebooruTag] + @Binding var searchText: String + var lastSearchTag: String { + String(searchText.split(separator: " ").last ?? "") + } + + var body: some View { + ForEach( + tags.filter { $0.name.lowercased().contains(lastSearchTag) + }) { suggestion in + Button { + searchText.replaceSubrange(searchText.range(of: lastSearchTag)!, with: suggestion.name) + } label: { + Text(suggestion.name) + } + } + } +} -- cgit v1.2.3