Listening to time change on datetimepicker


#1

I’m trying to implement a datetimepicker, and so I figured that I could do this on iOS by natively changing the default mode on the DatePicker component like this:
datepicker.ios.datePickerMode = UIDatePickerModeDateAndTime;
The major issue now is listening to a change on the time fields. Since the available properties on DatePicker are day, month, year, and date, propertyChange event is only triggered on a date change.
Any idea how to attach an event listener natively? Or alternatively, where can I see a list of available working event names for Nativescript to try?


#2

The best source of inspiration on how to proceed with extending the ios UIDatePicker are the tns-core-modules.

This is for example how changes in the Date Picker are tracked - https://github.com/NativeScript/NativeScript/blob/27773e96a6558fb14e63fb3ef8a83d216591faec/tns-core-modules/ui/date-picker/date-picker.ios.ts#L21 - a change handler ObjC class called UIDatePickerChangeHandlerImpl is created, and it takes care of all available date picker components - https://github.com/NativeScript/NativeScript/blob/27773e96a6558fb14e63fb3ef8a83d216591faec/tns-core-modules/ui/date-picker/date-picker.ios.ts#L85

You could consider toying around with the tns-core-modules code, or copy-pasting theirs into your project and modifying it for your own purposes.