Closed jadjoubran closed 10 years ago
I'll have a look at it. Thanks bud!
Hi @jadjoubran, I noticed two things on your implementation of Toast notifications:
A few things you might want to consider:
var toast = new Toast();
Nonetheless, great suggestion. I wasn't really thinking of adding Toast notifications since you can just use the PhoneGap plugin which is implemented natively.
Hi @jaunesarmiento , thanks for taking a look at Android-Toast!
Then I guess this can be added to the next release. :)
Hey @jaunesarmiento I updated the repository, kindly check it and let me know what you think!
Looks great! :)
@jadjoubran : Looks nice, fading effect quite close to the original Toast. I see the 5px padding in the box, did you test on different resolutions ? :+1:
@aboudard Does the padding make it look awkward? I tested in Samsung Galaxy S2, S3 & S4 and Nexus 4 Let me know if you have any comments
@jadjoubran oh no it looks great, I just wonder if the render is not too different on small resolutions and big ones, I'm testing right now :)
@aboudard okay great, let me know. We can fix it using CSS3 media queries to cater for small devices
Hey @jaunesarmiento are you going to include this in your next release? Let me know if I can help in that!
Yes, I'll be including this on version 1.0.1. :)
There are a few things I want changed before I include this as a component though:
CamelCase
coding style in JavaScript. So Android_Toast
should be converted to AndroidToast
and methods like set_duration
should be setDuration
. I want this implemented to provide coding style consistency.-
.@jadjoubran About the Toast code, I would recommend the use of literal object as parameters, easy to implement and much easer to code with.
in the Class you would find something like that :
function Android_Toast(){
this.timeout_id = null;
this.duration = 3000;
this.content = '';
this.position = 'bottom';
for (var n in arguments[0]) {
this[n] = arguments[0][n];
console.log(arguments[0][n]); // please remove me ;)
}
}
the call would look like that :
var toast = new Android_Toast({content: 'Hello Fries', duration: 5000});
what do you think ?
Or the following:
// If we're using fries namespace, do:
// var fries = window.fries || {};
(function () {
var Toast = function (options) {
this.init(options);
}
Toast.prototype = {
_defaults: {
// default options here
},
init: function (options) {
// merge user options with defaults
// show the Toast
// then hide Toast after a while
this.destroy(); // then destroy it
},
destroy: function () {
// destroy Toast here
}
};
// Then expose it in window or Fries namespace
window.Toast = Toast;
// or fries.Toast = Toast;
}());
Even better with the prototype ! I didn't mean to refactor the whole Toast :)
Hey! Thank you for your feedback. However can you please post this as an issue on the project itself? Just decide which one is better and I'll implement it as soon as possible
@jadjoubran : it's done !
Hey @jaunesarmiento I updated the code and wrapped the JS into an IIFE. Regarding the coding style, shall I do a new branch to provide you the designed coding style? Please advise since it's currently my first contribution to an open source project. Thanks!
Hey
There's this repo that replicates Android Toasts using HTML5 and Javascript ( no jQuery/zepto) dependency. I think it fits well with Fries.
https://github.com/jadjoubran/Android-Toast