title: SwiftUI - Passing Dynamic Data via Button
body: <p>I'm trying to pass dynamic details from a master page to a detail page via a Button action. The view I'm passing to, I'm animating from off-screen, into the view using animation. I was able to get this to work when I was passing simple hard coded data, but I'm having an issue trying to figure out how to get it to pass data specific to the item row that was tapped.</p>
  
  <p>I've wrapped the item row element with the button, but not sure I'm passing the right info into the button action parameter.</p>
  
  <pre><code>import SwiftUI
  
  struct SearchView: View {
  @State var show = false
  var course = courseData
  var body: some View {
  
      ZStack {
  
          ScrollView (.vertical, showsIndicators: false) {
  
              VStack(spacing: 0.0) {
                  ForEach(course) { item in
                      Button(action: { self.show.toggle() })  {
                          CourseResultTile(perks: item.perks, hotdeals: item.hotdeals, image: item.image, courseName: item.courseName, distance: item.distance, reviews: item.reviews, priceSpan: item.priceSpan, timeSpan: item.timeSpan)
                      }
                  }
              }
          }.offset(y: 120)
  </code></pre>
  
  <p>// View I'm animating in below //</p>
  
  <pre><code>        FacilityView(show: $show, perks: self.perks, image: self.image, courseName: self.courseName, address: self.address)
              .rotation3DEffect(Angle(degrees: show ? 0 : 60), axis: (x: 0, y: 10.0, z: 0))
              .animation(.default)
              .offset(x: show ? 0 : -UIScreen.main.bounds.width)
              .onTapGesture {
                  self.show.toggle()
          }
  
      }
      .navigationBarTitle(Text("Search"), displayMode: .inline)
      .navigationBarHidden(true)
      .edgesIgnoringSafeArea(.top)
  
  
  
  }
  }
  </code></pre>
  
  <p>// Course Data Model //</p>
  
  <pre><code>struct Course : Identifiable {
  var id = UUID()
  var hotdeals: String
  var perks: String
  var image: String
  var courseName: String
  var distance: String
  var reviews: String
  var priceSpan: String
  var timeSpan: String
  var address: String
  }
  
  let courseData = [
  Course(hotdeals: "Badge_HotDeals", perks: "Badge_NoPerks", image: "Image_CourseBackground", courseName: "Timacuan Golf Club", distance: "16.8 miles", reviews: "(562)", priceSpan: "$12.00 - $34.00", timeSpan: "1:53PM - 6:00 PM", address: "550 Timacuan Boulevard, Lake Mary, Florida, 32746"),
  Course(hotdeals: "Badge_HotDeals", perks: "Badge_NoPerks", image: "Image_Course1", courseName: "Sanctuary Ridge Golf Club", distance: "20.1 miles", reviews: "(895)", priceSpan: "$12.00 - $34.95", timeSpan: "8:46 AM - 5:02 PM", address: "2601 Diamond Club Drive, Clermont, Florida, 34711"),
  Course(hotdeals: "Badge_HotDeals", perks: "Badge_NoPerks", image: "Image_Course2", courseName: "Eagle Creek Golf Club - FL", distance: "14.3 miles", reviews: "(1K)", priceSpan: "$12.00 - $42.00", timeSpan: "8:42 AM - 5:51 PM", address: "10350 Emerson Lake Blvd, Orlando, Florida, 32832")
  </code></pre>
  
  <p>// FacilityView excerpt //</p>
  
  <pre><code>import SwiftUI
  
  struct FacilityView: View {
  
  var dateFormatter: DateFormatter {
  let formatter = DateFormatter()
  formatter.dateStyle = .medium
  return formatter
  }
  
  
  var perks = "Badge_NoPerks"
  var image = "Image_Course6"
  var courseName = "Panther Lake: Orange County National"
  var address = "16301 Phil Ritson Way, Winter Garden, FL 34787"
  var holes = "18"
  var par = "72"
  var length = "6836"
  var slope = "127"
  
  @Binding var show: Bool
  @State private var todaysDate = Date()
  </code></pre>
  
  <p>The error I'm getting is "Value of type 'SearchView' has no member 'variable I'm trying to pass'</p>