I am trying to have user click on image and take them to a different view where it has same image and text from array on that view and for each time they click on image in scollview the view pops up with that information. It will take data from array and show it on next view with the correct item from each toggle.
struct practice: View {
@State var show = false
var place = Placeinfo
var body: some View {
VStack {
ScrollView(.horizontal) {
ForEach(place) { item in
HStack(spacing: 30) {
VStack {
HStack {
VStack {
Text(item.title).font(.headline)
Text(item.subtitle).font(.caption)
Button(action:{
self.show.toggle()
}) {
Image(item.image).renderingMode(.original)
}.sheet(isPresented: self.$show) { Detail() }
}
}
}.padding(.leading)
}
}
}
}
}
}
struct places : Identifiable{
var id = UUID()
var title: String = ""
var subtitle: String = ""
var image: String = ""
}
let Placeinfo = [
places(title: "beach", subtitle: "Cozumel",
image: "beach1"),
places(title: "beach2", subtitle: "Caribbean", image: "beach2"),
places(title: "beach3", subtitle: "CostaRica", image: "beach3")
]