fix(app-iced): M75 r5 —— 禁用内容角色按变体(A1)+ 删 probe 重复块 + 逐行护栏
1) A1 逐变体(AAR javap):Filled/Elevated/Outlined/Text = OnSurfaceVariant@0.38; FilledTonal = OnSurface@0.38(FilledTonalButtonTokens.DisabledLabelTextColor); Standard/Filled IconButton = OnSurface@0.38(*IconButtonTokens.DisabledColor)。 新增 Variant::disabled_content() / IconVariant::disabled_content(), interaction::disabled_content_over_role(ui, role, on_container) 成唯一入口。 2) probe.rs 删掉被两个 reviewer 点名的重复块(disabled_colors 调用两次、 disabled_container 绑定两次),并补 grep 证据。 3) 护栏改成**逐行**:矩阵 7 个有内容的变体行各自断言 disabled 列的 38% 墨迹 > 40 px (浅/深同一套阈值,单行回退就会红),取代原来按浅色标定的全局 500 阈值。 6) 删掉 interaction/mod.rs 里挂在 mod tests 头上的悬挂文档。
This commit is contained in:
1 parent
b31a758cda
commit
eed1c9d3f7
5 files changed
+99
-51
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, fill);
|
||||
let ink = content_color(ui, forced, content, fill, variant.disabled_content());
|
||||
|
||||
let label = text(spec.label)
|
||||
.size(ui.style(TypeRole::LabelLarge).size_px)
|
||||
@@ -132,19 +132,25 @@ pub(super) fn assemble<'a, M: Clone + 'a>(
|
||||
///
|
||||
/// 单独成函数是为了让「内容色跟态走」这件事只有一处实现——`assemble`(文字按钮)与 `icon`
|
||||
/// (图标按钮)都调它,两条路径不会再各自钉死满档色。
|
||||
/// 内容色:**禁用时的角色由调用方按变体给**([`super::Variant::disabled_content`] /
|
||||
/// [`super::IconVariant::disabled_content`])——A1 里 FilledTonal 与 IconButton 是 `OnSurface`,
|
||||
/// 其余是 `OnSurfaceVariant`,不能在这里统一写死。
|
||||
pub(super) fn content_color(
|
||||
ui: &Ui,
|
||||
forced: Option<Interaction>,
|
||||
content: Role,
|
||||
fill: Option<Role>,
|
||||
disabled_content: Role,
|
||||
) -> iced::Color {
|
||||
match forced {
|
||||
// 有容器:38% 叠在**12% 容器**上(Filled / Tonal / Elevated)
|
||||
Some(Interaction::Disabled) if fill.is_some() => {
|
||||
interaction::disabled_colors(ui, Role::Surface).1
|
||||
interaction::disabled_content_over_role(ui, disabled_content, true)
|
||||
}
|
||||
// 无容器:38% 直接叠在 **surface** 上(Text / Outlined / standard IconButton)
|
||||
Some(Interaction::Disabled) => interaction::disabled_content_over(ui, Role::Surface),
|
||||
Some(Interaction::Disabled) => {
|
||||
interaction::disabled_content_over_role(ui, disabled_content, false)
|
||||
}
|
||||
_ => ui.color(content),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,22 @@ impl Variant {
|
||||
self.component().spec().shape
|
||||
}
|
||||
|
||||
/// **禁用态的内容角色**(A1,逐变体不同——别在这里统一猜)。
|
||||
///
|
||||
/// | 变体 | 禁用内容 |
|
||||
/// |---|---|
|
||||
/// | Filled / Elevated / Outlined / Text | `OnSurfaceVariant` @0.38 |
|
||||
/// | **FilledTonal** | **`OnSurface` @0.38** ← A1 的显式例外(`FilledTonalButtonTokens`) |
|
||||
///
|
||||
/// 出处:AAR `material3-android:1.4.0` 的 `javap -c`,`FilledButtonTokens.
|
||||
/// DisabledLabelTextColor = OnSurfaceVariant`、`FilledTonalButtonTokens` 同一字段 = `OnSurface`。
|
||||
pub(crate) const fn disabled_content(self) -> Role {
|
||||
match self {
|
||||
Variant::Tonal => Role::OnSurface,
|
||||
_ => Role::OnSurfaceVariant,
|
||||
}
|
||||
}
|
||||
|
||||
/// 高程:只有 Elevated 是 L1(`ElevatedButtonTokens.ContainerElevation`),其余 L0。
|
||||
///
|
||||
/// **不画阴影**:rubric §7「L0/L1 不应有可见阴影(用 tone 差)」,所以 L1 只体现为
|
||||
@@ -172,6 +188,12 @@ impl IconVariant {
|
||||
}
|
||||
}
|
||||
|
||||
/// **禁用态图标色**:三式都是 `OnSurface` @0.38 —— A1
|
||||
/// (`StandardIconButtonTokens.DisabledColor` / `FilledIconButtonTokens.DisabledColor`)。
|
||||
pub(crate) const fn disabled_content(self) -> Role {
|
||||
Role::OnSurface
|
||||
}
|
||||
|
||||
/// 色彩角色三元组(同 [`Variant::roles`] 的口径)。
|
||||
pub(crate) const fn roles(self) -> (Option<Role>, Role, Option<Role>) {
|
||||
match self {
|
||||
@@ -295,7 +317,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, fill);
|
||||
let glyph = assemble::content_color(ui, forced, content, fill, variant.disabled_content());
|
||||
let icon_box =
|
||||
layout::centered_fixed(geometry.side, geometry.side, icons::view::<M>(kind, glyph));
|
||||
|
||||
|
||||
Reference in new issue
Block a user