diff --git a/crates/app-iced/src/components/selection/chip.rs b/crates/app-iced/src/components/selection/chip.rs index 036a797..c4a9750 100644 --- a/crates/app-iced/src/components/selection/chip.rs +++ b/crates/app-iced/src/components/selection/chip.rs @@ -56,17 +56,15 @@ impl<'a, M> Chip<'a, M> { Self::new(label, ChipVariant::Input, false, on_press) } - /// 禁用的 chip(无消息)。 - pub fn disabled(label: &'a str, variant: ChipVariant) -> Self { - Self { - label, - variant, - selected: false, - leading: None, - trailing: None, - on_press: None, - state: None, - } + /// 转成禁用:**只清消息**,图标 / 选中态 / 状态层全部保留(复审 P2-1)。 + /// + /// 官方禁用态是「容器/描边 12%、文字与**图标** 38%」——只降**不删**。早先的 + /// `Chip::disabled(label, variant)` 把 leading / trailing / selected 一起丢掉,实测 + /// assist 78→54、filter·on 74→50(连填充和勾都没了),禁用列里 `filter·on` 与 `filter` + /// 逐像素同形,看不出选中与否。 + pub fn disabled(mut self) -> Self { + self.on_press = None; + self } fn new(label: &'a str, variant: ChipVariant, selected: bool, on_press: M) -> Self { diff --git a/crates/app-iced/src/components/selection/matrix.rs b/crates/app-iced/src/components/selection/matrix.rs index d5112c8..5f44807 100644 --- a/crates/app-iced/src/components/selection/matrix.rs +++ b/crates/app-iced/src/components/selection/matrix.rs @@ -163,22 +163,21 @@ fn draw(ui: &Ui, spec: Row, state: Interaction) -> Element<'_, ()> { ChipVariant::Filter => "Filter", ChipVariant::Input => "Input", }; - let chip = if disabled { - Chip::disabled(label, variant) - } else { - match variant { - ChipVariant::Assist => Chip::assist(label, ()).leading(IconKind::Download), - // Filter 的勾只在**选中**时给(选中态才需要「已筛选」的强提示) - ChipVariant::Filter if selected => { - Chip::filter(label, true, ()).leading(IconKind::Check) - } - ChipVariant::Filter => Chip::filter(label, false, ()).leading(IconKind::Filter), - // Input chip:前置图标 + 后置关闭键(avatar 位用图标代替) - ChipVariant::Input => Chip::input(label, ()) - .leading(IconKind::Folder) - .trailing(IconKind::Close), + // 禁用**只清消息**(`Chip::disabled()` 是修饰器):图标与选中态必须保留, + // 否则禁用列里 `filter·on` 与 `filter` 会逐像素同形(复审 P2-1)。 + let chip = match variant { + ChipVariant::Assist => Chip::assist(label, ()).leading(IconKind::Download), + // Filter 的勾只在**选中**时给(选中态才需要「已筛选」的强提示) + ChipVariant::Filter if selected => { + Chip::filter(label, true, ()).leading(IconKind::Check) } + ChipVariant::Filter => Chip::filter(label, false, ()).leading(IconKind::Filter), + // Input chip:前置图标 + 后置关闭键(avatar 位用图标代替) + ChipVariant::Input => Chip::input(label, ()) + .leading(IconKind::Folder) + .trailing(IconKind::Close), }; + let chip = if disabled { chip.disabled() } else { chip }; selection::chip(ui, chip.state(state)) } }