fix(design,app-iced): 图标尺寸与禁用 α 收敛到官方字节码,两族拆开(M86)

图标:IconSize::Button 16→18(AAR ButtonDefaults.<clinit> 的 bipush 18);新增
IconSize::SwitchThumb=16(SwitchTokens.Selected/UnselectedIconSize)承接开关滑块,按钮与
滑块不再借同一档;IconSize::Nav 的值不动但文档订正(无消费,官方导航/列表图标是 24)。
ButtonSmallTokens.IconSize=20 在整包 AAR 里零消费(javap 搜 getIconSize 无外部调用),
是死令牌,不再作为取值依据。

禁用 α:官方本来就分两族——按钮容器 0.10(*ButtonTokens.DisabledContainerOpacity)与
面状控件 0.12(chip 描边 / slider 轨道 / switch 轨道)。原来的缺陷是一个全局 12% 同时
服务两族(按钮那半边一直错、另半边一直对),现拆成 disabled_button_colors/…_content
与 disabled_colors/disabled_content_over_role 两个入口;interaction 首次超 400 行,
禁用口径与测试搬到 interaction/disabled.rs。

标题栏 caption 三键:官方 SmallIconButtonTokens.IconSize=24,按用户点名缩到 20
(容器 46×48 不动),登记为项目偏离;icons.rs 加按令牌取尺寸的入口 view_at,按
(种类,尺寸) 分别烘焙 SVG,20px 的 stroke 取 1.8 保视觉线宽 1.5px。
This commit is contained in:
AskaEth committed 2026-11-02 13:12:11 +08:00
1 parent c825e1aa3d
commit b566097107
16 files changed
+664 -175

No files matched your search

