Skip to content

Instantly share code, notes, and snippets.

@casevictor
Created May 26, 2014 23:40
Show Gist options
  • Save casevictor/374277dde6e6539f03b0 to your computer and use it in GitHub Desktop.
Save casevictor/374277dde6e6539f03b0 to your computer and use it in GitHub Desktop.
How to do a cross-platform loading indicator module.
var loading = require('functions').loading;
loading.setMessage('Autenticando...');
loading.show();
setTimeout(function(){
loading.hide();
},5000);
exports.loading = function(){
if(OS_IOS){
var activityWrapper= Ti.UI.createWindow({
width: '120dp',
height: '120dp',
backgroundColor: 'black',
opacity: 0.7,
borderRadius: 5,
});
var activityIndicator=Ti.UI.createActivityIndicator({
color: 'white',
font: {fontFamily:'Helvetica Neue', fontSize:'12sp'},
message: 'Autenticando...',
height:Ti.UI.SIZE,
width:Ti.UI.SIZE
});
}else{
var activityIndicator = Ti.UI.Android.createProgressIndicator({
message: 'Autenticando...',
location: Ti.UI.Android.PROGRESS_INDICATOR_DIALOG,
type: Ti.UI.Android.PROGRESS_INDICATOR_INDETERMINANT,
cancelable: false,
});
}
return {
setMessage: function(msg){
activityIndicator.message = msg;
},
show: function(){
if(OS_IOS){
activityWrapper.add(activityIndicator);
activityWrapper.open();
}
activityIndicator.show();
},
hide: function(){
activityIndicator.hide();
if(OS_IOS){
activityWrapper.remove(activityIndicator);
activityWrapper.close();
}
},
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment