//
//  SearchContainer.swift
//  Comedores Sociales
//
//  Created by Hector Carrion on 11/30/20.
//

import SwiftUI

struct SearchContainer: View {
    @State var filteredItems = foods
    
    var body: some View {

        CustomNavigationView(view: AnyView(Search(filteredItems: $filteredItems)), placeHolder: "Search", largeTitle: true, title: "Inventory",
                             
            onSearch: { (txt) in

            // filterting Data...
            if txt != ""{
                self.filteredItems = foods.filter{$0.name.lowercased().contains(txt.lowercased())}
            }
            else{
                self.filteredItems = foods
            }
            
        }, onCancel: {
            // Do Your Own Code When Search And Canceled....
            self.filteredItems = foods
            
        })
        .ignoresSafeArea()
    }
}

struct SearchContainer_Previews: PreviewProvider {
    static var previews: some View {
        SearchContainer()
    }
}
