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
@@ -68,7 +68,7 @@ pub(super) fn assemble<'a, M: Clone + 'a>(
|
||||
// 早先这里恒取 `ui.color(content)`,再被 `text(...).color(..)` 钉死,`Style.text_color`
|
||||
// 里的 38% 永远下发不出去 —— 表现为「text / standard icon 的 enabled 格与 disabled 格
|
||||
// 逐像素相同」(视觉 reviewer 实测 changed_px = 0;filled 禁用标签 1.23:1)。
|
||||
let ink = content_color(ui, forced, content);
|
||||
let ink = content_color(ui, forced, content, fill);
|
||||
|
||||
let label = text(spec.label)
|
||||
.size(ui.style(TypeRole::LabelLarge).size_px)
|
||||
@@ -132,9 +132,19 @@ pub(super) fn assemble<'a, M: Clone + 'a>(
|
||||
///
|
||||
/// 单独成函数是为了让「内容色跟态走」这件事只有一处实现——`assemble`(文字按钮)与 `icon`
|
||||
/// (图标按钮)都调它,两条路径不会再各自钉死满档色。
|
||||
pub(super) fn content_color(ui: &Ui, forced: Option<Interaction>, content: Role) -> iced::Color {
|
||||
pub(super) fn content_color(
|
||||
ui: &Ui,
|
||||
forced: Option<Interaction>,
|
||||
content: Role,
|
||||
fill: Option<Role>,
|
||||
) -> iced::Color {
|
||||
match forced {
|
||||
Some(Interaction::Disabled) => interaction::disabled_colors(ui, Role::Surface).1,
|
||||
// 有容器:38% 叠在**12% 容器**上(Filled / Tonal / Elevated)
|
||||
Some(Interaction::Disabled) if fill.is_some() => {
|
||||
interaction::disabled_colors(ui, Role::Surface).1
|
||||
}
|
||||
// 无容器:38% 直接叠在 **surface** 上(Text / Outlined / standard IconButton)
|
||||
Some(Interaction::Disabled) => interaction::disabled_content_over(ui, Role::Surface),
|
||||
_ => ui.color(content),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,11 @@ pub fn text<'a, M: Clone + 'a>(ui: &'a Ui, button: Button<'a, M>) -> Element<'a,
|
||||
|
||||
/// IconButton(standard / filled / tonal):40×40、图标 24、命中区 48。
|
||||
///
|
||||
/// **图标语汇纪律(视觉 reviewer P2-3)**:同一个控件里**不混用**填充字形(`IconPaint::Fill`,
|
||||
/// 如 `Play`/`Stop`/`More`)与描边字形(`Stroke`)——混着放会让线宽看起来忽粗忽细。
|
||||
/// 允许实心字形,但只能出现在「主操作」这一处(例如播放按钮),其余位置一律描边;
|
||||
/// gallery 的样例因此统一用描边图标(`Download` + `ChevronRight`),并有单测钉住。
|
||||
///
|
||||
/// `on_press: Option<M>`(`None` = 禁用)与 `state` 分开给:前者是语义,后者是取证开关。
|
||||
pub fn icon<'a, M: Clone + 'a>(
|
||||
ui: &'a Ui,
|
||||
@@ -290,7 +295,7 @@ pub fn icon<'a, M: Clone + 'a>(
|
||||
// 这里把盒子做成整个 40×40(而不是 24×24):`button::layout` 把内容放左上角、不居中,
|
||||
// 所以「居中」这件事必须由容器自己写死,别指望 button。
|
||||
// 内容色跟态走(禁用 = on-surface@38%),见 `assemble::content_color` 的说明
|
||||
let glyph = assemble::content_color(ui, forced, content);
|
||||
let glyph = assemble::content_color(ui, forced, content, fill);
|
||||
let icon_box =
|
||||
layout::centered_fixed(geometry.side, geometry.side, icons::view::<M>(kind, glyph));
|
||||
|
||||
|
||||
@@ -109,6 +109,27 @@ fn icon_button_geometry_matches_the_reference() {
|
||||
);
|
||||
}
|
||||
|
||||
/// 视觉 reviewer P2-3:同一控件里不许混用填充字形与描边字形(线宽语汇会打架)。
|
||||
///
|
||||
/// gallery 的样例图标(前置/后置)必须同为 `IconPaint::Stroke`;允许实心字形,但只能作为
|
||||
/// 「主操作」单独出场的图标(例如播放键),不能与描边图标同处一颗按钮。
|
||||
#[test]
|
||||
fn sample_icons_never_mix_fill_and_stroke() {
|
||||
use unlucky_design::icons::IconPaint;
|
||||
|
||||
let sample = [IconKind::Download, IconKind::ChevronRight];
|
||||
for kind in sample {
|
||||
assert_eq!(
|
||||
kind.icon().paint,
|
||||
IconPaint::Stroke,
|
||||
"{} 是填充字形,不能和描边图标混在同一颗按钮里",
|
||||
kind.name()
|
||||
);
|
||||
}
|
||||
// 已知的实心字形(留档,下次有人拿它们当按钮图标时这条会提醒)
|
||||
assert_eq!(IconKind::Play.icon().paint, IconPaint::Fill);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn five_variants_have_distinct_colour_roles() {
|
||||
let mut seen = Vec::new();
|
||||
|
||||
Reference in new issue
Block a user