fix(app-iced): M75 r3 —— 禁用内容角色按 A1 改 OnSurfaceVariant + 两项语汇 + probe 双色护栏
A1 定案(本机 gradle 缓存 material3.aar + javap):
FilledButtonTokens.<clinit>: DisabledContainerColor=OnSurface, DisabledContainerOpacity=0.1f
DisabledIconColor/DisabledLabelTextColor=OnSurfaceVariant, 两者 Opacity=0.38f
OutlinedButtonTokens/TextButtonTokens: LabelTextColor=OnSurfaceVariant(12b §1.9 原本就对)
据此:
- interaction::disabled_content_over / disabled_colors 的内容角色从 OnSurface 改成
OnSurfaceVariant(α 仍取令牌 DISABLED_CONTENT_ALPHA=0.38);设计层 color::state::disabled_content()
用的是 OnSurface,与 A1 不符 —— 令牌线修好前这里按 A1 直接求值,已登记。
- content_color 的「底」按有无容器分开:有容器叠 12% 容器、无容器叠 surface(视觉 r2 P2-1)。
- probe 加第二条护栏:无容器三式的 38% 墨迹单独计数,避免只护住有容器那四式(code r2 p2-1)。
- gallery 样例图标改描边(Download + ChevronRight),并加单测钉「同控件不混用 Fill/Stroke」(P2-3)。
- 滚动条:透明轨 + OutlineVariant thumb(P2-4;宽度 10px 是 iced 内部常量,只能改颜色)。
- probe 文档修好被 //! 打断的命令、shot_path 注释归位、去掉空转的重复断言(P2-5)。
This commit is contained in:
1 parent
d075feb77d
commit
5fd1f3ca26
7 files changed
+118
-22
No files matched your search
@@ -141,8 +141,10 @@ fn text_button<'a>(ui: &'a Ui, variant: Variant, state: Interaction) -> Element<
|
||||
}
|
||||
.state(state);
|
||||
if variant != Variant::Text {
|
||||
// 两个样例都必须是**描边**字形:`Play` 是填充字形,和 `ChevronRight` 混在一颗按钮里
|
||||
// 会显得线宽不一致(视觉 reviewer P2-3)。主操作允许实心,但只能单独出现。
|
||||
spec = spec
|
||||
.leading(IconKind::Play)
|
||||
.leading(IconKind::Download)
|
||||
.trailing(IconKind::ChevronRight);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ use iced::{Alignment, Background, Element, Length};
|
||||
|
||||
use unlucky_design::color::Role;
|
||||
use unlucky_design::elevation::MaterialLayer;
|
||||
use unlucky_design::shape::ShapeScale;
|
||||
use unlucky_design::spacing::Space;
|
||||
use unlucky_design::typography::TypeRole;
|
||||
|
||||
@@ -110,9 +111,30 @@ pub fn view<'a>(ui: &'a Ui) -> Element<'a, DemoMessage> {
|
||||
.spacing(ui.space(Space::X8))
|
||||
.width(Length::Fill);
|
||||
|
||||
// 滚动条:默认是主题给的 10px 深灰 thumb(`#6A7985`),压过组件本体(视觉 reviewer P2-4)。
|
||||
// 这里把它改成 **透明轨 + OutlineVariant thumb**;宽度 10px 是 `scrollable` 的内部常量
|
||||
// (该控件不暴露 Scrollbar 配置),所以只做了「低对比」这一半,已登记为偏离 D7。
|
||||
let body = scrollable(sections)
|
||||
.height(Length::Fill)
|
||||
.width(Length::Fill);
|
||||
.width(Length::Fill)
|
||||
.style(move |theme, status| {
|
||||
// `scrollable::Style` 没有 `Default`:底色/间隙从主题默认值出发,只覆盖竖轨
|
||||
let base = scrollable::default(theme, status);
|
||||
scrollable::Style {
|
||||
vertical_rail: scrollable::Rail {
|
||||
background: None,
|
||||
border: iced::Border::default(),
|
||||
scroller: scrollable::Scroller {
|
||||
background: Background::Color(ui.color(Role::OutlineVariant)),
|
||||
border: iced::Border {
|
||||
radius: ui.radius(ShapeScale::Full, ui.space(Space::X2)),
|
||||
..iced::Border::default()
|
||||
},
|
||||
},
|
||||
},
|
||||
..base
|
||||
}
|
||||
});
|
||||
|
||||
// 页面留白走 `layout::inset`(左右/上下各 24):这是 Q8/Q9 那两个 helper 的第三个兄弟,
|
||||
// 存在意义是「只改内边距、不改尺寸」,也顺手避免把 Padding 的上右下左写反。
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
//!
|
||||
//! ```text
|
||||
//! cargo build -p unlucky-app-iced --bin unlucky-launcher-iced
|
||||
//! ./target/debug/unlucky-launcher-iced --software-renderer --screen=gallery //! --screenshot target/m75/gallery-light.png --screenshot-theme=light
|
||||
//! ./target/debug/unlucky-launcher-iced --software-renderer --screen=gallery \
|
||||
//! --screenshot target/m75/gallery-light.png --screenshot-theme=light
|
||||
//! ULL_GALLERY_SHOT=target/m75/gallery-light.png cargo test -p unlucky-app-iced gallery::probe
|
||||
//! ```
|
||||
//!
|
||||
@@ -34,7 +35,6 @@ fn ui(flavor: SchemeFlavor) -> Ui {
|
||||
Ui::with_platform(flavor, Platform::Windows, FAMILIES)
|
||||
}
|
||||
|
||||
/// `ULL_GALLERY_SHOT` → 截图路径(相对路径按**工作区根**解释:`cargo test` 的 cwd 是 crate 目录)。
|
||||
/// 一条 1dp 细线在竖直方向的「墨量覆盖率」:各行相对底色的不透明度之和(1dp ⇒ ≈1.0)。
|
||||
///
|
||||
/// **只统计「长横线行」**(连续非底色像素 > 900):标题/正文那些行也有几百个零散墨迹像素,
|
||||
@@ -91,6 +91,7 @@ fn count_pixels(shot: &Shot, color: [u8; 3]) -> usize {
|
||||
.sum()
|
||||
}
|
||||
|
||||
/// `ULL_GALLERY_SHOT` → 截图路径(相对路径按**工作区根**解释:`cargo test` 的 cwd 是 crate 目录)。
|
||||
fn shot_path() -> Option<std::path::PathBuf> {
|
||||
let raw = std::env::var_os("ULL_GALLERY_SHOT")?;
|
||||
let path = std::path::PathBuf::from(raw);
|
||||
@@ -151,13 +152,12 @@ fn gallery_geometry_matches_the_tokens() {
|
||||
if bbox.width() > 60 {
|
||||
label_button = Some(*bbox);
|
||||
}
|
||||
if (39..=41).contains(&bbox.width()) {
|
||||
// 12b 2.1:IconButton 容器 40×40
|
||||
assert!(
|
||||
(39..=41).contains(&bbox.width()),
|
||||
"IconButton 应为 40×40,实测 {}×{}",
|
||||
bbox.width(),
|
||||
bbox.height()
|
||||
// 12b 2.1:IconButton 容器精确 40×40(别再用区间——reviewer 已证 +2px 抓不住)
|
||||
if bbox.width() < 60 {
|
||||
assert_eq!(
|
||||
(bbox.width(), bbox.height()),
|
||||
(40, 40),
|
||||
"IconButton 容器必须精确 40×40(12b 2.1)"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,16 @@ fn gallery_geometry_matches_the_tokens() {
|
||||
let ink_px = count_pixels(&shot, rgb(disabled_ink));
|
||||
assert!(
|
||||
ink_px > 200,
|
||||
"禁用内容色(on-surface@38%)在图上只出现 {ink_px} 像素: 说明 text / icon 的字形没走 38%(旧实现 enabled 与 disabled 逐像素相同)"
|
||||
"**有容器**四式的禁用内容(OnSurfaceVariant@38% 叠 12% 容器)只出现 {ink_px} 像素: 说明 Filled/Tonal/Elevated 的字形没走 38%"
|
||||
);
|
||||
|
||||
// **无容器**三式(Text / Outlined / standard IconButton)的禁用内容叠在 surface 上,
|
||||
// 是另一个色值;单查上面那个只会覆盖到有容器的四式(reviewer code-r2 p2-1:护栏漏一半)。
|
||||
let bare_ink = crate::app::components::interaction::disabled_content_over(&ui, Role::Surface);
|
||||
let bare_px = count_pixels(&shot, rgb(bare_ink));
|
||||
assert!(
|
||||
bare_px > 200,
|
||||
"**无容器**三式的禁用内容(OnSurfaceVariant@38% 叠 surface)只出现 {bare_px} 像素: 说明 Text/Outlined/standard 的字形没走 38%"
|
||||
);
|
||||
|
||||
// filled 禁用容器里不许出现满档 OnPrimary(旧实现是 #FFFFFF 压在 12% 容器上 = 1.23:1)
|
||||
@@ -352,7 +361,7 @@ fn gallery_geometry_matches_the_tokens() {
|
||||
顶行左内缩 {}(r=20 应 ≈14;8 圆角 ≈4;直角 0)
|
||||
实心块 {} 个(含 40×40 IconButton)
|
||||
分隔线长行 {} 行(每条 1px)
|
||||
禁用容器 (on-surface@12%) 命中 · 禁用内容 38% 墨迹 {} px
|
||||
禁用容器 (on-surface@12%) 命中 · 禁用内容 38% 墨迹 {} px(有容器)/ {} px(无容器)
|
||||
分隔线墨量覆盖率 {:.2}(1dp 应 ≈1.0)
|
||||
字形墨迹 {}px(24 盒应 16~26)",
|
||||
flavor,
|
||||
@@ -362,6 +371,7 @@ fn gallery_geometry_matches_the_tokens() {
|
||||
primary.len(),
|
||||
runs,
|
||||
ink_px,
|
||||
bare_px,
|
||||
coverage,
|
||||
glyph_width
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user