pages::Model.forced 此前只到得了外壳 + 实例页(唯一消费者 pages/instances.rs:159), 设置页「外观」区的滑块/文本框/裸 iced::button 全都不消费它 ⇒ M284 那四处状态层 (语言档 / 主题档 / 日志 action_button / 外观 choice)只有单测证据,做不出像素判据。 改动: - settings/mod.rs: resolve_state(forced, status) 与 forced_button(button, forced) 成为全仓唯一两个「forced 怎么解释」的点;view → form → section_columns 一路 新增 forced 形参(默认 None ⇒ 今天的行为逐字节不变)。 - Group.body(registry.rs)加第 4 个形参 Option<Interaction>,六组统一签名。 - 四类裸 iced::button 控件把 forced 递进样式闭包并经 resolve_state 落地: 语言档 chip(general/language.rs)、主题档 chip(general/theme.rs)、 日志 action_button(logs_row.rs)、外观 choice(appearance/section/mod.rs, 含 accent/window/bg_image/colour_source 共 10 处调用)。 - components::buttons::Button 的三组(update / ai / java)走 forced_button 的 .state()。 - harness: request.rs 解析 --force-state=rest|hover|pressed(未知值报错,词与产品 cli.rs 同一套),slug 加 -hover/-pressed;app.rs 把它写进 model.forced, 截图通道默认 Rest 的纪律保持(显式值优先)。 - pages/mod.rs: 唯一调用点把 model.forced 传给 settings::view(397 → 399 行)。 单测:resolve_state 的 Some 覆盖 / None 退回;forced_button 的 Some 钉态 / None 原样。
55 lines
2.5 KiB
Rust
55 lines
2.5 KiB
Rust
//! 设置页「Appearance」分组:演示行 + **真控件的接线**(M93 / APPEARWIRE)。
|
||
//!
|
||
//! 这一组是设置页唯一接了真控件的:`body = Some(body)`,`body` 直接调
|
||
//! `crate::pages::appearance::section`。`settings/mod.rs` 只按 `group.body` 分发,**不认识
|
||
//! 「Appearance」这个名字**;分组在左列的下标仍由 `crate::pages::appearance::APPEARANCE_GROUP`
|
||
//! 声明,`settings/tests/mod.rs` 拿它和本文件比对(顺序被调换会红)。
|
||
//!
|
||
//! **这一组归 language+appearance 线**:真控件的实现全在 `pages/appearance/section/`(本文件只负责
|
||
//! 把它挂进注册表),所以改控件时不用碰设置页目录。
|
||
//!
|
||
//! M101 r2:本组的渲染器签名改成收 [`States`](组状态 + 外观状态),于是「这一组要读哪些状态」
|
||
//! 由本文件决定——`settings/mod.rs` 不再认识 `appearance::State`。
|
||
//!
|
||
//! M179 `I18NSEAM`:签名再加一个 `lang`(`Group.body` 的槽位本身就带语言,见 `settings/mod.rs` 的
|
||
//! `Body` 类型别名),于是这一组的中文界面文案真的走词表——此前它只能写死 `Lang::En`,
|
||
//! 因为渲染器拿不到「这一次生效的语言」。
|
||
|
||
use iced::Element;
|
||
use unlucky_design::icons::IconKind;
|
||
use unlucky_i18n::Lang;
|
||
|
||
use crate::app::components::interaction::Interaction;
|
||
use crate::theme::Ui;
|
||
|
||
use super::{Group, Message, States};
|
||
|
||
/// Appearance 分组。`body` 指着 [`body`](它再转给 `pages/appearance/section/` 的真控件);
|
||
/// 没有外观运行期状态时(harness / `pages_demo`)返回 `None`,由 `form` 退回下面的演示行。
|
||
pub(super) const GROUP: Group = Group {
|
||
name: "Appearance",
|
||
icon: IconKind::Sidebar,
|
||
rows: &[
|
||
("Density", "Comfortable"),
|
||
("Corner style", "Follow system"),
|
||
("Motion", "Full"),
|
||
("Text scale", "100%"),
|
||
],
|
||
body: Some(body),
|
||
};
|
||
|
||
/// 本组的真控件渲染器:有外观状态就画真控件(M93),没有(harness)返回 `None`。
|
||
///
|
||
/// `lang` 一路递给 `pages::appearance::section`——它是这一组唯一知道「界面现在是什么语言」的东西;
|
||
/// `forced`(`--force-state`,M285)同样一路递下去,由 `section` 分给各段控件。
|
||
fn body<'a>(
|
||
ui: &'a Ui,
|
||
states: States<'a>,
|
||
lang: Lang,
|
||
forced: Option<Interaction>,
|
||
) -> Option<Element<'a, Message>> {
|
||
states
|
||
.appearance
|
||
.map(|state| crate::pages::appearance::section(ui, state, lang, forced))
|
||
}
|