Created
May 26, 2014 23:40
-
-
Save casevictor/374277dde6e6539f03b0 to your computer and use it in GitHub Desktop.
How to do a cross-platform loading indicator module.
This file contains hidden or 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
var loading = require('functions').loading; | |
loading.setMessage('Autenticando...'); | |
loading.show(); | |
setTimeout(function(){ | |
loading.hide(); | |
},5000); | |
This file contains hidden or 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
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