Skip to content

refactor: move ListTile onto the shared control core - #95

Merged
AdamMusa merged 13 commits into
codex/engine-initializationfrom
refactor/list-tile-control-core
Nov 2, 2026
Merged

AdamMusa merged 13 commits into
codex/engine-initializationfrom
refactor/list-tile-control-core

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Depends on #94 (ProgressRing, which stacks on #91 → #90 → #88 → #81) and on #89 (Ruby surface refresh). C3 needs #89's copy of the Ruby surface, which has ListTile's chevron; #89 is a sibling of the stack, so this branch merges its unchanged commit 8863398 (Merge chore/refresh-ruby-surface into refactor/list-tile-control-core, no content of its own; #89 only touches test/contract/ruflet_control_surface.json, which nothing else in the stack changes). Until those merge, this PR's diff also shows their commits; review the last two.

What

Item 10 of the decoupling plan: ListTile (DSL names list_tile and cupertino_list_tile) moves onto the shared core. Exactly two own commits after the stacking merge:

  1. test: snapshot ListTile renderer behaviour: JSON snapshots of the legacy renderers (test/widgets/list_tile_snapshot_test.dart, test/snapshots/ListTile/*.json), 14 fixtures × iOS/Android: defaults (pointer tap, long press, semantics tap, Tab, invoke focus, unfocus), every slot as text/icon (full, with additional_info, chevron, bgcolor), every slot as a child control, chevron alone, a tile without a title, disabled, toggle_inputs driving a trailing Switch and a leading Checkbox, padding (the cupertino_list_tile keyword) and content_padding, selected, the Material-only keys, the Cupertino-only keys and the layout keywords.
  2. refactor: move ListTile onto the shared control core: the migration. Snapshots change only per the parity table below.

Design

File Now
controls/list_tile_core.dart (new) listTileSpec, ListTileProps, ListTileCore. The core owns what a tap does, composed once for both designs: toggle the inputs of a toggle_inputs tile (one ListTileClickNotifier for the core's lifetime instead of a new one per skin build), open url, fire click; it is null while disabled or when a tap would do nothing. It also owns long_press, the padding (content_padding, or Ruby's cupertino_list_tile(padding:)) and the trailing chevron composition (trailingWithChevron(glyph): same 6 px gap on both designs, each skin passes its native glyph).
controls/list_tile.dart MaterialListTileSkin → ListTile on a transparent Material.
controls/cupertino_list_tile.dart CupertinoListTileSkin → the forked RufletCupertinoListTile (base or notched), wrapped in the same Semantics(button, selected, enabled) the Material ListTile builds for itself. A tile without a title renders an empty title.
controls/adaptive_list_tile.dart Same class/file (registry untouched); canonical entry (create: ListTileCore.new, C1e).

Core-consumed: trailing + chevron (composition), content_padding + padding (one padding), toggle_inputs, url. Both skins: title, subtitle, leading, bgcolor, selected (iOS: accessibility state only). Cupertino-only, with reasons: additional_info, bgcolor_activated, notched, leading_size, leading_to_title. Material-only, with reasons: autofocus, dense, is_three_line, horizontal_spacing, min_leading_width, min_vertical_padding, min_height, visual_density, style, title_alignment, shape, icon_color, text_color, selected_color, selected_tile_color, focus_color, hover_color, splash_color, enable_feedback, mouse_cursor and the three text styles. Events click (onTap) and long_press (onLongPress) are skin-sourced and wired by both skins (C4). Both skin files leave legacy_renderers.txt.

The legacy Material tile also fired focus/blur from onFocusChange. Ruby declares neither on_focus nor on_blur for ListTile (they are not in its KEYWORDS, so the backend never sent them), so the core does not declare them; nothing Ruby can observe changes.

Manifest entry: title + subtitle + leading icon, native widgets ListTile / RufletCupertinoListTile, parity script tap native, long press, unfocus.

Three existing tests (ruby_list_tile_chevron_test.dart, ruby_list_tile_events_test.dart, ruby_list_section_test.dart) found the tile by the legacy class names; they now use the skin class names, nothing else changed.

Parity changes (DC-5)

# Platform Before After Ruby impact Snapshot rows
1 both padding (the cupertino_list_tile keyword) ignored: Dart read only content_padding padding is the tile padding when content_padding is not sent cupertino_list_tile(padding: 30) pads on both designs padding.android, padding.ios (geometry)
2 iOS no button, enabled or selected state for accessibility (the label node was only the title text) Semantics(button, selected, enabled) around the tile, as the Material ListTile builds; the node covers the tile VoiceOver announces buttons, dimmed and selected tiles as TalkBack does every iOS fixture's semantics
3 iOS no title: an ErrorControl ("CupertinoListTile.title must be provided and visible") the tile renders with an empty title (Material already did) list_tile(leading:, subtitle:) renders and taps on iOS no_title.ios
4 both invoke on a ListTile waited for the timeout (no listener) fails fast with #59's UnsupportedError text error instead of a timeout defaults.* invoke focus
5 both a number sent as title/subtitle/additional_info was dropped (iOS: the title error) rendered as text (the core's textOrWidget) numbers display not in the snapshots

Unchanged on both designs (identical snapshots): all geometry except rows 1 and 3, click/long-press payloads, disabled behaviour, toggle_inputs driving the Switch and Checkbox, the chevron, child-control slots, the Material-only and Cupertino-only keys, Android semantics.

Tests

  • Snapshot test: 28 (commit 1 against legacy, commit 2 updated per the table).
  • Existing ListTile tests (ruby_list_tile_chevron_test.dart, ruby_list_tile_events_test.dart, ruby_list_tile_geometry_test.dart, ruby_list_section_test.dart) pass with only the class-name update.
  • Contract test, new entry: C1, C1e, C2/C2b, C3 (Ruby's 41 non-layout keywords, incl. chevron from chore: refresh the checked-in Ruby control surface #89), C4, C5, C6, C7 (native tap and long press on both designs, same semantics).

team/verify_pr.sh on head 2d77068 with ruflet 43928509 (the tree #81–#91 were verified with): PASS: engine flutter test +1186 all passed, flutter analyze lib test no issues, ruflet_core 157/157 files, wire-key audit 0 new; the one ListTile finding (prop_not_read padding) is fixed.

Gate

No open PR touches adaptive_list_tile.dart, list_tile.dart, cupertino_list_tile.dart, ruflet_cupertino_list_tile.dart, list_tile_clicks.dart or the ListTile tests; #84/#86/#87 only touch their own test/snapshots/{Switch,Checkbox,Radio}/list_tile*.json. Checked before starting and before opening. core_manifest.dart / legacy_renderers.txt: adjacent-line conflicts with #84/#86/#87 and developer 1's SegmentedButton/picker PRs; keep both sides, entries alphabetical.

Add the shared control kernel every control will migrate onto: a pure-data
ControlSpec, PropReader as the only reader of wire keys, ControlEvents as the
only event dispatcher, ControlCore/FocusableCore for client state and focus,
and CoreHost as the single owner of a control's invoke listener and layout
keywords (re-bound when Ruby replaces the control in place). ToggleLabel,
TileToggleCore, CoreSemantics, RawProp and TextOrWidget are the neutral
pieces the first migrations share.

The control-core contract test checks every migrated control against rules
C1-C8 (skin isolation, core purity, spec equals Ruby KEYWORDS, skin
consumption, lifecycle, completeness, event and semantics parity, and a
report-only legacy ratchet). The manifest starts empty; the runtime rules run
against a test-only probe core and the static rules against adversarial
fixtures. The JSON snapshot harness and the Ruby control surface copy (with
tool/sync_ruby_surface.rb) support the migration PRs.
Regenerate test/contract/ruflet_control_surface.json from ruflet main
43928509 with tools/control_surface.rb (ruflet #59). It now includes the
keywords merged since the first copy, among them ListTile chevron (ruflet #38)
and TextField text_input_action (ruflet #30), and the controls added since
(CarouselView, DraggableScrollableSheet, FittedBox, FormRow, IndexedStack,
ListSection, Table, TableRow).
Registry entries map several wire types to one host (the five Button types
all build AdaptiveButtonControl), and the entry-shape rule keeps entries from
reading the Control. Give ControlCore protected, read-only accessors for its
canonical wire type, its parent's, and the parent property that holds it, so
a core can choose its spec and rendering itself (a Button inside an
AlertDialog, an IconButton in an AppBar's leading slot) while its constructor
stays a plain super.control.
Add contract rule C1e for the registry entry, the one place outside the
kernel that holds the Control: CoreHost(create:) must be a constructor
tear-off, each PlatformControlRenderer closure builds its skin with only
core: (the builder's core) and key:, choosing between skins only on the
core, and control appears only as CoreHost(control:), inside the host key and
in debugPrint. C2b now also bans public mutable fields and setters on cores,
and C1 covers helper skin libraries.

QA's evasions N1 (an entry injects wire data into a core field) and N4 (an
entry passes a raw wire value to a skin) are negative fixtures; the three
approved entries (Switch, Checkbox, Radio) are positive fixtures, verbatim.
Record the legacy renderers of the five Button wire types (Button,
FilledButton, FilledTonalButton, OutlinedButton, TextButton) on iOS and
Android as JSON snapshots: geometry, semantics, what they send to Ruby during
semantics taps, label taps, long presses, mouse hover and keyboard focus, and
invoke outcomes, plus icon, outlined-icon, maximal, disabled and AlertDialog
action fixtures. The migration onto the shared control core may change them
only as listed in its parity table.
ButtonCore now owns everything Ruby sends or receives for the Button,
FilledButton, FilledTonalButton, OutlinedButton and TextButton wire types:
one spec per wire type (it picks its spec and variant from its wire type),
click with url, long press, hover and pressed state, focus and the
focus/blur methods. The Material skin maps the core onto the five Material
buttons; the Cupertino skins render CupertinoButton (plain, filled, tinted),
or CupertinoDialogAction for a Button inside an AlertDialog. The registry
entry has the canonical shape (create: ButtonCore.new). The legacy
CupertinoButtonControl stays for the IconButton family until it migrates.

Both designs now answer the blur method, iOS buttons report their enabled
state to accessibility, Android OutlinedButton.icon fires hover, and an iOS
alert-dialog action honors the layout keywords. Snapshots change only for
those rows.
Record the legacy renderers of the four IconButton wire types (IconButton,
FilledIconButton, FilledTonalIconButton, OutlinedIconButton) on iOS and
Android as JSON snapshots: geometry, semantics, what they send to Ruby during
semantics taps, pointer taps, long presses, mouse hover and keyboard focus,
and invoke outcomes, plus selected, disabled, maximal and AppBar leading back
fixtures. The migration onto the shared control core may change them only as
listed in its parity table.
IconButtonCore now owns everything Ruby sends or receives for the IconButton,
FilledIconButton, FilledTonalIconButton and OutlinedIconButton wire types:
one spec per wire type (picked from its wire type), click with url, long
press, hover and pressed state, the selected state, focus and the
focus/blur methods, and whether it is an AppBar's leading button (the iOS
back chevron). The Material skin maps the core onto IconButton and its
variants; the Cupertino skin (the former legacy CupertinoButtonControl)
renders CupertinoButton from core values. The registry entry has the
canonical shape (create: IconButtonCore.new).

Both designs now answer the blur method; iOS reports the enabled state to
accessibility and honors selected_icon, selected_icon_color, disabled_color
and enable_feedback; Android honors style and visual_density. Snapshots change
only for those rows.
Record the legacy ProgressRing renderers (CircularProgressIndicator on
Android, CupertinoActivityIndicator on iOS) as JSON snapshots: geometry,
semantics, the native indicator's state (value, progress, radius,
animating), what they send to Ruby during a tap and invoke outcomes.
Fixtures cover determinate, labelled, value plus progress, maximal and
layout-keyword rings, and, without settling, indeterminate, progress-only,
paused and radius rings, recording whether the indicator still spins. The
migration onto the shared control core may change them only as listed in
its parity table.
ProgressRingCore now owns everything Ruby sends for ProgressRing (the
progress_ring and cupertino_activity_indicator DSL names): one fraction for
both designs (`progress` wins over `value`, clamped to 0..1) and the
accessibility value both announce (`semantics_value`, or the determinate
percentage). The Material skin maps the core onto CircularProgressIndicator
and the Cupertino skin onto CupertinoActivityIndicator, wrapped in the same
semantics the Material ring exposes. The registry entry has the canonical
shape (create: ProgressRingCore.new).

Android now honors `progress`; iOS announces semantics_label and the
progress value to accessibility and no longer fails an assertion on an
out-of-range value. Unknown methods fail fast. Snapshots change only for
those rows.
Record the legacy ListTile renderers (Material ListTile on Android, the
forked Cupertino list tile on iOS) as JSON snapshots: geometry, semantics,
what they send to Ruby during taps, long presses, semantics taps and Tab
focus, invoke outcomes, and the toggles a `toggle_inputs` tile drives.
Fixtures cover defaults, every slot as text, icon and child control, the
chevron, a tile without a title, disabled, selected, `padding` and
`content_padding`, the Material-only and Cupertino-only keys and the layout
keywords. The migration onto the shared control core may change them only
as listed in its parity table.
ListTileCore now owns everything Ruby sends or receives for ListTile (the
list_tile and cupertino_list_tile DSL names): what a tap does (click, url
and toggling the inputs of a toggle_inputs tile, through one notifier for
the core's lifetime), long press, the padding (content_padding, or Ruby's
cupertino_list_tile padding) and the trailing chevron composition. The
Material skin maps the core onto ListTile; the Cupertino skin onto the
forked iOS list tile, reporting the same button, enabled and selected
states to accessibility. The registry entry has the canonical shape
(create: ListTileCore.new).

Both designs now honor `padding`; iOS renders a tile without a title (it
showed an error) and reports its states to accessibility. Unknown methods
fail fast. Snapshots change only for those rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant