fix: 设置页所有 UI 元素统一跟随 SETTINGS_THEME 切换

之前只有 buildSettingsGroupPanelView(分组页)检查了
SETTINGS_THEME,但首页面板 buildSettingsHomePanelView
和入口卡片 createSettingsHomeEntry 直接硬编码
getAnimalIslandTheme(),导致切换到 Monet 后首页仍是
动物岛风。

修复: 提取公共方法 applySettingsTheme(T, isDark, C, cfgTpl),
在三个构建位置统一调用:
- createSettingsHomeEntry (入口卡片:徽章/标题/按钮颜色)
- buildSettingsHomePanelView (设置首页:背景/统计卡/按钮)
- buildSettingsGroupPanelView (分组页:背景/卡片/预览开关)
This commit is contained in:
7015725
2026-05-15 02:29:03 +08:00
parent b79961b08e
commit efdcd3f187
3 changed files with 38 additions and 27 deletions

View File

@@ -1,4 +1,33 @@
// @version 1.0.0
// 根据当前 SETTINGS_THEME 覆盖 TAnimal Island 配色对象),
// 使设置页所有 UI 元素(首页/分组页/入口卡片)统一跟随主题切换。
// 传入 T、isDark、C(this.ui.colors)、cfgTpl(配置源),直接修改 T 的字段。
FloatBallAppWM.prototype.applySettingsTheme = function(T, isDark, C, cfgTpl) {
var settTheme = String((cfgTpl || this.config).SETTINGS_THEME || "animal");
if (settTheme !== "monet") return;
try {
var Color = android.graphics.Color;
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(e) { safeLog(null, 'e', "catch " + String(e)); }
};
FloatBallAppWM.prototype.getSettingsGroupDefs = function() {
return [
{ key: "ball", title: "漂浮气球", desc: "调整气球大小、图标和跟随距离", sections: ["悬浮球"] },
@@ -38,6 +67,8 @@ FloatBallAppWM.prototype.createSettingsHomeEntry = function(parent, title, desc,
var isDark = this.isDarkTheme();
var C = this.ui.colors;
var T = this.getAnimalIslandTheme();
var cfgTpl = this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
this.applySettingsTheme(T, isDark, C, cfgTpl);
var cardColor = T.card;
var textColor = T.text;
var subTextColor = T.sub;
@@ -111,6 +142,8 @@ FloatBallAppWM.prototype.buildSettingsHomePanelView = function() {
var isDark = this.isDarkTheme();
var C = this.ui.colors;
var T = this.getAnimalIslandTheme();
var cfgTpl = this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
this.applySettingsTheme(T, isDark, C, cfgTpl);
var bgColor = T.bg;
var subTextColor = T.sub;
var panel = this.ui.createStyledPanel(this, 16);
@@ -259,29 +292,7 @@ FloatBallAppWM.prototype.buildSettingsGroupPanelView = function() {
// 设置页主题切换animal默认动物岛风或 monet系统莫奈色
var cfgTpl = this.state.pendingUserCfg ? this.state.pendingUserCfg : this.config;
var settTheme = String(cfgTpl.SETTINGS_THEME || "animal");
if (settTheme === "monet") {
try {
var Color = android.graphics.Color;
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)); }
}
this.applySettingsTheme(T, isDark, C, cfgTpl);
var bgColor = T.bg;
var cardColor = T.card;