tweaks to last commit

pull/843/head
Gordon Williams 2021-10-06 20:14:22 +01:00
parent c1a5cafb26
commit 05145da819
1 changed files with 71 additions and 68 deletions

View File

@ -163,8 +163,9 @@ function showBLEMenu() {
}); });
} }
let m; function showThemeMenu() {
function updT(th) { function cl(x) { return g.setColor(x).getColor(); }
function upd(th) {
g.theme = th; g.theme = th;
settings.theme = th; settings.theme = th;
updateSettings(); updateSettings();
@ -175,14 +176,12 @@ function updT(th) {
g.clear(1); g.clear(1);
Bangle.drawWidgets(); Bangle.drawWidgets();
m.draw(); m.draw();
} }
function showThemeMenu() { var m = E.showMenu({
function cl(x) { return g.setColor(x).getColor(); }
m = E.showMenu({
'':{title:'Theme'}, '':{title:'Theme'},
'< Back': ()=>showMainMenu(), '< Back': ()=>showMainMenu(),
'Dark BW': ()=>{ 'Dark BW': ()=>{
updT({ upd({
fg:cl("#fff"), bg:cl("#000"), fg:cl("#fff"), bg:cl("#000"),
fg2:cl("#0ff"), bg2:cl("#000"), fg2:cl("#0ff"), bg2:cl("#000"),
fgH:cl("#fff"), bgH:cl("#00f"), fgH:cl("#fff"), bgH:cl("#00f"),
@ -190,7 +189,7 @@ function showThemeMenu() {
}); });
}, },
'Light BW': ()=>{ 'Light BW': ()=>{
updT({ upd({
fg:cl("#000"), bg:cl("#fff"), fg:cl("#000"), bg:cl("#fff"),
fg2:cl("#00f"), bg2:cl("#0ff"), fg2:cl("#00f"), bg2:cl("#0ff"),
fgH:cl("#000"), bgH:cl("#0ff"), fgH:cl("#000"), bgH:cl("#0ff"),
@ -199,8 +198,8 @@ function showThemeMenu() {
}, },
'Customize': ()=>showCustomThemeMenu(), 'Customize': ()=>showCustomThemeMenu(),
}); });
}
function showCustomThemeMenu() { function showCustomThemeMenu() {
function cv(x) { return g.setColor(x).getColor(); } function cv(x) { return g.setColor(x).getColor(); }
function setT(t, v) { function setT(t, v) {
let th = g.theme; let th = g.theme;
@ -224,7 +223,10 @@ function showCustomThemeMenu() {
const i = colors.indexOf(v); const i = colors.indexOf(v);
return i!== -1 ? names[i] : v; // another color: just show value return i!== -1 ? names[i] : v; // another color: just show value
} }
let menu = {'':{title:'Customize Theme'}}; let menu = {
'':{title:'Customize Theme'},
"< Back"] : () => showThemeMenu();
};
const labels = { const labels = {
fg: 'Foreground', bg: 'Background', fg: 'Foreground', bg: 'Background',
fg2: 'Foreground 2', bg2: 'Background 2', fg2: 'Foreground 2', bg2: 'Background 2',
@ -249,8 +251,9 @@ function showCustomThemeMenu() {
}, },
}; };
}); });
menu["< Back"] = () => {delete m;showThemeMenu();}; menu["< Back"] = () => showThemeMenu();
m = E.showMenu(menu); m = E.showMenu(menu);
}
} }
function showPasskeyMenu() { function showPasskeyMenu() {
@ -291,7 +294,7 @@ function showWhitelistMenu() {
if (settings.whitelist) settings.whitelist.forEach(function(d){ if (settings.whitelist) settings.whitelist.forEach(function(d){
menu[d.substr(0,17)] = function() { menu[d.substr(0,17)] = function() {
E.showPrompt('Remove\n'+d).then((v) => { E.showPrompt('Remove\n'+d).then((v) => {
if (v) if (v) {
settings.whitelist.splice(settings.whitelist.indexOf(d),1); settings.whitelist.splice(settings.whitelist.indexOf(d),1);
updateSettings(); updateSettings();
} }