Created
July 27, 2015 15:39
-
-
Save animecyc/093901bf4f94396efa7f to your computer and use it in GitHub Desktop.
Wrapping controller example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(opts) { | |
'use strict'; | |
// Override MyComponent | |
$.MyComponent = $.content; | |
// Append all the children | |
var children = opts.children || []; | |
if (OS_ANDROID) { | |
for (var i = 0; i < children.length; i++) { | |
$.content.add(children[i]); | |
} | |
} else { | |
$.content.add(children); | |
} | |
// Swizzle the methods that export the root | |
_.extend(exports, { | |
/* Swizzling getTopLevelViews */ | |
getTopLevelViewsOrig: exports.getTopLevelViews, | |
getTopLevelViews: function() { | |
return [$.content]; | |
}, | |
/* Swizzling getView */ | |
getViewOrig: exports.getView, | |
getView: function() { | |
if (!arguments.length) { | |
return $.content; | |
} | |
return this.getViewOrig.apply(this, arguments); | |
} | |
}); | |
}(arguments[0] || {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"#MyComponent": { | |
layout: 'vertical' | |
}, | |
"#content": { | |
height: Ti.UI.SIZE | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<View> | |
<Label text="I'm the wrapper!"/> | |
<View id="content"/> | |
</View> | |
</Alloy> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment