Hello i have an issue with the refresh of my view when i toggle a boolean. Here is the code
class MyItem: Identifiable {
@Published var isActive: Bool
}
struct myView: View {
@Binding var item: MyItem
var body: some View {
HStack {
Toggle("", isOn: $item.isActive)
Spacer()
TextField("", text: item.isActive ? $text : .constant("")) { isFocused in
guard !isFocused && text.count == 0 else { return }
item.isActive.toggle
}
.background(item.isActive ? Color.white : Color.clear)
}
}
}
when i lose my focus and run item.isActive.toggle it change correctly his value, but my Toggle and my TextField doesn't update their UI (the Toggle is still active and the background of the TextField is still white)
Any idea of what i am missing ?