xmartlabs / Eureka

Elegant iOS form builder in Swift
https://eurekacommunity.github.io
MIT License
11.77k stars 1.33k forks source link

TimePickerRow is undeletable in MultivaluedSection #2228

Closed Nikitaxub closed 1 year ago

Nikitaxub commented 2 years ago

Hi Eureka Team! I need several Time args for my form. I used MultivaluedSection with TimePickerRow in first (because one Time arg should be in all cases) and multivaluedRowToInsertAt.

My code below

form
+++ MultivaluedSection(multivaluedOptions: [.Insert, .Delete],
                       header: "Bedtimes",
                       footer: "Add the timing of the medication, if necessary") {
    $0.addButtonProvider = { section in
        return ButtonRow(){
            $0.title = "Add new bedtime"
        }
    }
    $0.multivaluedRowToInsertAt = { index in
        return TimePickerRow() {
            let formatter = DateFormatter()
            formatter.dateFormat = "HH:mm"
            let someDateTime = formatter.date(from: "09:00")
            $0.value = someDateTime
        }
    }
    $0 <<< TimePickerRow() {
        let formatter = DateFormatter()
        formatter.dateFormat = "HH:mm"
        let someDateTime = formatter.date(from: "09:00")
        $0.value = someDateTime
    }
}

I can't delete any Row.

Screenshot 2022-09-09 at 11 00 34

Next I changed TimePickerRow to e.g TimeRow for first Row:

$0.multivaluedRowToInsertAt = { index in
    return TimePickerRow() {
        let formatter = DateFormatter()
        formatter.dateFormat = "HH:mm"
        let someDateTime = formatter.date(from: "09:00")
        $0.value = someDateTime
    }
}
$0 <<< TimeRow() {
    let formatter = DateFormatter()
    formatter.dateFormat = "HH:mm"
    let someDateTime = formatter.date(from: "09:00")
    $0.value = someDateTime
}

What I see: TimeRow is deletable;

Screenshot 2022-09-09 at 11 16 44

TimePickerRow is deletable if TimeRow is being prepared for deletion;

Screenshot 2022-09-09 at 11 13 16

TimePickerRow is undeletable again if TimeRow isn't being prepared for deletion (w/o screenshot).

Same thing then first Row is TimePickerRow and TimeRow in multivaluedRowToInsertAt.

mats-claassen commented 1 year ago

Hi, I copied your first code into one of the examples and the TimePickerRow is deletable, as you can see in the screenshot below. Might there be anything else you are adding in your code that breaks this?

Screen Shot 2022-09-29 at 08 57 02

And if I press the (-):

Screen Shot 2022-09-29 at 08 57 23
Nikitaxub commented 1 year ago

I don't understand why it didn't work for me for several days in a row. And when I had to go to another country, I checked after your answer and everything is OK) Thank you.