Searching disables the filters (#2530)

This commit is contained in:
Mauro
2024-03-06 11:02:30 +01:00
committed by GitHub
parent 7f3451216d
commit 7754b9b8dc
18 changed files with 84 additions and 74 deletions
@@ -17,6 +17,8 @@
import SwiftUI
import SwiftUIIntrospect
// MARK: - Search Controller Extensions
extension View {
/// A custom replacement for searchable that allows more precise configuration of the underlying search controller.
///
@@ -169,3 +171,21 @@ private struct SearchController: UIViewControllerRepresentable {
}
}
}
// MARK: - Searchable Extensions
struct IsSearchingModifier: ViewModifier {
@Environment(\.isSearching) private var isSearchingEnv
@Binding var isSearching: Bool
func body(content: Content) -> some View {
content
.onChange(of: isSearchingEnv) { isSearching = $0 }
}
}
extension View {
func isSearching(_ isSearching: Binding<Bool>) -> some View {
modifier(IsSearchingModifier(isSearching: isSearching))
}
}