I am migrating an old project to Swift 4, so naturally I also updated to Eureka 4.3.
In the old project, there is a custom row called LatitudeSelectorRow
that presents a LatitudeSelectorController
.
LatitudeSelectorRow
used to look like this:
final class LatitudeSelectorRow: SelectorRow<PushSelectorCell<CLLocationDegrees>, LatitudeSelectorController> {
required init(tag: String?, _ initializer: ((LatitudeSelectorRow) -> ())) {
super.init(tag: tag)
initializer(self)
// Focus on here!!
presentationMode = PresentationMode.show(controllerProvider: ControllerProvider.storyBoard(storyboardId: "LatitudeSelector", storyboardName: "Main", bundle: nil), completionCallback: {
_ in
})
displayValueFor = {
...
}
}
required convenience init(tag: String?) {
self.init(tag: tag)
}
}
And LatitudeSelectorController
used to look like this:
class LatitudeSelectorController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource, TypedRowControllerType {
/// A closure to be called when the controller disappears.
public var onDismissCallback: ((UIViewController) -> ())?
@IBOutlet var latitudePicker: UIPickerView!
var row: RowOf<CLLocationDegrees>!
var completionCallback: ((UIViewController) -> ())?
...
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
let degrees = latitudePicker.selectedRow(inComponent: 0)
let minutes = latitudePicker.selectedRow(inComponent: 1)
let seconds = latitudePicker.selectedRow(inComponent: 2)
let negative = latitudePicker.selectedRow(inComponent: 3) == 1
self.row?.value = (Double(degrees) + Double(minutes) / 60.0 + Double(seconds) / 3600.0) * (negative ? -1 : 1)
}
In Eureka 4.3, that stopped working. It gives me an error saying that LatitudeSelectorController
cannot be converted to a SelectorViewController
.
I tried to work around this by changing the PresentationMode
:
presentationMode = PresentationMode.segueName(segueName: "selectLatitude", onDismiss: nil)
The VC is successfully shown, but I noticed that the row
property is nil. This means that no matter what I select in the VC, the row's value won't be changed.
I also tried to make LatitudeSelectorController
inherit from SelectorRowController
:
class LatitudeSelectorController: SelectorViewController<SelectorRow<PushSelectorCell<Double>>>
and reverted back to using PresentationMode.show
.
This time, row
is not nil, but the whole VC is covered by some view at the front, making my picker view invisible:
How can I create a custom presenter row in Eureka 4.3? Can I not use TypedRowControllerType
anymore?