Skip to main content

mobiler_ui/
lib.rs

1//! Mobiler's fixed UI wire ABI.
2//!
3//! These types are the **stable contract** between any Mobiler app's Rust core
4//! and the native shell. Because they never change per app, a single shell is
5//! built once and renders *any* Mobiler app — the shell only ever knows these
6//! types, never an app's domain events or widgets.
7//!
8//! - The core emits a [`Widget`] tree (the `ViewModel`).
9//! - The shell sends back an [`Action`] (the `Event`).
10//! - App domain events ride inside actions as opaque [`ActionToken`]s that the
11//!   shell round-trips without interpreting.
12//!
13//! Style is expressed as **intent tokens** (e.g. [`TextStyle`], [`Tone`]); the
14//! shell maps each to a concrete look (font, color, dp), so dark mode and theme
15//! come for free on the native side.
16
17use facet::Facet;
18use serde::{Deserialize, Serialize};
19
20/// An opaque, serialized app event (e.g. JSON of the app's domain action).
21pub type ActionToken = String;
22
23/// A value produced by an input widget at runtime.
24#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
25#[repr(C)]
26pub enum InputValue {
27    Text(String),
28    Bool(bool),
29    Int(i64),
30}
31
32/// What the shell sends back to the core. **Fixed across all apps.**
33#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
34#[repr(C)]
35pub enum Action {
36    /// An action widget (button/etc.) fired; `token` is the opaque app event.
37    Fired { token: ActionToken },
38    /// A value-carrying input changed; `id` names the widget.
39    Input { id: String, value: InputValue },
40    /// Persisted state handed back to the core on startup (empty string if none).
41    Restore { data: String },
42    /// Fired once on startup (after `Restore`) so the app can kick off initial
43    /// effects (e.g. fetching data).
44    Start,
45}
46
47// ---------------------------- style tokens ----------------------------
48
49#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
50#[repr(C)]
51pub enum TextStyle { Body, Title, Subtitle, Caption, Emphasis }
52
53#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
54#[repr(C)]
55pub enum ButtonStyle { Filled, Outlined, Text }
56
57#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
58#[repr(C)]
59pub enum CardStyle { Elevated, Outlined, Filled, Brand }
60
61/// Semantic status color (distinct from brand/identity color).
62#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
63#[repr(C)]
64pub enum Tone { Neutral, Success, Warning, Danger, Info }
65
66/// How a `Chart` draws its series.
67///
68/// **Cartesian** styles plot every series over the shared `labels` x-axis:
69/// `Bar`/`Line` (grouped bars / one polyline per series), `StackedBar` (series stack to a total
70/// per x-slot), `StackedBar100` (each x-slot fills to 100% — series as proportions).
71///
72/// **Circular** styles ignore the x-axis and the `axis` flag: `Pie`/`Donut` turn **each series**
73/// into one wedge sized by its magnitude (`Donut` leaves a center hole); `Rings` draws concentric
74/// progress arcs (Apple-Watch fitness style), one per series, swept by `sum(values) / goal`;
75/// `Gauge` draws a single arc for the first series' `value / goal` with the number in the center.
76#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
77#[repr(C)]
78pub enum ChartStyle { Bar, Line, StackedBar, StackedBar100, Pie, Donut, Rings, Gauge }
79
80/// One named data series in a [`Widget::Chart`]. Cartesian styles plot `values` across the chart's
81/// x-axis `labels`; circular styles (pie/donut/rings/gauge) collapse the series to a single
82/// magnitude (`values` summed). `color` overrides the auto-assigned palette slot; `goal` is the
83/// denominator for `Rings`/`Gauge` progress (ignored by the other styles).
84#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
85#[repr(C)]
86pub struct ChartSeries {
87    pub name: String,
88    pub values: Vec<f32>,
89    pub color: Option<Rgb>,
90    pub goal: Option<f32>,
91}
92
93impl ChartSeries {
94    /// A named series carrying `values`. Color falls back to the chart palette; no goal.
95    #[must_use]
96    pub fn new(name: impl Into<String>, values: Vec<f32>) -> Self {
97        Self { name: name.into(), values, color: None, goal: None }
98    }
99    /// Override the auto-assigned palette color for this series.
100    #[must_use]
101    pub fn with_color(mut self, color: Rgb) -> Self {
102        self.color = Some(color);
103        self
104    }
105    /// Set the denominator for `Rings`/`Gauge` progress (`sum(values) / goal`). Ignored by
106    /// cartesian and pie/donut styles.
107    #[must_use]
108    pub fn with_goal(mut self, goal: f32) -> Self {
109        self.goal = Some(goal);
110        self
111    }
112}
113
114// ----------------------------- region chart -----------------------------
115//
116// A [`Widget::RegionChart`] is a variable-width stacked-region ("Marimekko" / coverage-gap)
117// chart: arbitrary colored rectangles placed in a 2-D `[0, x_max] × [0, y_max]` plane, each with
118// an in-cell label, plus horizontal reference lines, an irregular x-axis, an optional right-side
119// bracket annotation, and a legend. The app computes the geometry; the shells map domain→pixels.
120
121/// One rectangle in a [`Widget::RegionChart`], spanning `[x0, x1]` horizontally and `[y0, y1]`
122/// vertically in the chart's domain. `label` is centered inside (empty = none); `vertical` rotates
123/// it 90° for narrow columns. `color` overrides the auto-assigned palette slot.
124#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
125#[repr(C)]
126pub struct ChartRegion {
127    pub x0: f32,
128    pub x1: f32,
129    pub y0: f32,
130    pub y1: f32,
131    pub color: Option<Rgb>,
132    pub label: String,
133    pub vertical: bool,
134}
135
136/// A horizontal reference line across a [`Widget::RegionChart`] at `value`, with a right-edge
137/// `label` chip. `dashed` draws it dashed (e.g. a "max insured" ceiling) vs solid (a target).
138#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
139#[repr(C)]
140pub struct ChartRefLine {
141    pub value: f32,
142    pub label: String,
143    pub dashed: bool,
144}
145
146/// A right-side bracket annotation spanning `[y0, y1]` with a `label` note (e.g. a ceiling band).
147#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
148#[repr(C)]
149pub struct ChartBracket {
150    pub y0: f32,
151    pub y1: f32,
152    pub label: String,
153}
154
155/// An x-axis tick on a [`Widget::RegionChart`] at domain position `at`, labelled `label`. Ticks
156/// are irregular (the app places them), so shells position them by fraction, not even spacing.
157#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
158#[repr(C)]
159pub struct ChartTick {
160    pub at: f32,
161    pub label: String,
162}
163
164/// One legend entry (swatch + name) for a [`Widget::RegionChart`].
165#[derive(Facet, Serialize, Deserialize, Clone, Debug, PartialEq)]
166#[repr(C)]
167pub struct ChartLegendItem {
168    pub label: String,
169    pub color: Rgb,
170}
171
172impl ChartRegion {
173    /// A region spanning `[x0,x1] × [y0,y1]` with a centered `label` (palette color, horizontal).
174    #[must_use]
175    pub fn new(x0: f32, x1: f32, y0: f32, y1: f32, label: impl Into<String>) -> Self {
176        Self { x0, x1, y0, y1, color: None, label: label.into(), vertical: false }
177    }
178    /// Override the fill color.
179    #[must_use]
180    pub fn with_color(mut self, color: Rgb) -> Self {
181        self.color = Some(color);
182        self
183    }
184    /// Render the label rotated 90° (for tall, narrow regions).
185    #[must_use]
186    pub fn vertical(mut self) -> Self {
187        self.vertical = true;
188        self
189    }
190}
191
192impl ChartRefLine {
193    /// A solid target line at `value` with a right-edge chip.
194    #[must_use]
195    pub fn target(value: f32, label: impl Into<String>) -> Self {
196        Self { value, label: label.into(), dashed: false }
197    }
198    /// A dashed "max"/ceiling line at `value`.
199    #[must_use]
200    pub fn max(value: f32, label: impl Into<String>) -> Self {
201        Self { value, label: label.into(), dashed: true }
202    }
203}
204
205impl ChartTick {
206    #[must_use]
207    pub fn new(at: f32, label: impl Into<String>) -> Self {
208        Self { at, label: label.into() }
209    }
210}
211
212impl ChartLegendItem {
213    #[must_use]
214    pub fn new(label: impl Into<String>, color: Rgb) -> Self {
215        Self { label: label.into(), color }
216    }
217}
218
219impl ChartBracket {
220    #[must_use]
221    pub fn new(y0: f32, y1: f32, label: impl Into<String>) -> Self {
222        Self { y0, y1, label: label.into() }
223    }
224}
225
226#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
227#[repr(C)]
228pub enum Spacing { Xs, Sm, Md, Lg, Xl }
229
230/// A finite icon set (maps to Material icons / SF Symbols / web glyphs per shell).
231/// Grouped: editing, navigation/chrome, content, and domain icons.
232#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
233#[repr(C)]
234pub enum Icon {
235    // editing / status
236    Delete, Add, Edit, Close, Settings, Check, Star, Info,
237    // navigation / chrome
238    Home, Search, Menu, Filter, Back, Forward, Down, Bell, Cart, Share, Heart, HeartFilled,
239    // people / contact
240    Person, People, Phone, Mail, Calendar, Clock, MapPin,
241    // content / media
242    Camera, Photo, Play,
243    // domain
244    Scissors,
245}
246
247#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
248#[repr(C)]
249pub enum ImageShape { Square, Rounded, Circle }
250
251#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
252#[repr(C)]
253pub enum ImageRatio { Wide, Square, Tall }
254
255#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
256#[repr(C)]
257pub enum BoxAlign { TopStart, TopEnd, Center, BottomStart, BottomCenter, BottomEnd }
258
259/// Project-identity colors (distinct from semantic `Tone`). Concrete RGB decided
260/// in the render layer.
261#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
262#[repr(C)]
263pub enum ProjectColor { Indigo, Teal, Coral, Amber, Lime, Pink }
264
265// ------------------------------- theme -------------------------------
266
267/// A 24-bit RGB color. Used for a theme's brand/seed color — the one place an app
268/// supplies an arbitrary color (everything else is intent tokens).
269#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
270#[repr(C)]
271pub struct Rgb {
272    pub r: u8,
273    pub g: u8,
274    pub b: u8,
275}
276
277impl Rgb {
278    pub const fn new(r: u8, g: u8, b: u8) -> Self {
279        Self { r, g, b }
280    }
281}
282
283/// Global corner-radius scale. `Medium` ≈ the current (un-themed) look.
284#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
285#[repr(C)]
286pub enum Corner { None, Small, Medium, Large }
287
288/// Global spacing scale. `Comfortable` ≈ the current (un-themed) spacing.
289#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
290#[repr(C)]
291pub enum Density { Compact, Comfortable }
292
293/// A finite, cross-platform font family (maps to each platform's nearest system
294/// font design — no bundled font files). `System` ≈ the current look.
295#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
296#[repr(C)]
297pub enum FontFamily { System, Rounded, Serif, Monospace }
298
299/// App branding as data — the visual twin of `dark_mode`. Set on a [`Widget::Scaffold`]
300/// (`theme: None` = the framework defaults, i.e. no visual change). The shell maps these
301/// to its native theming: `seed` → the brand/primary color (Android M3 scheme / iOS tint /
302/// web `--primary`), plus a global corner, spacing, and font choice.
303#[derive(Facet, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
304#[repr(C)]
305pub struct Theme {
306    pub seed: Rgb,
307    /// Optional secondary brand color. `None` ⇒ derived from `seed`. Used for the
308    /// gradient on `CardStyle::Brand` (seed → accent) and as a secondary accent.
309    pub accent: Option<Rgb>,
310    pub corner: Corner,
311    pub density: Density,
312    pub font: FontFamily,
313}
314
315/// `Theme::default()` matches the framework's un-themed look as closely as a theme can
316/// (medium corners, comfortable spacing, system font) with a neutral indigo seed — so an
317/// app can override just the bits it cares about: `Theme { seed: brand, ..Default::default() }`.
318impl Default for Theme {
319    fn default() -> Self {
320        Theme {
321            seed: Rgb::new(0x5C, 0x6B, 0xC0), // indigo — matches the legacy default accent
322            accent: None,
323            corner: Corner::Medium,
324            density: Density::Comfortable,
325            font: FontFamily::System,
326        }
327    }
328}
329
330/// A bottom-navigation tab. `selected` marks the active one; tapping sends
331/// `on_select`. `icon` (optional) renders above the label for an icon tab bar.
332#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
333#[repr(C)]
334pub struct Tab {
335    pub label: String,
336    pub selected: bool,
337    pub on_select: ActionToken,
338    /// Optional leading icon (icon tab bar). `None` = label-only (the original look).
339    pub icon: Option<Icon>,
340}
341
342/// A floating action button anchored over the scaffold body (the raised primary action).
343#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
344#[repr(C)]
345pub struct Fab {
346    pub icon: Icon,
347    pub on_press: ActionToken,
348}
349
350/// One option in a [`Widget::Segmented`] control (mirrors [`Tab`]). `selected` marks the
351/// active segment; tapping sends `on_select`.
352#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
353#[repr(C)]
354pub struct Segment {
355    pub label: String,
356    pub selected: bool,
357    pub on_select: ActionToken,
358}
359
360/// A modal bottom sheet anchored over the scaffold body (a scrim behind, a panel rising from
361/// the bottom). Present (`Some`) ⇒ open; tapping the scrim/handle sends `on_dismiss`.
362#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
363#[repr(C)]
364pub struct Sheet {
365    pub title: String,
366    pub child: Box<Widget>,
367    pub on_dismiss: ActionToken,
368}
369
370/// One revealed action in a `SwipeAction` row (swipe to reveal, tap to fire).
371#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
372#[repr(C)]
373pub struct SwipeButton {
374    pub label: String,
375    pub tone: Tone,
376    pub on_tap: ActionToken,
377}
378
379// ------------------------------- widgets -------------------------------
380
381/// The app-agnostic widget tree the shell renders. **Fixed across all apps.**
382#[derive(Facet, Serialize, Deserialize, Clone, Debug)]
383#[repr(C)]
384pub enum Widget {
385    // Content
386    Text { content: String, style: TextStyle },
387    Image { source: String, shape: ImageShape, ratio: ImageRatio },
388    Badge { label: String, tone: Tone },
389    /// A circular avatar image with an optional colored status dot.
390    Avatar { source: String, status: Option<Tone> },
391    /// A star rating. `value` is in tenths (e.g. `48` = 4.8 of `max` stars). When `on_rate`
392    /// is set (one token per star), the stars are tappable — star *i* fires `on_rate[i]`.
393    Rating { value: u32, max: u8, on_rate: Option<Vec<ActionToken>> },
394    /// Small non-interactive colored dot — a project/identity hint.
395    ColorDot { color: ProjectColor },
396    Divider,
397    /// Progress indicator: `value` 0.0–1.0 for a determinate bar, `None` for an indeterminate spinner.
398    Progress { value: Option<f32> },
399    /// Shimmer placeholder shown while content loads.
400    Skeleton,
401    /// A data chart drawing one or more named `series` in the given `style` (see [`ChartStyle`]).
402    /// `labels` (optional) annotate the x-axis for cartesian styles. `axis` shows y gridlines +
403    /// tick values (cartesian only); `legend` shows a series swatch+name row. Non-interactive.
404    Chart { series: Vec<ChartSeries>, labels: Vec<String>, style: ChartStyle, axis: bool, legend: bool },
405    /// A variable-width stacked-region ("Marimekko" / coverage-gap) chart: `regions` are arbitrary
406    /// colored rectangles in the `[0, x_max] × [0, y_max]` plane (each with an in-cell label),
407    /// `ticks` annotate the irregular x-axis, `ref_lines` are horizontal target/max lines with
408    /// right-edge chips, `bracket` is an optional right-side range annotation, and `legend` names
409    /// the colors. The app supplies all geometry; shells map domain→pixels. Non-interactive.
410    RegionChart {
411        regions: Vec<ChartRegion>,
412        ticks: Vec<ChartTick>,
413        x_max: f32,
414        y_max: f32,
415        ref_lines: Vec<ChartRefLine>,
416        bracket: Option<ChartBracket>,
417        legend: Vec<ChartLegendItem>,
418    },
419    /// An inline month calendar. `first_weekday` is the weekday of day 1 (0=Sun..6=Sat) so the
420    /// shells render leading blanks without date math; `on_day[d-1]` fires when day `d` is tapped
421    /// (length = days in the month). `selected` highlights a day.
422    Calendar { year: u32, month: u8, first_weekday: u8, selected: Option<u8>, on_day: Vec<ActionToken> },
423    /// A list row that reveals trailing `actions` on horizontal swipe (each tappable). On web the
424    /// actions render inline as a trailing button row (no gesture).
425    SwipeAction { child: Box<Widget>, actions: Vec<SwipeButton> },
426    Spacer { size: Spacing },
427    // Layout
428    Row { children: Vec<Widget> },
429    Column { children: Vec<Widget> },
430    /// Card; tappable when `on_press` is set.
431    Card { child: Box<Widget>, style: CardStyle, on_press: Option<ActionToken> },
432    /// Z-stack: children layered back-to-front, positioned by `align`. With
433    /// `scrim`, the first child is a background image, darkened for legibility,
434    /// and the rest render on top in light content.
435    Box { children: Vec<Widget>, align: BoxAlign, scrim: bool },
436    /// Fixed 2-column grid; children flow left-to-right, top-to-bottom.
437    Grid { children: Vec<Widget> },
438    /// Horizontally scrolling row of children (a carousel / chip rail).
439    Scroller { children: Vec<Widget> },
440    // Input
441    Button { label: String, style: ButtonStyle, on_press: ActionToken },
442    IconButton { icon: Icon, on_press: ActionToken },
443    Chip { label: String, selected: bool, on_press: ActionToken },
444    TextField { id: String, placeholder: String, value: String },
445    /// A search input (leading magnifier, pill shape); emits `Input { id, Text }` like `TextField`.
446    SearchField { id: String, placeholder: String, value: String },
447    /// A single-choice segmented control — exclusive options in a pill (e.g. Men/Women/Kids).
448    Segmented { segments: Vec<Segment> },
449    Toggle { id: String, label: String, value: bool },
450    Checkbox { id: String, label: String, value: bool },
451    /// Continuous 0..=`max` slider; emits `Input { id, Int }`.
452    Slider { id: String, value: i32, max: i32 },
453    /// Numeric stepper with −/+ controls carrying their own events.
454    Stepper { value: i32, on_decrement: ActionToken, on_increment: ActionToken },
455    /// App shell: a top bar (`title` + optional `back`), a scrollable `body`,
456    /// and bottom-nav `tabs`. `dark_mode` is theme-as-data — the shell themes
457    /// the whole app from it.
458    ///
459    /// `route` + `depth` drive navigation: the shell animates the body when
460    /// `route` (the current screen's identity) changes — slide for push/pop
461    /// (direction from whether `depth` grew or shrank), crossfade for a lateral
462    /// move at the same depth — and wires the system back button to `back`.
463    Scaffold {
464        title: String,
465        body: Box<Widget>,
466        tabs: Vec<Tab>,
467        back: Option<ActionToken>,
468        dark_mode: bool,
469        /// App branding (brand color, corner, density, font). `None` = framework
470        /// defaults (no visual change) — theme-as-data, the visual twin of `dark_mode`.
471        theme: Option<Theme>,
472        /// Optional floating action button (raised primary action over the body).
473        fab: Option<Fab>,
474        /// Optional modal bottom sheet over the body (a scrim + a panel from the bottom).
475        sheet: Option<Sheet>,
476        /// Pull-to-refresh: when set, the body is pull-refreshable and fires this event on pull.
477        /// The app owns `refreshing` — set it true when the pull fires, clear it when the async
478        /// reload completes (the shell shows a spinner while it's true).
479        on_refresh: Option<ActionToken>,
480        refreshing: bool,
481        route: String,
482        depth: u32,
483    },
484}
485
486#[cfg(test)]
487mod tests {
488    use super::*;
489    use serde::Serialize;
490    use serde::de::DeserializeOwned;
491
492    // Round-trips the ABI without requiring `PartialEq` on the wire types:
493    // serialize → deserialize → re-serialize, and compare the two encodings.
494    fn round_trips<T: Serialize + DeserializeOwned>(value: &T) {
495        let a = serde_json::to_string(value).expect("serialize");
496        let back: T = serde_json::from_str(&a).expect("deserialize");
497        let b = serde_json::to_string(&back).expect("re-serialize");
498        assert_eq!(a, b);
499    }
500
501    #[test]
502    fn action_round_trips() {
503        round_trips(&Action::Start);
504        round_trips(&Action::Fired { token: "tok".to_string() });
505        round_trips(&Action::Input { id: "field".to_string(), value: InputValue::Bool(true) });
506        round_trips(&Action::Restore { data: "{}".to_string() });
507    }
508
509    #[test]
510    fn widget_round_trips() {
511        round_trips(&Widget::Text { content: "hi".to_string(), style: TextStyle::Title });
512        round_trips(&Widget::ColorDot { color: ProjectColor::Teal });
513        round_trips(&Widget::Chart {
514            series: vec![ChartSeries { name: "s".to_string(), values: vec![1.0, 2.5, 3.0], color: None, goal: None }],
515            labels: vec!["a".to_string()],
516            style: ChartStyle::Bar,
517            axis: true,
518            legend: false,
519        });
520        round_trips(&Widget::RegionChart {
521            regions: vec![ChartRegion::new(0.0, 3.0, 0.0, 80.0, "80%").vertical(),
522                          ChartRegion::new(3.0, 21.0, 0.0, 80.0, "CHF 80'000").with_color(Rgb::new(0x8E, 0xC6, 0xBA))],
523            ticks: vec![ChartTick { at: 3.0, label: "3 Mt.".to_string() }, ChartTick { at: 65.0, label: "65 J.".to_string() }],
524            x_max: 65.0,
525            y_max: 80.0,
526            ref_lines: vec![ChartRefLine { value: 80.0, label: "CHF 80'000".to_string(), dashed: false }],
527            bracket: Some(ChartBracket { y0: 60.0, y1: 80.0, label: "Ceiling".to_string() }),
528            legend: vec![ChartLegendItem { label: "Gap".to_string(), color: Rgb::new(0x5A, 0x7D, 0x9A) }],
529        });
530        round_trips(&Widget::Calendar { year: 2026, month: 6, first_weekday: 1, selected: Some(15), on_day: vec!["d1".to_string(), "d2".to_string()] });
531        round_trips(&Widget::SwipeAction { child: Box::new(Widget::Divider), actions: vec![SwipeButton { label: "Del".to_string(), tone: Tone::Danger, on_tap: "t".to_string() }] });
532        // Un-themed scaffold (theme: None) — the default, must round-trip.
533        round_trips(&Widget::Scaffold {
534            title: "T".to_string(),
535            body: Box::new(Widget::Divider),
536            tabs: vec![Tab { label: "A".to_string(), selected: true, on_select: "t".to_string(), icon: Some(Icon::Home) }],
537            back: Some("b".to_string()),
538            dark_mode: true,
539            theme: None,
540            fab: None,
541            sheet: None,
542            on_refresh: None,
543            refreshing: false,
544            route: "r".to_string(),
545            depth: 2,
546        });
547        // Themed scaffold — all four theme knobs must round-trip.
548        round_trips(&Widget::Scaffold {
549            title: "T".to_string(),
550            body: Box::new(Widget::Divider),
551            tabs: vec![],
552            back: None,
553            dark_mode: false,
554            theme: Some(Theme {
555                seed: Rgb::new(0xC8, 0x5A, 0x3C),
556                accent: Some(Rgb::new(0xE0, 0x6A, 0x2C)),
557                corner: Corner::Large,
558                density: Density::Compact,
559                font: FontFamily::Rounded,
560            }),
561            fab: Some(Fab { icon: Icon::Calendar, on_press: "f".to_string() }),
562            sheet: Some(Sheet { title: "S".to_string(), child: Box::new(Widget::Divider), on_dismiss: "d".to_string() }),
563            on_refresh: Some("r".to_string()),
564            refreshing: true,
565            route: "r".to_string(),
566            depth: 1,
567        });
568    }
569}