Thanks a lot for this!
Post
Replies
Boosts
Views
Activity
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(favorites.contains(item) ? systemImage: "heart" : systemImage: "heart.fill") {
if favorites.contains(item) {
favorites.remove(item)
} else {
favorites.add(item)
}
}
}
}
This is the code that doesn't work
I'm sorry for the messy format above but if I modify the code in my original question to Button(favorites.contains(item) ? systemImage: "heart" : systemImage: "heart.fill") it doesn't work anymore
If I replace Button(favorites.contains(item) ? "-" : "+") in my original code with Button(favorites.contains(item) ? systemImage: "heart.fill": systemImage: "heart") it doesn't work anymore.