[ALOY-1517] UI elements are not created properly with formFactor property in style
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-11-24T17:17:29.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.0, alloy 1.9.5 |
Components | Styling |
Labels | Alloy, ios |
Reporter | Jorge Macias Garcia |
Assignee | Feon Sua Xin Miao |
Created | 2016-08-04T12:15:55.000+0000 |
Updated | 2016-12-09T00:47:35.000+0000 |
Description
When I use a conditional style I know the style only applies if the conditions are met. If not, a default style will be applied. For example:
*index.xml*
<Label>Hello, World</Label>
*index.tss*
"Label[platform=ios formFactor=tablet]":{
color: "red"
}
On iPad the label will be red, but it will render as black on other devices.
But this is not the case when I’m styling a NavigationWindow for a specific platform:
*index.xml*
<Alloy>
<NavigationWindow>
<Window>
<Label>Hello, World</Label>
</Window>
</NavigationWindow>
</Alloy>
*index.tss*
"NavigationWindow[platform=ios formFactor=tablet]":{}
Launching the app on an iPhone, Alloy don’t create the NavigationWindow:
$.__views.index = Ti.UI.iOS.createNavigationWindow(function() {
var o = {};
Alloy.isTablet && Alloy.deepExtend(true, o, {
window: $.__views.__alloyId0,
id: "index"
});
return o;
}());
The app crash with the error message: *“Invalid type passed to function”*.
Why a style determines if create or not the element? The correct code could be:
$.__views.index = Ti.UI.iOS.createNavigationWindow(function() {
var o = {};
Alloy.isTablet && Alloy.deepExtend(true, o, {
});
Alloy.deepExtend(true, o, {
window: $.__views.__alloyId0,
id: "index"
});
return o;
}());
Attachments
File | Date | Size |
---|---|---|
Test Navigation Window.zip | 2016-08-04T12:15:19.000+0000 | 10474170 |
PR: https://github.com/appcelerator/alloy/pull/808
Verified fixed, using: MacOS 10.12 (16A323) Ti SDK 6.1.0.v20161208114813 Appc NPM 4.2.8 Appc CLI 6.1.0-312 Alloy 1.9.5 Xcode 8.1 (8B62) UI Elements with a form factor set, both with and without styling defined, will be created properly. Tested by creating UI elements and setting a platform and formfactor on their style. Then built for both the specified platform/formfactor and not, with styling defined and not. All combinations had properly generated code and launched without error.