Skip to content

Commit

Permalink
[TIMOB-24817] Implement ListView Alloy widget support
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Mar 22, 2018
1 parent f56da33 commit 26b4ec6
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions android/modules/ui/src/js/listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,30 @@ exports.bootstrap = function(Titanium) {

//convert name of UI elements into a constructor function.
//I.e: lookup("Titanium.UI.Label") returns Titanium.UI.createLabel function
function lookup(name) {
var lastDotIndex = name.lastIndexOf('.');
var proxy = eval(name.substring(0, lastDotIndex));
if (typeof(proxy) == undefined) return;
function lookup(namespace) {

var proxyName = name.slice(lastDotIndex + 1);
return proxy['create' + proxyName];
// handle Titanium widgets
if (/^(Ti|Titanium)/.test(namespace)) {
const namespaceIndex = namespace.lastIndexOf('.'),
proxyName = namespace.slice(namespaceIndex + 1),
parentNamespace = namespace.substring(0, namespaceIndex),
parentProxy = eval(parentNamespace);

if (parentProxy) {
return parentProxy['create' + proxyName];
}

// handle Alloy widgets
} else {
const widget = '/alloy/widgets/' + namespace + '/controllers/widget',
hasWidget = Ti.Filesystem.getFile(widget).exists();

if (hasWidget) {
return (parameters) => {
new (require(widget))(parameters);
};
}
}
}

//overwrite list view constructor function with our own.
Expand Down

0 comments on commit 26b4ec6

Please sign in to comment.