microsoft / ace

Build Cordova apps with true native UI
http://microsoft.github.io/ace
Other
850 stars 157 forks source link

DatePicker and TimePicker does not work on iOS? #49

Closed jnordstrom1983 closed 8 years ago

jnordstrom1983 commented 8 years ago

Sorry if I totally missed something fundamental of Ace and have done something really wrong here. But as far I can't see that the DatePicker nor the TimePicker UI component works as expected on iOS?

Problem 1: No time/date is reported back when time is changed.

Steps to reproduce: Run the following code:

var p = new ace.Popup();
var stackPanel = new ace.StackPanel()
var dt = new ace.DatePicker();
stackPanel.getChildren().add(dt);
p.setContent(stackPanel)
p.show();

Then change the the date in the date picker.

Result: dt.getDate() now returns "Invalid date".

After trying to figure out why i think this may be because no date is reported back from the native component.

In src/ios/DatePicker.mm it seams to me like nil is sent back to the JavaScript and not the actual date as it is in src/android/framework/DatePicker.java

src/ios/DatePicker.mm

    if (_dateChangedHandlers > 0) {
        [OutgoingMessages raiseEvent:@"datechanged" handle:_handle eventData:nil];
    }

src/android/framework/DatePicker.java

 void raiseDateChangedEvent(String dateString) {
    if (_dateChangedHandlers > 0) {
      OutgoingMessages.raiseEvent("datechanged", _dateChangedHandle, dateString);
    }
  }

Problem 2 As far as I can see the .setDate/.setTime doesn't work either.

Steps to reproduce: Run the following code:

var p = new ace.Popup();
var stackPanel = new ace.StackPanel()
var dt = new ace.DatePicker();
stackPanel.getChildren().add(dt);
p.setContent(stackPanel)
p.show();
var d = new Date();
d.setDate(d.getDate()+10)
dt.setDate(d)

Result: The date in the date picker is showing wrong date.

Don't have a clue why this doesn't work.

adnathan commented 8 years ago

Thank you so much for the report! I've just committed fixes for both issues, and I've published a new version with them included (0.0.17).