From 00dbb5a5d56eee12168f05e4a48f0f0f33fbe941 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 2 Nov 2026 06:55:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(selection):=20=E9=80=89=E4=B8=AD=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E7=9A=84=20Checkbox=20=E5=AE=B9=E5=99=A8=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20OnSurface@38%=EF=BC=8C=E5=B9=B6=E8=A1=A5=E9=80=90?= =?UTF-8?q?=E6=A0=BC=E6=96=AD=E8=A8=80=EF=BC=88=E5=A4=8D=E5=AE=A1=20P2-3?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A1:SelectedDisabledContainerColor=OnSurface + SelectedDisabledContainerOpacity=0.38(不是普通禁用容器的 12%)。断言同时钉住三件事:fill == 38% 叠色、fill != 12% 容器色、未选中禁用描边与它是同一个 38%。 (同一提交还带着 P2-2 的命中区单测:两处断言都在 tests.rs,无法按 hunk 切分。) --- .../src/components/selection/tests.rs | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/crates/app-iced/src/components/selection/tests.rs b/crates/app-iced/src/components/selection/tests.rs index 0b3c3ed..66011ab 100644 --- a/crates/app-iced/src/components/selection/tests.rs +++ b/crates/app-iced/src/components/selection/tests.rs @@ -6,7 +6,7 @@ use unlucky_design::color::{Role, SchemeFlavor}; use unlucky_design::typography::Platform; -use super::super::interaction::Interaction; +use super::super::interaction::{self, Interaction}; use super::geometry::{ChipGeometry, ControlGeometry, SwitchGeometry}; use super::paint::{self, ChipVariant}; use crate::theme::{Families, Ui}; @@ -21,6 +21,25 @@ fn ui() -> Ui { Ui::with_platform(SchemeFlavor::Light, Platform::Windows, FAMILIES) } +/// 复审 P2-2:命中区恒 **48×48**——Ø40 状态层之外左右各 4dp 透明内边距(无标签时行宽才不是 40)。 +#[test] +fn hit_area_is_48_square_even_without_a_label() { + let ui = ui(); + for (name, geometry) in [ + ("checkbox", ControlGeometry::checkbox(&ui)), + ("radio", ControlGeometry::radio(&ui)), + ] { + assert_eq!(geometry.hit, 48.0, "{name} 命中区必须是 48"); + assert_eq!(geometry.state_layer, 40.0, "{name} 状态层 Ø40"); + assert_eq!(geometry.hit_padding(), 4.0, "{name} 左右各留 4dp"); + assert_eq!( + geometry.state_layer + geometry.hit_padding() * 2.0, + geometry.hit, + "{name}:可见 40 + 左右各 4 = 命中 48" + ); + } +} + /// §18.1 / §18.5 / §18.9:Checkbox 的四个参考值全部来自令牌层。 #[test] fn checkbox_geometry_comes_from_the_token_layer() { @@ -161,11 +180,24 @@ fn checkbox_disabled_keeps_the_stroke_and_uses_the_a1_roles() { ui.color(Role::Surface), "A1:SelectedDisabledIconColor = Surface" ); - assert!(checked.frame.fill.is_some()); + // 复审 P2-3:**选中且禁用**的填充是 OnSurface@38%(`SelectedDisabledContainerOpacity`), + // 不是普通禁用容器的 12%。两格差一眼就能看出来,所以逐字钉住。 + let ink38 = interaction::disabled_content_over_role(&ui, Role::OnSurface, false); + let container12 = interaction::disabled_colors(&ui, Role::Surface).0; + assert_eq!( + checked.frame.fill, + Some(ink38), + "A1:SelectedDisabledContainerOpacity = 0.38" + ); assert_ne!( checked.frame.fill, - Some(ui.color(Role::Primary)), - "禁用不保留 Primary" + Some(container12), + "选中禁用不是 12% 容器色" + ); + assert_eq!( + unchecked.frame.outline, + Some(ink38), + "同一行里未选中禁用描边与选中禁用填充是同一个 38% 叠色" ); }