This plugin aims to recreate the Toast notification from Android to be used in Sencha Touch apps. This plugin allows the Toast to be called multiple times like in Android and it will get queued. Also, it allows for a custom action button on the Toast, e.g. UNDO.
These plugin have been tested working with Sencha Touch 2.3.1.
At the Application level, you'll need to add the required class to be loaded automatically.
Ext.Application({
requires: [ 'BA.Toast' , .. ],
..
});
At anytime needed, you can create a Toast instance by simply creating the class. Also include toast.js and toast.css into your app.
To show a simple toast:
Ext.create('BA.Toast', {
message: 'This is a toast',
toastDuration: 'SHORT'
});
To show a toast with an undo action button:
Ext.create('BA.Toast', {
message: 'Toast that allows undo',
toastDuration: 2500,
doAction: {
text: 'Undo',
tap: function() {
console.log('Perform undo function here');
// Other code here..
}
}
});
Parameter | Value |
---|---|
message | A string to display on the toast. Pick something real short and sweet! |
toastDuration | Duration of how long to show the Toast. Value can be set either in:
Defaults to long duration |
doAction | An object that must have two fields:
|
In toast.css, feel free to edit the 3 classes tied to the toast, message and action button.
Only one line of text as the message.
Unforunately that is not the right behaviour. Creating the class instance multiple times will queue the Toasts to display one after another.
Coming soon..
- Version 1.0
- Release: April 2, 2015.
- First release.