Problem description
Sample code for ALOY-1058 is using a value for the type property with quotes, while, setting the type from the TSS, it should be used with no quotes.
Not a regression.
From the sample code "index.tss", type is defined in this way:
"#picker":{
type:"Ti.UI.PICKER_TYPE_DATE"
}
while type should be:
type: Ti.UI.PICKER_TYPE_DATE
Steps to reproduce
1. Run the sample code
Result: Running the sample, the picker is actually showing DATE as a type when run, but the constant values should be used with no quotes in the TSS.
Here is the compiled code from Resources/iphone/alloy/controller/index.js:
$.__views.picker = Ti.UI.createPicker({
type: "Ti.UI.PICKER_TYPE_DATE",
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
2. Change index.tss picker stile to:
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
Result: compiled code is:
$.__views.picker = Ti.UI.createPicker({
type: "Ti.UI.PICKER_TYPE_DATE_AND_TIME",
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
However, DATE type picker is still shown (not DATE_AND_TIME).
Considering the generated code, this could be a behavior issue relative to how SDK is handling the Picker type property, not Alloy. Investigating and creating a Classic Titanium sample.
3. Change the picker style to:
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
Result: Picker DATE_AND_STYLE is shown. Compiled code also looks good:
$.__views.picker = Ti.UI.createPicker({
type: Ti.UI.PICKER_TYPE_DATE_AND_TIME,
id: "picker",
minDate: new Date("Tue Apr 01 2014 00:00:00 GMT-0700 (PDT)"),
maxDate: new Date("Thu May 01 2014 12:00:00 GMT-0700 (PDT)"),
value: new Date("Tue Apr 15 2014 12:00:00 GMT-0700 (PDT)")
});
Note
My suggestion for the sample is to use the DATE_AND_TIME picker as type in case of iOS.
i.e.
"#picker":{
type:Ti.UI.PICKER_TYPE_DATE
}
"#picker[platform=ios]":{
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME
}
PR: https://github.com/appcelerator/alloy/pull/563 Functional test: run the ALOY-1058 sample on ios and android simulators, no errors, and you get the date-time or date pickers respectively. Examine the generated code to see that the constant is supplied to the picker constructor without quotes.
PR merged.