Expand description
阶段 4-A:Theme + Direction — 第一个 InheritedWidget 用例
设计文档 § 6 + § 19.Theme:全局视觉风格沿树向下传递。
ⓘ
ThemeWidget::new(ThemeData::dark())
.direction(Direction::Ltr)
.child(MyApp())任何后代 widget 在 state.build(ctx) 中调 ctx.depend_on::<ThemeWidget>() 或
便捷的 ctx.theme() / ctx.direction() 拿当前主题。
Re-exports§
pub use tokens::define_theme;pub use tokens::overlay;pub use tokens::ColorToken;pub use tokens::DurationToken;pub use tokens::EasingToken;pub use tokens::FocusTokens;pub use tokens::FontFamilyToken;pub use tokens::FontSizeToken;pub use tokens::FontWeightToken;pub use tokens::LengthToken;pub use tokens::RadiusTokens;pub use tokens::Shadow;pub use tokens::ShadowLayer;pub use tokens::ShadowToken;pub use tokens::SizeTokens;pub use tokens::SpacingStep;pub use tokens::TextRole;pub use tokens::TextRoleStyle;pub use tokens::ThemeDefinition;pub use tokens::TokenError;pub use tokens::TokenOverrides;pub use tokens::Tokens;pub use tokens::Value as TokenValue;pub use tokens::Variant;
Modules§
Structs§
- Avatar
Style - Avatar 样式(首字头像)。
- Button
Style - Button style defaults.
- Button
Variant Style - 单个按钮变体的五态配色。
- Button
Variants - 全部按钮变体。
- Control
Geometry - 表单控件的几何令牌(Checkbox / Radio 的指示器尺寸、描边、焦点环)。
- Control
Style - 表单控件(Checkbox / Radio / Toggle / Slider)的控件令牌,由 Astryx token 推导(见
ThemeData::from_tokens)。 - Dialog
Style - Dialog 遮罩 + 对话框样式。
- Direction
Widget - 单独的 Direction 提供者,方便只想换方向不换主题的场景。
- Dropdown
Style - Dropdown 触发器 + 弹出面板样式。
- Feedback
Style - 反馈类组件样式(进度条 / Toast 等)。
- Input
Style - TextField / 输入框样式(描边输入框 + 主色焦点环,颜色全部来自
--color-*)。 - List
Style - ListView / 列表类样式。
- Menu
Style - 菜单 / 右键 ContextMenu / 下拉列表样式。
- NavStyle
- NavigationMenu 样式。
- Scrollbar
Style - Spacing
Scale - 4pt 间距刻度 + 组件默认间距(由
--spacing-*生成)。 - TabStyle
- TabBar / TabView / TabbedPane 样式。
- Text
Style Theme - Text
Theme - Text style defaults (theme-level). Individual TextWidget can override via TextStyle.
- Theme
Data - 主题色板 + 子主题。
- Theme
Widget - Theme 提供者 widget。挂到树中,所有后代可通过
ctx.theme()访问。 - Tooltip
Style - Tooltip 浮层样式。
Enums§
- Button
Variant - 按钮语义变体(对应组件侧
ButtonType)。 - Direction
Constants§
- MGUI_
INDICATOR_ SIZE - Checkbox / Radio 指示器边长。
Functions§
- resolve_
color - 用户显式颜色优先,否则回退到主题/token 值。
- resolve_
f32 - 数值版
resolve_color:显式尺寸/宽度优先,否则用主题/回退值。