Nav apraksta

SearchContainer.swift 992B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // SearchContainer.swift
  3. // Comedores Sociales
  4. //
  5. // Created by Hector Carrion on 11/30/20.
  6. //
  7. import SwiftUI
  8. struct SearchContainer: View {
  9. @State var filteredItems = foods
  10. var body: some View {
  11. CustomNavigationView(view: AnyView(Search(filteredItems: $filteredItems)), placeHolder: "Search", largeTitle: true, title: "Inventory",
  12. onSearch: { (txt) in
  13. // filterting Data...
  14. if txt != ""{
  15. self.filteredItems = foods.filter{$0.name.lowercased().contains(txt.lowercased())}
  16. }
  17. else{
  18. self.filteredItems = foods
  19. }
  20. }, onCancel: {
  21. // Do Your Own Code When Search And Canceled....
  22. self.filteredItems = foods
  23. })
  24. .ignoresSafeArea()
  25. }
  26. }
  27. struct SearchContainer_Previews: PreviewProvider {
  28. static var previews: some View {
  29. SearchContainer()
  30. }
  31. }