Skip to content

refactor: move Radio onto the shared control core - #87

Merged
AdamMusa merged 3 commits into
codex/engine-initializationfrom
refactor/radio-control-core
Nov 2, 2026
Merged

AdamMusa merged 3 commits into
codex/engine-initializationfrom
refactor/radio-control-core

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Depends on #81 (control core foundation). Until #81 merges this PR's diff also shows its commit; review the last two commits. Sibling of #84 (Switch) and #86 (Checkbox), also stacked on #81.

What

Item 3 of the decoupling plan: Radio moves onto the shared core. Exactly two commits:

  1. test: snapshot Radio renderer behaviour: JSON snapshots of the legacy renderers (test/widgets/radio_snapshot_test.dart, test/snapshots/Radio/*.json, 9 fixtures x iOS/Android, each inside a RadioGroup: defaults, unlabeled, maximal, disabled, child-control label, RTL, nested theme, toggle_inputs tile, disabled in tile). Messages from the radio and its group are recorded.
  2. refactor: move Radio onto the shared control core: the migration. Snapshots change only for the rows of the parity table below.

Design

File Now
controls/radio_core.dart (new) radioSpec (every Ruby keyword of the Radio wire type; hover_color, overlay_color, splash_radius, visual_density Material-only, inactive_color, use_checkmark_style Cupertino-only, with reasons), RadioProps, RadioCore (FocusableCore + TileToggleCore): RadioGroup lookup, label and tile selection (ignored while disabled), shared states (selected/disabled/focused), labelled() (one ToggleLabel, full-width row as before) and the "must be enclosed within RadioGroup" error for both designs.
controls/radio.dart MaterialRadioSkin -> Radio<String> (now with enabled: core.enabled).
controls/cupertino_radio.dart CupertinoRadioSkin -> CupertinoRadio<String> (fill_color resolved with core.states, native primary colour as the active default).
controls/adaptive_radio.dart Same class/file: CoreHost<RadioCore> under the legacy key.

The RadioGroup still owns the value and fires change; radio_group.dart is not edited (#60 touches it). Registry, control_type.dart and the renderer matrix are untouched. Manifest: one entry; radio.dart/cupertino_radio.dart leave legacy_renderers.txt; cupertino_control_independence_test.dart mounts AdaptiveRadioControl (assertions unchanged, passing).

Parity changes (DC-5)

# Platform Before After Ruby impact Snapshot rows
1 Android disabled on the Radio itself (group enabled) left the native radio selectable and announced as enabled the radio is disabled (iOS behaviour): no selection, semantics not enabled, no tap action no group change from a disabled radio disabled.android, list_tile_disabled.android
2 both a child-control label rendered its map as text ({value: Custom}) the control is rendered and toggles label: text(...) works label_control
3 iOS toggle_inputs ListTile taps ignored (no subscription) the tile selects the radio (Android behaviour) group change on iOS tile taps list_tile.ios
4 iOS label_style ignored honored (disabled colour still applied) styled labels on iOS maximal (label 18 px)
5 iOS fill_color read as a plain colour (state maps dropped) state maps resolved with selected/disabled/focused fill_color: {selected: ...} works on iOS not visible; ruby_radio_keys_test.dart
6 both page.invoke(radio, "focus") waited for the invoke timeout fails fast with #59's UnsupportedError text error returned immediately defaults invoke focus
7 iOS missing-group error said "CupertinoRadio must be enclosed within RadioGroup" "Radio must be enclosed within RadioGroup" (Android wording) message text only none

The unlabeled fixture is driven with a pointer tap: without a label Flutter merges a radio's semantics into the page node on both designs, so no radio-scoped node exists to act on (unchanged by this PR). The audit's baseline Radio findings (on_focus/on_blur not fired) are fixed.

Tests

  • Snapshot test: 18 tests (commit 1 against legacy, commit 2 updated per the table).
  • test/widgets/ruby_radio_keys_test.dart (2): iOS fill_color state map; Android disabled inside an enabled group.
  • Contract test entry for Radio: C1–C7 (53 Ruby keywords; lifecycle incl. in-place replacement; every key parsed; identical events, write-backs and semantics on iOS and Android).

team/verify_pr.sh on head ffd00a3 (base 81609d0 + #81 @ 02c2d4b) with ruflet origin/main (b5fd1694): PASS: engine flutter test +978 all passed, flutter analyze lib test no issues, ruflet_core 153/153 files, wire-key audit (spec-aware, see #84) 0 new findings.

Round 2 (rebased onto #81 @ 02c2d4b after QA review)

Still exactly two own commits. The snapshot commit is unchanged in content and still passes against the legacy renderer on the new #81. In the migration commit:

  • (A) The spec now declares label and label_position as consumer: PropConsumer.core. Every other prop must be referenced by each skin it lists, so the core mentioning a field no longer excuses a skin. C4 passes under the stricter rule.
  • (B) The core passes C2b: no Control token or Control imports, and the constructor only forwards super.control.
  • (D)/(F) The manifest declares the native widgets (Radio<String>/CupertinoRadio<String>). The parity script starts with tap native, a pointer tap on the native widget, so the skin's own onChanged wiring is compared on both designs, and it ends with unfocus. C7 now proves the script fires every core event: focus and blur (selection is the group's change, recorded too).
  • QA's twelve mutations, re-run on the rebased Switch tree, all fail (M4 C4, M8 C2b, M12 C7).
  • No parity rows changed; the snapshots are identical to round 1.

Gate

No open PR touches adaptive_radio.dart, radio.dart or cupertino_radio.dart (checked before starting and before opening); radio_group.dart (#60) is not edited. cupertino_control_independence_test.dart, core_manifest.dart and legacy_renderers.txt are also edited by siblings #84/#86 (adjacent lines): keep both when merging.

Record the legacy Radio renderers on iOS and Android as JSON snapshots:
geometry, semantics, what the radio and its RadioGroup send to Ruby during
scripted taps, label taps, keyboard focus and ListTile toggling, and invoke
outcomes, for the defaults, unlabeled, maximal, disabled, child-control
label, RTL, nested-theme and toggle_inputs tile fixtures. The migration onto
the shared control core may change them only as listed in its parity table.
RadioCore now owns everything Ruby sends or receives for a Radio: one parse
of every keyword (radioSpec), its RadioGroup lookup, label and toggle_inputs
tile selection, focus and the must-be-in-a-RadioGroup rule. The Material and
Cupertino skins only map the core's values onto Radio and CupertinoRadio,
and AdaptiveRadioControl hosts the core under the legacy key. The group still
owns the value and the change event (radio_group.dart is untouched).

Both designs now render child-control labels, iOS honors label_style,
fill_color state maps and toggle_inputs tiles, and Android honors disabled
on the radio itself. Snapshots change only for those rows.
Brings in the PRs merged since, so #87 merges; conflicts take the resolution tested on the full merge of the open PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
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.

2 participants