I have this code in one of my views:
struct TextFieldClearButton: ViewModifier {
@Binding var text: String
func body(content: Content) -> some View {
HStack {
content
if !text.isEmpty {
Button(
action: { self.text = "" },
label: {
Image(systemName: "delete.left")
.foregroundColor(Color(UIColor.opaqueSeparator))
}
)
}
}
}
}
I get two errors:
Type 'TextFieldClearButton' does not conform to protocol 'ViewModifier'
Static method 'buildBlock' requires that 'Content' conform to 'View'
How can I get rid of these errors and make this modifier compile?
It looks like I can't use ViewModifier
at all. Adding super simple case errors out too??: