feat(app-iced): M76 选择类家族 —— Checkbox / Radio / Switch / Chip(15 §18/§19 + 12b §10/§13)
- selection/:geometry(令牌→像素,缺档登记 G16)/ paint(Interaction×选中×错误→角色)/ shell(48 透明外壳 + 帧内状态通道 + 勾形 SVG)/ checkbox·radio·switch·chip / matrix(12×5 状态矩阵)/ tests - gallery/selection.rs:小节 + **渲染层像素断言**(20×20 选中与未选中同尺寸 · Radio 内点 10 · Ø40 状态层是圆 · 勾形 14.8 · 短横 · 轨道 52×32 · Chip 32 · 禁用 38%),按颜色+墨迹块定位、不假设行号 - gallery/mod.rs:新增 ULL_GALLERY_SECTION 段落过滤(tower 批准,M77 零成本复用)+ 四个 helper 放宽到 pub(crate) A1 证据(本机 AAR javap):未选中 hover/focus/pressed 描边是 OnSurface(不是 OnSurfaceVariant)、 Radio 选中态 hover 仍 Primary、Checkbox SelectedDisabledIconColor=Surface、Switch hover 滑块 PrimaryContainer。
This commit is contained in:
1 parent
35345f3399
commit
b69a2cdd7f
12 files changed
+2585
-56
No files matched your search
@@ -1,37 +1,43 @@
|
||||
//! **选择类家族(桩)**:由后续 mission 填充(§18 Checkbox / §19 Radio / §10 Switch / §13 Chip)。
|
||||
//! **选择类家族**(D39 §1 的 ownership 切片):Checkbox / Radio / Switch / Chip。
|
||||
//!
|
||||
//! 本文件目前只有占位 `demo()`。**后续 mission 只写本目录内的文件,不改 `components/mod.rs`**:
|
||||
//! 家族模块已经在 `mod.rs` 里声明好,`gallery/selection.rs` 也已经在 `gallery/mod.rs` 里声明好,
|
||||
//! 所以「加组件」不需要碰任何共享文件(D39 §1 的并行地基)。
|
||||
//! | 组件 | 参考章节 | 尺寸一句话 |
|
||||
//! |---|---|---|
|
||||
//! | [`Checkbox`] | `research/15` §18 | 20×20 / 圆角 2 / 描边 2(向内收)/ 勾 12dp 方头 / Ø40 状态层 / 命中 48 |
|
||||
//! | [`Radio`] | `research/15` §19 | 外圈 20 / 环线 2 / 内点 **10**(不是 12)/ Ø40 状态层 |
|
||||
//! | [`Switch`] | `research/12b` §10 | 轨道 52×32 / 滑块 24·16 / Ø40 状态层 |
|
||||
//! | [`Chip`] | `research/12b` §13 | 高 32 / 圆角 8 / 内边距 8 / Assist·Filter·Input |
|
||||
//!
|
||||
//! 填充时请照抄按钮家族的分层:
|
||||
//! ## 分层(照抄按钮家族,审起来只需看四处)
|
||||
//!
|
||||
//! - 几何进 `selection/geometry.rs`(数值一律从 `ComponentMetrics` / `Space` / `ShapeScale` 取,
|
||||
//! 缺令牌登记 G 编号);
|
||||
//! - 状态层只能走 [`crate::app::components::interaction`](α 一处定义);
|
||||
//! - 精确尺寸用 [`crate::app::components::layout`](Q8/Q9 的解法),别手写 `.width(x)`。
|
||||
//! ```text
|
||||
//! geometry.rs 令牌 → 像素(唯一把 ComponentMetrics / Space / ShapeScale 读成数字的地方)
|
||||
//! paint.rs Interaction × 选中 × 错误 → 角色 → 颜色(唯一写角色名的地方)
|
||||
//! shell.rs button 四态 → 内部自绘样式的帧内通道 + 勾形 SVG
|
||||
//! <component>.rs 布局与装配(一行一个 Element)
|
||||
//! ```
|
||||
//!
|
||||
//! ## 纪律(D39 契约 §2 / §3)
|
||||
//!
|
||||
//! - 全部组件**对消息类型泛型**(`M: Clone`),不 import `crate::app::Message`;
|
||||
//! - hover / pressed / focus / disabled 的 α 只从 [`super::interaction`] 取(本目录零 α 字面量);
|
||||
//! - 精确尺寸只从 [`super::layout`](`centered_fixed` / `fixed`)与 `geometry` 取,不许手写;
|
||||
//! - 图标一律 `icons::view` + 固定尺寸容器(Q9),圆角按 D32 分层(微控件 2 / 容器刻度 / full)。
|
||||
|
||||
use iced::widget::{container, text};
|
||||
use iced::Element;
|
||||
mod checkbox;
|
||||
mod chip;
|
||||
mod radio;
|
||||
mod shell;
|
||||
mod switch;
|
||||
|
||||
use unlucky_design::color::Role;
|
||||
use unlucky_design::spacing::Space;
|
||||
use unlucky_design::typography::TypeRole;
|
||||
pub mod geometry;
|
||||
pub mod matrix;
|
||||
pub mod paint;
|
||||
|
||||
use crate::theme::Ui;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// 占位 demo:一句 "pending",供 `--screen=gallery` 保持五段结构完整。
|
||||
///
|
||||
/// 后续 mission 把本函数换成真组件矩阵即可(`gallery/selection.rs` 调的就是它)。
|
||||
/// 文案用 ASCII:干净 CI 上可能没有中文字体(`fonts` 只保证拉丁族名),豆腐块会污染验收图。
|
||||
pub fn demo<'a, M: 'a>(ui: &'a Ui) -> Element<'a, M> {
|
||||
let style = ui.style(TypeRole::BodySmall);
|
||||
container(
|
||||
text("selection · checkbox / radio / switch / chip — pending")
|
||||
.size(style.size_px)
|
||||
.font(ui.font_of(style))
|
||||
.color(ui.color(Role::OnSurfaceVariant)),
|
||||
)
|
||||
.padding(ui.space(Space::X2))
|
||||
.into()
|
||||
}
|
||||
pub use checkbox::{checkbox, CheckValue, Checkbox};
|
||||
pub use chip::{chip, Chip};
|
||||
pub use paint::ChipVariant;
|
||||
pub use radio::{radio, Radio};
|
||||
pub use switch::{switch, Switch};
|
||||
Reference in new issue
Block a user