Open-Bytes/SwiftUIFormValidator

Display issue with custom checkbox that uses a inline validation

jeffbailey opened this issue · 0 comments

I have a custom toggle style that displays an empty circle when not enabled and a checked circle when enabled.

struct CheckToggleStyle: ToggleStyle {
    func makeBody(configuration: Configuration) -> some View {
        Button {
            configuration.isOn.toggle()
        } label: {
            Label {
                configuration.label
            } icon: {
                Image(systemName: configuration.isOn ? "checkmark.circle.fill" : "circle")
                    .foregroundColor(configuration.isOn ? .accentColor : .secondary)
                    .accessibility(label: Text(configuration.isOn ? "Checked" : "Unchecked"))
                    .imageScale(.large)
            }
        }
        .buttonStyle(PlainButtonStyle())
    }
}

This used to work fine, but after upgrading to the 1.0 version, the checkmark no longer displays when enabled. You can easily test this out in the Example Form by adding the following in ExampleForm:

 @FormField(inlineValidator: { value in
        return value ? nil : "You must acknowledge"
    })
    var ack: Bool = false
    lazy var ackValidation = _ack.validation(manager: manager)

And the following in one of the sections of ContentView:

            Toggle(isOn: $form.ack) {
                Text("Random Acknowledgement")
            }
            .validation(form.ackValidation)
            .toggleStyle(CheckToggleStyle())

This worked fine when using versions prior to 1.0. Any ideas?