Does the `.badge` modifier work for anyone?

In the Sidebar, the badge doesn't show up for me. This is also the case with the end product:

ForEach(store.gardens(in: store.currentYear)) { garden in
    Label(garden.name, systemImage: "leaf")
      .badge(garden.numberOfPlantsNeedingWater)
}

Odd. Yes, works for me with their sample and in my own project.

Hi

For me, there is a mistake in the Plant.swift file for the needsWater computed property.

return lastWateredOn.timeIntervalSince(Date()) > TimeInterval(wateringFrequency) * 24

IS WRONG and should be:

return Date().timeIntervalSince(lastWateredOn) > TimeInterval(wateringFrequency) * 24 * 60 * 60

The interval is from lastWateredOn until Now and not the opposite.

So the initial code lastWateredOn.timeIntervalSince(Date()) gives a negative value and the test is always false so no badge appears.

Regards

Vincent

Apologies, already answered correctly earlier.

Does the `.badge` modifier work for anyone?
 
 
Q