title: Use a Modal to Add an Item from a List in SwiftUI
body: <p>I would like to know how to add an item from a List included in a Modal so when I tap in a row, I can have the item selected in the First View that launched the sheet (to make clearer, the effect the you find when the iPhone app "Messages" select a contact from "Contacts").</p>
  
  <p>Here's my basic code</p>
  
  <pre><code>struct Product : Hashable { 
  
    var name : String
  
    init(name: String) {
      self.name = name
    }
  
    func hash(into hasher: inout Hasher) {
      hasher.combine(name)
    }
  }
  
  
  class Manager {
  
    var product : [Product] = []
  
    init() {
  
  
      let pencil = Product(name: "Pencil")
      let eraser = Product(name: "Eraser")
      let ruler = Product(name: "Notebook")
  
      product = [pencil, eraser, ruler]
  
    }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>struct FirstView: View {
  
    @State var isSheetOpened = false
    var products : Manager
  
    var body: some View {
        VStack {
        Button(action: {
            self.isSheetOpened.toggle()
        }) {
            Text("Add item from sheet")
        }
        .sheet(isPresented: self.$isSheetOpened) {
            Sheet(products: self.products, isSheetOpened: self.isSheetOpened)
        }
  
        Text("Add here")
  
      }
    }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>struct Sheet: View {
  
    var products : Manager
    var isSheetOpened : Bool
  
    var body: some View {
        VStack {
            List {                
                ForEach(self.products.product, id: \.self) { index in
                  Text(index.name)
              }
          }
      }
    }
  }
  </code></pre>