forked from FOSS/BangleApps
25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
|
|
// Auto-generated by apps/icons/gen/generate.js
|
|
|
|
/// Get an icon based on a name from getIconNames that can be drawn with g.drawImage
|
|
exports.getIcon = function(name) {
|
|
let match = ",home|0,bike|1,car|2,fan|3,light|4,plug|5,rocket|6,switch|7,sync|8,up|9,down|10,left|11,right|12,close|13,".match(new RegExp(`,${name.toLowerCase()}\\|(\\d+)`))
|
|
return require("Storage").read("icons.img", (match===null)?0:match[1]*76, 76);
|
|
};
|
|
|
|
/// Get a list of available icon names
|
|
exports.getIconNames = function() {
|
|
return ["home","bike","car","fan","light","plug","rocket","switch","sync","up","down","left","right","close"];
|
|
};
|
|
|
|
/// Show a menu to allow an icon to be chosen - its name is returned
|
|
exports.showIconChooser = function() {
|
|
return new Promise((resolve,reject) => {
|
|
var menu = { "" : { title : /*LANG*/"Icons", back : ()=>{E.showMenu();reject();}}}
|
|
exports.getIconNames().forEach(name => {
|
|
menu[`\0${exports.getIcon(name)} ${name}`] = ()=>{E.showMenu();resolve(name);};
|
|
});
|
|
E.showMenu(menu);
|
|
});
|
|
};
|
|
|