Last active
January 25, 2016 13:32
-
-
Save manumaticx/11400523 to your computer and use it in GitHub Desktop.
Normalized User Notifications
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
/* | |
* This is how I notify users about errors, confirmations etc. | |
* e.g.: "Wrong password", "Registration complete", ... | |
* | |
*/ | |
module.exports = (function(){ | |
var notification, | |
OS_IOS = 'iPhone OS' === Ti.Platform.name, | |
OS_ANDROID = 'android' === Ti.Platform.name; | |
if (OS_ANDROID){ | |
notification = require('de.manumaticx.crouton'); | |
} | |
if (OS_IOS){ | |
notification = require('de.marcelpociot.mwkprogress'); | |
} | |
function confirm(message){ | |
OS_IOS && notification.showSuccessMessage(message); | |
OS_ANDROID && notification.showText(message, notification.STYLE_CONFIRM); | |
} | |
function alert(message){ | |
OS_IOS && notification.showErrorMessage(message); | |
OS_ANDROID && notification.showText(message, notification.STYLE_ALERT); | |
} | |
function info(message){ | |
OS_IOS && notification.showMessageWithColor({ | |
message: message, | |
color: '#005bd1' | |
}); | |
OS_ANDROID && notification.showText(message, notification.STYLE_INFO); | |
} | |
return { | |
confirm: confirm, | |
alert: alert, | |
info: info | |
}; | |
}()); |
Author
manumaticx
commented
Apr 29, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment