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 RuleProvidersRowView: View {
@ObservedObject var providerStorage: DBProviderStorage
@EnvironmentObject var searchString: ProxiesSearchString
@State private var isUpdating = false
var providers: [DBRuleProvider] {
if searchString.string.isEmpty {
return providerStorage.ruleProviders
} else {
return providerStorage.ruleProviders.filter {
$0.name.lowercased().contains(searchString.string.lowercased())
}
}
}
var body: some View {
NavigationLink {
contentView
@@ -26,7 +37,7 @@ struct RuleProvidersRowView: View {
ScrollView {
Section {
VStack(spacing: 12) {
ForEach(providerStorage.ruleProviders, id: \.id) {
ForEach(providers, id: \.id) {
RuleProviderView(provider: $0)
}
}