I am struggling to move the fitting information to a different View.
The thought is first to pick the Activity that has Standing 0 and move it to CardContentView to show below the Part of New duties. If I print the values, its right however it all the time shows the primary information/array no matter its Standing. What could possibly be carried out right here?
struct Duties: Identifiable {
let id = UUID()
let title: String
let standing: Int
let picture: String
}
extension Duties {
static var testData: [Tasks] {
return [
Tasks(name: "Inprogress", status: 1, image:"a1"),
Tasks(name: "New", status: 0, image:"a2"),
]
}
}
ContentsView
struct ContentsView: View {
@State var gadgets: [Tasks]
var dimension = 0
var physique: some View {
NavigationView {
Record {
let new = gadgets.filter({$0.standing == 0})
let dimension = new.depend
if dimension > 0 {
Part(header:Textual content("(dimension)" + " New")){
//let _ = print(new)
ForEach(new.indices, id: .self) {itemIndex in
NavigationLink(vacation spot: ChosenTask()) {
CardContentView(merchandise: self.$gadgets[itemIndex])
}
}
}
}
}
.navigationBarTitle("My duties")
}
}
}
CardContentView
struct CardContentView: View {
@Binding var merchandise: Duties
var physique: some View {
HStack {
VStack(alignment: .main,spacing: 5) {
Label("Title: " + (merchandise.title), systemImage: "individual.crop.circle")
.font(.system(dimension: 12))
.labelStyle(.titleAndIcon)
}
.body(maxWidth: .infinity, alignment: .main)
Picture(merchandise.picture)
.resizable()
.body(width: 60, top: 70)
}
}
}