feat: search support

This commit is contained in:
mrFq1
2023-05-18 15:20:27 +08:00
parent e23239ecd9
commit 088fc47329
5 changed files with 52 additions and 25 deletions
@@ -9,9 +9,20 @@ import SwiftUI
struct ProxyProvidersRowView: View {
@ObservedObject var providerStorage: DBProviderStorage
@EnvironmentObject var searchString: ProxiesSearchString
@State private var isUpdating = false
var providers: [DBProxyProvider] {
if searchString.string.isEmpty {
return providerStorage.proxyProviders
} else {
return providerStorage.proxyProviders.filter {
$0.name.lowercased().contains(searchString.string.lowercased())
}
}
}
var body: some View {
NavigationLink {
contentView
@@ -53,7 +64,7 @@ struct ProxyProvidersRowView: View {
}
var listView: some View {
ForEach(providerStorage.proxyProviders, id: \.id) {
ForEach(providers, id: \.id) {
ProxyProviderInfoView(provider: $0)
}
}