-
-
Save dizda/5038393 to your computer and use it in GitHub Desktop.
Growl-like notifications in Titanium (tested under iOS)
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
Growl = (function() { | |
// constructor | |
function Growl(message){ | |
this.message = message; | |
} | |
Growl.prototype.show = function() | |
{ | |
this.createWindow(); | |
}; | |
Growl.prototype.createWindow = function() | |
{ | |
Ti.API.info('Growl :'+this.message); | |
var window = Ti.UI.createWindow({ | |
title:this.message, | |
backgroundColor:'#000', | |
top:135, left:95, | |
width:145,height:145, | |
opacity:0, | |
borderRadius:16 | |
}); | |
var imgValid = Ti.UI.createImageView({ | |
image:'/images/growl_check.png', | |
top:20, left:42, | |
width:64, | |
height:64 | |
}); | |
var label = Ti.UI.createLabel({ | |
color:'#FFF', | |
font:{fontWeight:'bold'}, | |
text:this.message, | |
textAlign:'center', | |
width:135, | |
left:6, | |
bottom:10, | |
height:'auto', | |
}); | |
var animation = Ti.UI.createAnimation({ | |
duration:250, | |
opacity:0.7 | |
}); | |
animation.addEventListener('complete',function(){ | |
setTimeout( function(){ | |
window.animate( {duration:1000, opacity:0}, function(){ | |
window.close(); | |
}); | |
},1000 ); | |
}); | |
window.animate(animation); | |
window.add(imgValid); | |
window.add(label); | |
window.open(); | |
}; | |
return Growl; | |
})(); | |
module.exports = Growl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And call it with something like that :