Ok, so i'm trying to get a list element in another view to view more details and interact with it. Right now, This is a snippet of the code: (Note, this is in a Navigation View and that syntax is correct)
//below is listed before the body
@ObservedObject var jobViewModel: JobViewModel
//The rest is a snippet of the code in question
List{
ForEach(jobViewModel.jobs){ job in
let jobDate = ParserDate(date: job.date)
if job.completed == false && jobDate == comparisonDate{
let jobTime = ParserTime(time: job.date)
NavigationLink(destination: dummy(job: job))
{
VStack(alignment: .leading){
HStack{
Text("Boat Name")
Spacer()
.frame(width: 50, height: 50)
Text(job.boatName)
}
//Text(job.boatID)
HStack{
Text("Job Time")
Spacer()
.frame(width: 50, height: 50)
Text(jobTime)
}
HStack{
Text("Job Type")
Spacer()
.frame(width: 50, height: 50)
Text(job.job)
}
HStack{
Text("Owner's Name")
Spacer()
.frame(width: 50, height: 50)
Text(job.ownerName)
//Text(job.time)
}
}
}
}
}
}
This is the dummy view as of right now:
import SwiftUI
struct dummy: View {
let job: Job
var body: some View {
Text("Placeholder for job details, will not exists in production, please delete")
VStack(alignment: .leading){
HStack{
Text("Boat Name")
Spacer()
.frame(width: 50, height: 50)
Text(job.boatName)
}
Text(job.boatID)
/*HStack{
Text("Job Time")
Spacer()
.frame(width: 50, height: 50)
Text(jobTime)
}*/
HStack{
Text("Job Type")
Spacer()
.frame(width: 50, height: 50)
Text(job.job)
}
HStack{
Text("Owner's Name")
Spacer()
.frame(width: 50, height: 50)
Text(job.ownerName)
//Text(job.time)
}
}
}
}
struct dummy_Previews: PreviewProvider {
static var previews: some View {
dummy(job: Job[0])
}
}
On the "dummy(job: Job[0])" line, i am getting this error: Type 'Job' has no member 'subscript'. I don't know where I'm going wrong. Any help is appreciated.