// put me in /app/lib
exports.createTabGroup = function(args) {
// create base tabgroup
var tabGroup = Ti.UI.createTabGroup(args);
if (OS_IOS) {
// get the display width and calc the tab width
var deviceWidth = Ti.Platform.displayCaps.platformWidth;
var tabWidth = deviceWidth / tabGroup.tabs.length;
var indicatorWrapper = Ti.UI.createView({
width : tabWidth,
height : args.tabIndicatorHeight || 1.5,
left : 0,
bottom : 0,
});
// create the base indicator, takes args for height, width, color
var indicator = Ti.UI.createView({
height : Ti.UI.FILL,
backgroundColor : args.tabIndicatorColor || "red",
width : args.tabIndicatorWidth || tabWidth
});
// trap the focus event and animate the indicator
tabGroup.addEventListener("focus", function(e) {
indicatorWrapper.animate({
left : tabWidth * e.index,
duration : 100
});
});
// add the indicator and return the tabgroup
indicatorWrapper.add(indicator);
tabGroup.add(indicatorWrapper);
}
return tabGroup;
};