refactor: 精简主题模板为设置页主题二选一
去掉之前多余的6套模板配色(ocean/sunset/forest/mono等), 只保留一个清晰的二选一功能: - 动物岛风 (默认) — 当前 Animal Island 固定配色,不变 - 系统莫奈色 — 设置页 UI 使用系统 Monet 色系,与主面板一致 改动: - THEME_TEMPLATE → SETTINGS_THEME (animal/monet) - 删除 th_04_theme.js 的 getThemeTemplate/applyThemeTemplate - buildSettingsGroupPanelView 直接根据 SETTINGS_THEME 用 ui.colors 的 Monet 色构造 T 结构 - setPendingValue 中 SETTINGS_THEME 切换时重建设置页
This commit is contained in:
@@ -257,54 +257,30 @@ FloatBallAppWM.prototype.buildSettingsGroupPanelView = function() {
|
||||
var C = this.ui.colors;
|
||||
var T = this.getAnimalIslandTheme();
|
||||
|
||||
// 如果用户选择了非 system 的主题模板,根据模板颜色构造设置页配色替代 Animal Island
|
||||
// 优先从 pendingUserCfg 读模板值(预览态),其次从 this.config
|
||||
// 设置页主题切换:animal(默认动物岛风)或 monet(系统莫奈色)
|
||||
var cfgTpl = this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
|
||||
var tpl = String(cfgTpl.THEME_TEMPLATE || "system");
|
||||
if (tpl !== "system") {
|
||||
var settTheme = String(cfgTpl.SETTINGS_THEME || "animal");
|
||||
if (settTheme === "monet") {
|
||||
try {
|
||||
var tplColors = this.getThemeTemplate(tpl);
|
||||
var Color = android.graphics.Color;
|
||||
var dayBg = tplColors.dayBg ? android.graphics.Color.parseColor(tplColors.dayBg) : null;
|
||||
var dayText = tplColors.dayText ? android.graphics.Color.parseColor(tplColors.dayText) : null;
|
||||
var nightBg = tplColors.nightBg ? android.graphics.Color.parseColor(tplColors.nightBg) : null;
|
||||
var nightText = tplColors.nightText ? android.graphics.Color.parseColor(tplColors.nightText) : null;
|
||||
var bg = isDark ? (nightBg || T.bg) : (dayBg || T.bg);
|
||||
var txt = isDark ? (nightText || T.text) : (dayText || T.text);
|
||||
// 根据主背景色推导辅助色:用调亮/调暗/混合方式生成 T 结构的其他字段
|
||||
var r = Color.red(bg), g = Color.green(bg), b = Color.blue(bg);
|
||||
var lum = (r*0.299 + g*0.587 + b*0.114) / 255.0;
|
||||
var subTxt = isDark ? Color.rgb(
|
||||
Math.min(255, Color.red(txt) + 40),
|
||||
Math.min(255, Color.green(txt) + 40),
|
||||
Math.min(255, Color.blue(txt) + 40)
|
||||
) : Color.rgb(
|
||||
Math.max(0, Color.red(txt) - 40),
|
||||
Math.max(0, Color.green(txt) - 40),
|
||||
Math.max(0, Color.blue(txt) - 40)
|
||||
);
|
||||
var cardBg = isDark ? Color.rgb(
|
||||
Math.min(255, r + 25), Math.min(255, g + 25), Math.min(255, b + 25)
|
||||
) : Color.rgb(
|
||||
Math.max(0, r - 20), Math.max(0, g - 20), Math.max(0, b - 20)
|
||||
);
|
||||
var card2 = isDark ? Color.rgb(
|
||||
Math.max(0, r + 40), Math.max(0, g + 40), Math.max(0, b + 40)
|
||||
) : Color.rgb(
|
||||
Math.min(255, r - 30), Math.min(255, g - 30), Math.min(255, b - 30)
|
||||
);
|
||||
T.bg = bg;
|
||||
T.card = cardBg;
|
||||
T.card2 = card2;
|
||||
T.text = txt;
|
||||
T.sub = subTxt;
|
||||
T.primary = this.ui.colors.primary;
|
||||
T.primaryDeep = this.ui.colors.primary;
|
||||
T.primarySoft = isDark ? this.withAlpha(this.ui.colors.primary, 0.20) : this.withAlpha(this.ui.colors.primary, 0.12);
|
||||
T.brown = txt;
|
||||
T.stroke = isDark ? this.withAlpha(txt, 0.25) : this.withAlpha(txt, 0.18);
|
||||
T.onPrimary = this.ui.colors._monetOnPrimary || (isDark ? Color.parseColor("#062E6F") : Color.WHITE);
|
||||
} catch(eTpl) { safeLog(null, 'e', "catch " + String(eTpl)); }
|
||||
var monetBg = isDark ? C.bgDark : C.bgLight;
|
||||
var monetTxt = isDark ? C.textPriDark : C.textPriLight;
|
||||
var monetCard = isDark ? C.cardDark : C.cardLight;
|
||||
var monetSub = isDark ? C.textSecDark : C.textSecLight;
|
||||
var monetPrimary = C.primary;
|
||||
var monetOnP = C._monetOnPrimary || (isDark ? Color.parseColor("#062E6F") : Color.WHITE);
|
||||
T.bg = monetBg;
|
||||
T.card = monetCard;
|
||||
T.card2 = monetCard;
|
||||
T.text = monetTxt;
|
||||
T.sub = monetSub;
|
||||
T.primary = monetPrimary;
|
||||
T.primaryDeep = monetPrimary;
|
||||
T.primarySoft = isDark ? this.withAlpha(monetPrimary, 0.20) : this.withAlpha(monetPrimary, 0.10);
|
||||
T.brown = monetSub;
|
||||
T.stroke = isDark ? this.withAlpha(monetTxt, 0.16) : this.withAlpha(monetTxt, 0.12);
|
||||
T.onPrimary = monetOnP;
|
||||
} catch(eM) { safeLog(null, 'e', "catch " + String(eM)); }
|
||||
}
|
||||
|
||||
var bgColor = T.bg;
|
||||
|
||||
Reference in New Issue
Block a user