feat(app-iced): 强调色接线落地(M250 ACCENTWIRE)
appearance.accent_color 此前是死线:配置键、presenter 往返、预设色板都在,但造 tokens 的 唯一入口恒走 DesignTokens::brand(board),用户填了色界面不变。 - theme.rs:Ui::with_accent + accent_scheme(唯一调用 DesignTokens::with_accent 的地方) - app/state/theme.rs:rebuild_ui 三选一(显式强调色 > D38 取色方案 > 出厂板),diag 一行说清是谁生效 - pages/appearance:新增 accent 状态(原文/解析结果/方案/结构化错误)+ 设置页输入行与预设色块; 非法值保持上一次合法值并给出 Short/Long/Digit 三档原因,不静默回退出厂色 - presenter::prefs:AccentChoice::parse 成为唯一解析点,set_accent_checked 交回结构化原因 - app/appearance.rs:persist_appearance 带上 accent_color(此前写不进去),只写上一次合法值 - pages/harness/app.rs:gallery 也能吃 ULL_APPEARANCE_ACCENT,供出图矩阵 - core keys.rs:订正「空 = 出厂 #0078D4;accent 令牌全域生效」这句半真半假的说明 - i18n:强调色 7 条文案(链尾新域,金表只追加) 判据:同一组件(进度条 Primary)在空配置与 #006A5C 下色值不同(App 级 + 令牌级两条); 非法值拿到结构化错误、生效色不回退、不写盘、tokens 仍可构造。
This commit is contained in:
1 parent
4cdb46d2e0
commit
e6b2200360
18 files changed
+787
-38
No files matched your search
@@ -40,7 +40,11 @@ impl App {
|
||||
);
|
||||
}
|
||||
|
||||
/// 按「配色来源是否取色成功」重建 [`Ui`]。
|
||||
/// 按「强调色 / 配色来源是否接管」重建 [`Ui`]。
|
||||
///
|
||||
/// **优先级(M250):显式强调色 > D38 取色方案 > 出厂品牌板**。手填的色是直接意图,取色是从
|
||||
/// 图片派生的,所以强调色只在用户真的填了合法值时压过取色——两条路都只决定「颜色来自哪里」,
|
||||
/// `flavor`(明暗 / 跟随系统)仍由 `self.appearance.flavor()` 决定。
|
||||
///
|
||||
/// 色卡档(③)刻意继续走 `Scheme::baseline`:`resolve_source` 的色卡档返回的是
|
||||
/// `DEFAULT_CARD`(天蓝卡)方案,与令牌 baseline 逐色不同,应用它会把**全部既有验收图的
|
||||
@@ -49,15 +53,34 @@ impl App {
|
||||
// 面板 α(D36)在这里注入 `Ui`:全仓所有表面色都从 `Ui::layer` 出去,所以这是**唯一**
|
||||
// 生效点(外壳 / 三页卡片 / 外观分组卡片 / 空态图标块自动同源,调用点没有机会各处自乘)。
|
||||
let panel_alpha = self.appearance.effective_panel_alpha();
|
||||
self.ui = match self.appearance.derived_scheme() {
|
||||
Some(scheme) => {
|
||||
self.ui = match (
|
||||
self.appearance.accent.color(),
|
||||
self.appearance.derived_scheme(),
|
||||
) {
|
||||
(Some(accent), _) => {
|
||||
// M250:一行里同时给「强调色生效了」与「取色方案被谁压住」,两件事都能读出来。
|
||||
diag!(
|
||||
"[appearance] accent={} → Ui::with_accent(只换 primary/secondary/tertiary;\
|
||||
取色方案 palette={} 被显式强调色压住)",
|
||||
self.appearance.accent.log_token(),
|
||||
self.appearance.palette_level()
|
||||
);
|
||||
Ui::with_accent(self.appearance.flavor(), accent, self.families)
|
||||
}
|
||||
(None, Some(scheme)) => {
|
||||
diag!(
|
||||
"[appearance] palette={} → Ui::from_scheme(取色方案接管 49 个角色)",
|
||||
self.appearance.palette_level()
|
||||
);
|
||||
Ui::from_scheme(*scheme, self.families)
|
||||
}
|
||||
None => Ui::new(self.appearance.flavor(), self.families),
|
||||
(None, None) => {
|
||||
// 非法值:**保持出厂板**,但错行留在设置页(不静默),日志里也留一条。
|
||||
if let Some(error) = self.appearance.accent.error() {
|
||||
diag!("[appearance] accent 非法({error:?})→ 出厂板,错行见设置页");
|
||||
}
|
||||
Ui::new(self.appearance.flavor(), self.families)
|
||||
}
|
||||
}
|
||||
.with_panel_alpha(panel_alpha);
|
||||
}
|
||||
@@ -151,3 +174,58 @@ impl App {
|
||||
&self.ui
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::App;
|
||||
use crate::app::components::feedback::progress;
|
||||
use crate::cli::Options;
|
||||
use crate::pages::appearance::Change;
|
||||
use crate::theme::Families;
|
||||
use unlucky_design::color::{Color, SchemeFlavor};
|
||||
use unlucky_presenter::mock::MockBackend;
|
||||
use unlucky_presenter::settings_bridge::SettingsBridge;
|
||||
|
||||
const FAMILIES: Families = Families {
|
||||
text: "Segoe UI",
|
||||
display: "Segoe UI",
|
||||
mono: "Consolas",
|
||||
};
|
||||
|
||||
/// 强调色接线(M250 ACCENTWIRE)的 App 级判据:`rebuild_ui` 真的换了令牌。
|
||||
///
|
||||
/// **这条是判据一的变异探针**:把 [`App::rebuild_ui`] 改回「恒走 `Ui::new` 出厂板」
|
||||
/// (或在它前面短路掉 `accent.color()` 分支),下面 `assert_ne!` 当场红——`pages/appearance`
|
||||
/// 那条用例只证明「`Ui::with_accent` 能给出不同的色」,抓不到「谁去调它」。
|
||||
///
|
||||
/// 抓得住:接线不存在 / 被短路 / 强调色解析结果没进 `Ui`。
|
||||
/// 抓不住:像素(样式闭包被别处覆盖)——那是出图的事。
|
||||
#[test]
|
||||
fn rebuild_ui_follows_the_configured_accent() {
|
||||
let mut app = App::with_presenter(
|
||||
Options::default(),
|
||||
FAMILIES,
|
||||
SchemeFlavor::Light,
|
||||
Box::new(MockBackend::new()),
|
||||
SettingsBridge::memory_only(),
|
||||
);
|
||||
|
||||
// 出厂态:同一组件(进度指示条 = `Role::Primary`)取到的值
|
||||
let (_, factory_primary) = progress::linear_colors(app.ui());
|
||||
assert_eq!(app.ui().name(), "ull-silver");
|
||||
|
||||
// 设置页填色 → `on_appearance` 会 rebuild 一次(与真机路径同一个函数)
|
||||
app.on_appearance(Change::Accent(Color::rgb(0x00, 0x6A, 0x5C).to_hex()));
|
||||
let (_, accent_primary) = progress::linear_colors(app.ui());
|
||||
|
||||
assert_ne!(
|
||||
factory_primary, accent_primary,
|
||||
"填了自定义强调色,`rebuild_ui` 却还给出出厂板的 Primary ⇒ 接线没落地"
|
||||
);
|
||||
assert_eq!(
|
||||
app.ui().flavor(),
|
||||
SchemeFlavor::Light,
|
||||
"强调色只换颜色来源,不改明暗"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user