@@ -143,13 +143,13 @@ pub(super) fn content_color(
disabled_content: Role,
) -> iced::Color {
match forced {
// 有容器:38% 叠在**12% 容器**上(Filled / Tonal / Elevated)
// 有容器:38% 叠在**按钮家族 10% 容器**上(Filled / Tonal / Elevated)
Some(Interaction::Disabled) if fill.is_some() => {
interaction::disabled_content_over_role(ui, disabled_content, true)
interaction::disabled_button_content(ui, disabled_content, true)
}
// 无容器:38% 直接叠在 **surface** 上(Text / Outlined / standard IconButton)
Some(Interaction::Disabled) => {
interaction::disabled_content_over_role(ui, disabled_content, false)
interaction::disabled_button_content(ui, disabled_content, false)
}
_ => ui.color(content),
}
@@ -167,7 +167,7 @@ pub(super) fn style_closure(
.unwrap_or_else(|| Interaction::from_status(status));
let (background, text_color) = if state.is_disabled() {
let (container, content) = interaction::disabled_colors(ui, Role::Surface);
let (container, content) = interaction::disabled_button_colors(ui, Role::Surface);
// 透明容器在禁用态依然透明(官方只改内容透明度)
(spec.fill.map(|_| container), content)
} else {
@@ -184,7 +184,7 @@ pub(super) fn style_closure(
};
let border_color = if state.is_disabled() {
interaction::disabled_colors(ui, Role::Surface).0
interaction::disabled_button_colors(ui, Role::Surface).0
} else {
spec.border
.map_or_else(|| ui.color(Role::OutlineVariant), |role| ui.color(role))
@@ -6,20 +6,21 @@
//! | 圆角 | `ShapeScale::Full.radius_px(高)` | 20 `[源]` 12b 1.2 |
//! | 左右内边距(无图标) | `Space::X6` | 24 / 24 `[源]` 12b 1.3 |
//! | 左内边距(带前置图标) | `Space::X4` | 16 `[源]` 12b 1.4 |
//! | 图标边长 | `IconSize::Button` | 16(**官方 18 → G14 偏离**) |
//! | 图标边长 | `IconSize::Button` | 18 `[源]` AAR `ButtonDefaults.IconSize = 18.dp`(12b 1.6 同值) |
//! | 图标↔文字 | `Space::X2` | 8 `[源]` 12b 1.6 |
//! | 描边 | `unlucky_design::stroke::HAIRLINE`(`crate::theme::STROKE_PX` 同一真源) | 1 `[源]` rubric G7 |
//! | IconButton 边长 | `LayoutMetrics::control_height` | 40 `[源]` 12b 2.1 |
//! | IconButton 图标 / 边距 | `IconSize::Toolbar` / `Space::X2` | 24 / 8 `[源]` 12b 2.2 |
//!
//! **没有落点的两个参考值**(登记在报告里,不在此处写数):
//! **没有落点的一个参考值**(登记在报告里,不在此处写数):
//!
//! - 12b 1.7 最小宽 **58** → `G15`:iced 的 `Length` 没有 min-width 语义;按「24 + 24 内边距 +
//! LabelLarge 二字」自然宽度 ≈ 76,实际不触发,故本 mission 不施加该约束;
//! - 12b 1.6 图标 **18** → `G14`:令牌层 `IconSize::Button` 是 16、没有 18 档,
//! 组件层又不许写字面量 → 先用 16 并登记 2px 偏离。
//! LabelLarge 二字」自然宽度 ≈ 76,实际不触发,故本 mission 不施加该约束。
//!
//! 这两条是**能力缺口不是审美选择**,登记后由令牌层(`crates/design`)补档位。
//! **G14 已收口(M86)**:这里曾登记「12b 1.6 图标 18 → 令牌只有 16,先用 16 并偏离 2px」。
//! 令牌层现在有 18 档([`IconSize::Button`],出处在 `crates/design/src/icons/mod.rs`),
//! 所以本文件取 18 就是**回到规范值**,不再是偏离。**别按 `ButtonSmallTokens.IconSize = 20` 改**:
//! 那个 token 在 AAR 里零消费(没有任何类读它的 `getIconSize`),是死令牌。
use iced::Padding;
@@ -9,14 +9,14 @@
//! | 1.3 | 水平内边距(无图标) | **24 / 24** | `Space::X6` |
//! | 1.4 | 水平内边距(带前置图标) | **16(左)/ 24(右)** | `Space::X4` / `Space::X6` |
//! | 1.5 | 字级 | **LabelLarge 14/20 w500** | `TypeRole::LabelLarge` 强调档 |
//! | 1.6 | 图标 18 + 图标↔文字 8 | 图标见 **G14 偏离**(令牌只有 16);间距 `Space::X2` | [`Geometry`] |
//! | 1.6 | 图标 18 + 图标↔文字 8 | **18** = `IconSize::Button`(AAR `ButtonDefaults.IconSize`);间距 `Space::X2` | [`Geometry`] |
//! | 1.7 | 最小宽 58 | **G15**:iced 的 `Length` 无 min-width,不施加(实测见报告) | — |
//! | 1.8 | 状态层 + 禁用 | hover 8 / focus 10 / pressed 10;容器 12%(A1 是 10%,D8)& 内容 38%;**内容角色按变体**([`Variant::disabled_content`]) | [`super::interaction`] |
//! | 1.8 | 状态层 + 禁用 | hover 8 / focus 10 / pressed 10;容器 **10%**(官方 `DisabledContainerOpacity`;面状控件的 12% 是另一类)& 内容 38%;**内容角色按变体**([`Variant::disabled_content`]) | [`super::interaction`] |
//! | 1.9 | 五式色彩角色 | Filled `Primary`/`OnPrimary`;Tonal `SecondaryContainer`/`OnSecondaryContainer`;Elevated `SurfaceContainerLow`/`Primary`;Outlined 透明 + 1dp `OutlineVariant` + `OnSurfaceVariant`;Text 透明 + `OnSurfaceVariant` | [`Variant::roles`] |
//! | 2.1 | IconButton 容器 | **40×40**、圆角 full | [`IconGeometry`] |
//! | 2.2 | IconButton 图标 / 边距 | 图标 **24**、边距 **8** | [`IconGeometry`] |
//! | 2.4 | Standard 各态**图标色不变** | 只有状态层变化 | [`Variant::roles`] 与态无关 |
//! | 2.7 | IconButton 禁用 | 内容 **`OnSurface`@38%**(A1;见 [`IconVariant::disabled_content`]) | [`super::interaction::disabled_content_over_role`] |
//! | 2.7 | IconButton 禁用 | 内容 **`OnSurface`@38%**(A1;见 [`IconVariant::disabled_content`]) | [`super::interaction::disabled_button_content`](按钮族 10% 底) |
//! | 2.8 | 命中区 | 容器 40 + 四周各 4 = **48** | `LM.touch_target`(按钮自身不撑高) |
//!
//! ## 与契约 §2 的签名差异(**已登记,请 tower 确认**)
@@ -234,7 +234,7 @@ impl<'a, M> Button<'a, M> {
}
}
/// 一个禁用的按钮(无消息)。禁用不是「另一种颜色」,见 `interaction::disabled_colors`。
/// 一个禁用的按钮(无消息)。禁用不是「另一种颜色」,见 `interaction::disabled_button_colors`。
pub fn disabled(label: &'a str) -> Self {
Self {
label,
@@ -84,8 +84,17 @@ fn geometry_matches_the_reference_values() {
assert_eq!(outlined.stroke, STROKE_PX, "rubric G7 全站 1px");
assert_eq!(outlined.stroke, 1.0);
// 图标 16 是**令牌值**;官方 18 是 G14 登记的偏离(不在这里假装相等)
assert_eq!(geometry.icon, 16.0, "IconSize::Button");
// 图标 18 是**令牌值**(`IconSize::Button`,AAR `ButtonDefaults.IconSize`);
// 12b 1.6 的 18 与它同源。**别按 `ButtonSmallTokens.IconSize = 20` 改**:那是零消费者的死令牌。
assert_eq!(
geometry.icon, 18.0,
"IconSize::Button(官方 ButtonDefaults.IconSize)"
);
assert_eq!(
geometry.icon,
unlucky_design::icons::IconSize::Button.px(),
"组件侧必须只从令牌取值(不许写字面量)"
);
assert_eq!(geometry.height % 4.0, 0.0, "可见高必须在 4px 栅格上(D1)");
}
@@ -269,9 +278,12 @@ fn outlined_style_draws_hairline_border_and_full_radius() {
let disabled = style(&ui.theme(), button::Status::Disabled);
let (container, content) =
interaction::disabled_colors(&ui, unlucky_design::color::Role::Surface);
interaction::disabled_button_colors(&ui, unlucky_design::color::Role::Surface);
assert_eq!(disabled.text_color, content, "禁用内容 = 令牌 38%");
assert_eq!(disabled.border.color, container, "禁用描边 = 令牌 12%");
assert_eq!(
disabled.border.color, container,
"禁用描边 = 按钮族的令牌 10%(OutlinedButtonTokens.DisabledContainerOpacity)"
);
}
#[test]