Eureka
Eureka copied to clipboard
DateInlineRow value not updated if tapped other cell too fast
Environment: Eureka 5.2.1, Xcode 11.4.1 and iOS 13.4.1
If I tap another cell while UIDatePicker is still moving value is not saved because removeFromRowObservers
is called before datePickerValueChanged(_:)
I think this is expected. Only when datePickerValueChanged
is called has the picker really changed its value. Before that, the user might be scrolling through the picker but hasn't chosen a value.
I think this is expected. Only when
datePickerValueChanged
is called has the picker really changed its value. Before that, the user might be scrolling through the picker but hasn't chosen a value.
datePickerValueChanged
is called when DatePicker
is hidden and so value is not updated in inline row, with this ugly workaround it behaves correctly.
public typealias DateInlineRowFix = DateInlineRowFix_<Date>
public final class DateInlineRowFix_<T>: _DateInlineRow, RowType, InlineRowType {
required public init(tag: String?) {
super.init(tag: tag)
onExpandInlineRow { cell, row, _ in
let color = cell.detailTextLabel?.textColor
row.onCollapseInlineRow { cell, row, inlineRow in
cell.detailTextLabel?.textColor = color
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(600)) {
if (row.cell != nil && row.value != inlineRow.value) {
row.value = inlineRow.value
row.updateCell()
}
}
}
cell.detailTextLabel?.textColor = cell.tintColor
}
}
public override func customDidSelect() {
super.customDidSelect()
if !isDisabled {
toggleInlineRow()
}
}
}