{ "id": "105799", "key": "TIMOB-13425", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2016-10-19T14:14:22.000+0000", "created": "2012-12-01T09:25:30.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "Carbon", "SDK", "applyProperties", "create", "js", "native", "proxy", "speed" ], "versions": [], "issuelinks": [ { "id": "27279", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "112093", "key": "TIMOB-13317", "fields": { "summary": "TiAPI: Allow ListView templates outside of ListView", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-29T17:51:06.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "12305", "name": "Core", "description": "Central component of the Platform (outside of Tooling, or platform specific implementation details)" } ], "description": "Following a discussion on Twitter and the Alloy Google Group, I've put together a test project to see how [Carbon|http://carbon.appersonlabs.com]'s way of batching UI creation in a single {{create()}} or via JSON, could work for Titanium and it's new MVC Alloy.\r\n\r\nThe test project and it's documentation can be found at:\r\nhttps://github.com/FokkeZB/nl.fokkezb.alloyCarbonized\r\n\r\nMy conclusions can be found in a blog post at:\r\nhttp://fokkezb.nl/post/36942105712/alloycarbonized\r\n\r\nThe tests show that passing a whole view-hierarchy to {{Carbon.UI.create()}} in one dictionary speeds up UI creation up to 200%.\r\n\r\nI guess this is exactly why in 3.x the {{applyProperties()}} methods are being introduced, to also minimize the number of trips from JS- to native-land.\r\n\r\nSo my request is to continue on this path and add a {{Carbon.UI.create()}} like {{Ti.UI.create()}} to the SDK.\r\n\r\nHaving done so, it would be just a small step to have Alloy make heavy use of this new method in the code it generates based on the XML and TSS files.\r\n\r\nSome ideas of how this would work:\r\n\r\n{code}\r\n// Ti.UI.create returns some kind of view-collection object\r\nvar views = Ti.UI.create({\r\n 'Window': {\r\n fullscreen: false,\r\n backgroundColor: '#fff',\r\n\r\n // Non-hierarchy views can also be added like:\r\n titleControl: {\r\n 'Label': {\r\n text: 'My title',\r\n font: { fontWeight: 'bold' }\r\n }\r\n },\r\n \r\n // Child views are added through a 'children' property\r\n children: [\r\n {\r\n 'View': {\r\n\r\n // Only views that have an 'id' can be referenced in JS-land through a proxy object\r\n id: 'red',\r\n \r\n top: 100, left: 50,\r\n width: 200, height: 200,\r\n backgroundColor: '#f00',\r\n \r\n children: [\r\n 'Label': {\r\n id: 'platform',\r\n\r\n // In Alloy this wouldn't be needed since platform branching is done at built-time,\r\n // but for usage without Alloy this would be really nice to have.\r\n platform: ['android'],\r\n \r\n top: 25, right: 25, bottom: 25, left: 25,\r\n backgroundColor: '#0f0',\r\n \r\n text: 'I am green Android'\r\n },\r\n 'Label': {\r\n id: 'platform',\r\n platform: ['ios'],\r\n \r\n top: 25, right: 25, bottom: 25, left: 25,\r\n backgroundColor: '#00f',\r\n \r\n text: 'I am blue iOS'\r\n },\r\n\r\n // You could also include an existing Ti.UI object like this:\r\n someExistingView\r\n ]\r\n }\r\n },\r\n {\r\n 'Label': {\r\n top: 400, left: 0, right: 0,\r\n height: Ti.UI.SIZE,\r\n \r\n text: 'I want Ti.UI.create()',\r\n\r\n // Events could also be added like this, but\r\n // it would compromise clear controller-view-separation\r\n onClick: myCallback,\r\n\r\n // Just like platform-branching, formFactor would be like:\r\n formFactor: ['tablet']\r\n }\r\n }\r\n ]\r\n }\r\n});\r\n\r\n// Views that have an 'id' can be referenced from JS-land\r\nvar redView = views.get('redView');\r\n\r\n// Views you won't need anymore can be destroyed, including children\r\nviews.release('platform');\r\n\r\n// Or just release all\r\nviews.release();\r\n{code}", "attachment": [], "flagged": false, "summary": "Ti.UI.create(): An applyProperties-like way to create a whole view hierarchy at once", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": null, "comment": { "comments": [ { "id": "229485", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Added example for using existing views in Ti.UI.create() and including non-hierarchy views like a window's titleControl (or rightNavButton etc.)", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-12-02T07:40:37.000+0000", "updated": "2012-12-02T07:40:37.000+0000" }, { "id": "229486", "author": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Added example for formFactor and event support, so it now included pretty much everything Alloy could need from generating a single {{Ti.UI.create()}} call from it's XML and TSS file.", "updateAuthor": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-12-02T07:44:10.000+0000", "updated": "2012-12-02T07:44:10.000+0000" }, { "id": "399366", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Some thought from my side:\r\n* At the time this ticket ticket was created, we didn't have a GA version of Alloy (released in 08/2013 along with Titanium 3.0.2), so the ability to create custom view-structures made more sense at that time\r\n* The design proposal does not include the handling custom namespaces e.g. {{Ti.UI.iOS}} or {{Ti.UI.Android}}\r\n* This structure could be created on the JavaScript side, without the need to change the core. You could just iterate through the data structure and call the namespaces from there, since they are usual objects (e.g. {{Ti.UI.ImageView}} = {{Ti.UI[\"Label\"]}}).\r\n* The [Carbon library|https://github.com/iamyellow/Carbon] already has parts of this implemented and could be extended for those who really need this feature\r\n\r\nConsidering that and the priority of other tickets that should be addresses instead, I will resolve this ticket for now, thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-10-19T14:14:22.000+0000", "updated": "2016-10-19T14:14:22.000+0000" }, { "id": "416213", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket with reference to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-29T17:51:06.000+0000", "updated": "2017-03-29T17:51:06.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }