I think I found a better way of doing this. Rather than keeping days as a computed property, I changed it to @State and moved its computation implementation to the View's top level ZStack's onAppear. It was most certainly being called somewhere in my code again and again. But I only needed to calculate days only once to begin with so there was no point in making it a computed property in the first place.
Post
Replies
Boosts
Views
Activity
Hi @Claude31, heres the code for checkbox where days is actually being used:
var checkboxes: some View {
HStack {
if days.count > 0 {
ForEach(days.reversed(), id: \.id) {day in
VStack() {
Text(day.dayValue)
.fontWeight(.light)
.font(.callout)
if !day.checked && !day.passed {
Image(systemName: "circle")
.resizable()
.frame(width: daysCircleRadius, height: daysCircleRadius)
} else if !day.checked && day.passed {
Image(systemName: "multiply.circle")
.resizable()
.frame(width: daysCircleRadius, height: daysCircleRadius)
} else {
Image(systemName: "checkmark.circle")
.resizable()
.frame(width: daysCircleRadius, height: daysCircleRadius)
}
}
}
}
}
When I comment out the ForEach in here, the app works perfectly, without showing the checkboxes