Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1517] UI elements are not created properly with formFactor property in style

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-11-24T17:17:29.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0, alloy 1.9.5
ComponentsStyling
LabelsAlloy, ios
ReporterJorge Macias Garcia
AssigneeFeon Sua Xin Miao
Created2016-08-04T12:15:55.000+0000
Updated2016-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

FileDateSize
Test Navigation Window.zip2016-08-04T12:15:19.000+000010474170

Comments

  1. Feon Sua Xin Miao 2016-11-14

    PR: https://github.com/appcelerator/alloy/pull/808
  2. Eric Wieber 2016-12-09

    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.

JSON Source