mirror of https://github.com/espruino/BangleApps
settings 0.42: Fix theme customizer on new Bangle 2 firmware
parent
ef9f772a49
commit
c1db203205
|
@ -44,3 +44,4 @@
|
||||||
0.39: Fix misbehaving debug info option
|
0.39: Fix misbehaving debug info option
|
||||||
0.40: Moved off into Utils, put System after Apps
|
0.40: Moved off into Utils, put System after Apps
|
||||||
0.41: Stop users disabling all wake-up methods and locking themselves out (fix #1272)
|
0.41: Stop users disabling all wake-up methods and locking themselves out (fix #1272)
|
||||||
|
0.42: Fix theme customizer on new Bangle 2 firmware
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "setting",
|
"id": "setting",
|
||||||
"name": "Settings",
|
"name": "Settings",
|
||||||
"version": "0.41",
|
"version": "0.42",
|
||||||
"description": "A menu for setting up Bangle.js",
|
"description": "A menu for setting up Bangle.js",
|
||||||
"icon": "settings.png",
|
"icon": "settings.png",
|
||||||
"tags": "tool,system",
|
"tags": "tool,system",
|
||||||
|
|
|
@ -243,12 +243,11 @@ function showThemeMenu() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function showCustomThemeMenu() {
|
function showCustomThemeMenu() {
|
||||||
function cv(x) { return g.setColor(x).getColor(); }
|
|
||||||
function setT(t, v) {
|
function setT(t, v) {
|
||||||
let th = g.theme;
|
let th = g.theme;
|
||||||
th[t] = v;
|
th[t] = v;
|
||||||
if (t==="bg") {
|
if (t==="bg") {
|
||||||
th['dark'] = (v===cv("#000"));
|
th['dark'] = (v===cl("#000"));
|
||||||
}
|
}
|
||||||
upd(th);
|
upd(th);
|
||||||
}
|
}
|
||||||
|
@ -260,11 +259,7 @@ function showThemeMenu() {
|
||||||
let colors = [], names = [];
|
let colors = [], names = [];
|
||||||
for(const c in rgb) {
|
for(const c in rgb) {
|
||||||
names.push(c);
|
names.push(c);
|
||||||
colors.push(cv(rgb[c]));
|
colors.push(cl(rgb[c]));
|
||||||
}
|
|
||||||
function cn(v) {
|
|
||||||
const i = colors.indexOf(v);
|
|
||||||
return i!== -1 ? names[i] : v; // another color: just show value
|
|
||||||
}
|
}
|
||||||
let menu = {
|
let menu = {
|
||||||
'':{title:'Custom Theme'},
|
'':{title:'Custom Theme'},
|
||||||
|
@ -277,14 +272,11 @@ function showThemeMenu() {
|
||||||
};
|
};
|
||||||
["fg", "bg", "fg2", "bg2", "fgH", "bgH"].forEach(t => {
|
["fg", "bg", "fg2", "bg2", "fgH", "bgH"].forEach(t => {
|
||||||
menu[labels[t]] = {
|
menu[labels[t]] = {
|
||||||
value: colors.indexOf(g.theme[t]),
|
min : 0, max : colors.length-1, wrap : true,
|
||||||
format: () => cn(g.theme[t]),
|
value: Math.max(colors.indexOf(g.theme[t]),0),
|
||||||
|
format: v => names[v],
|
||||||
onchange: function(v) {
|
onchange: function(v) {
|
||||||
// wrap around
|
var c = colors[v];
|
||||||
if (v>=colors.length) {v = 0;}
|
|
||||||
if (v<0) {v = colors.length-1;}
|
|
||||||
this.value = v;
|
|
||||||
const c = colors[v];
|
|
||||||
// if we select the same fg and bg: set the other to the old color
|
// if we select the same fg and bg: set the other to the old color
|
||||||
// e.g. bg=black;fg=white, user selects fg=black -> bg changes to white automatically
|
// e.g. bg=black;fg=white, user selects fg=black -> bg changes to white automatically
|
||||||
// so users don't end up with a black-on-black menu
|
// so users don't end up with a black-on-black menu
|
||||||
|
|
Loading…
Reference in New Issue