Skip to content

refactor: move Checkbox onto the shared control core - #86

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

AdamMusa merged 3 commits into
codex/engine-initializationfrom
refactor/checkbox-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), also stacked on #81.

What

Item 2 of the decoupling plan: Checkbox moves onto the shared core. Exactly two commits:

  1. test: snapshot Checkbox renderer behaviour: JSON snapshots of the legacy renderers (test/widgets/checkbox_snapshot_test.dart, test/snapshots/Checkbox/*.json, 11 fixtures x iOS/Android: defaults, unlabeled, tristate cycle, maximal, sized, disabled, child-control label, RTL, nested theme, toggle_inputs tile, disabled in tile).
  2. refactor: move Checkbox onto the shared control core: the migration. Snapshots change only for the rows of the parity table below.

Design

File Now
controls/checkbox_core.dart (new) checkboxSpec (every Ruby keyword of the Checkbox wire type; error, hover_color, overlay_color, splash_radius, visual_density Material-only with reasons), CheckboxProps, CheckboxCore (FocusableCore + TileToggleCore): the tristate cycle (null -> false -> true -> null), value commits (writeBack then change), label and tile toggling (ignored while disabled), shared states, labelled() (one ToggleLabel, full-width row as before, spacing with each design's native default) and the width/height scale-to-fit.
controls/checkbox.dart MaterialCheckboxSkin -> Checkbox (visual_density via the pure parseVisualDensity).
controls/cupertino_checkbox.dart CupertinoCheckboxSkin -> CupertinoCheckbox.
controls/adaptive_checkbox.dart Same class/file: CoreHost<CheckboxCore> under the legacy key, skins in PlatformControlRenderer closures.

width/height are sharedLayoutKeys (#81), as for Switch. Registry, control_type.dart and the renderer matrix are untouched. Manifest: one entry; checkbox.dart/cupertino_checkbox.dart leave legacy_renderers.txt; cupertino_control_independence_test.dart mounts AdaptiveCheckboxControl (assertions unchanged, passing).

Parity changes (DC-5)

# Platform Before After Ruby impact Snapshot rows
1 Android disabled checkbox toggled from a toggle_inputs ListTile ignores tile taps (iOS behaviour) no change from disabled checkboxes list_tile_disabled.android
2 Android spacing ignored (Cupertino only) honored; default gap stays 0 (iOS keeps its native 10) checkbox(spacing:) works on Android not visible (label-first fixture); ruby_checkbox_keys_test.dart
3 both page.invoke(checkbox, "focus") waited for the invoke timeout fails fast with #59's UnsupportedError text error returned immediately defaults invoke focus

Everything else (payloads, geometry, tristate cycle, semantics, label styling, control labels, scale-to-fit) is unchanged on both designs, as the unchanged snapshots show. The audit's 2 baseline Checkbox findings (on_focus/on_blur not fired) are fixed.

Tests

  • Snapshot test: 22 tests (commit 1 against legacy, commit 2 updated per the table).
  • test/widgets/ruby_checkbox_keys_test.dart (2): spacing and the per-design default gap.
  • Contract test entry for Checkbox: C1–C7 (58 Ruby keywords; lifecycle incl. in-place replacement; every key parsed; identical events, write-backs and semantics on iOS and Android through the tristate cycle).

team/verify_pr.sh on head 9491fb3 (base 81609d0 + #81 @ 02c2d4b) with ruflet origin/main (b5fd1694): PASS: engine flutter test +982 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, label_position, spacing, width and height 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 (Checkbox/CupertinoCheckbox). 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: change (native tap through the tristate cycle), focus and blur.
  • 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_checkbox.dart, checkbox.dart or cupertino_checkbox.dart (checked before starting and before opening). cupertino_control_independence_test.dart and core_manifest.dart are also edited by sibling #84 (adjacent lines): keep both when merging the second.

Record the legacy Checkbox renderers on iOS and Android as JSON snapshots:
geometry, semantics, what they send to Ruby during scripted taps, label taps,
the tristate cycle, keyboard focus and ListTile toggling, and invoke
outcomes, for the defaults, unlabeled, tristate, maximal, sized, 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.
CheckboxCore now owns everything Ruby sends or receives for a Checkbox: one
parse of every keyword (checkboxSpec), the tristate cycle, value commits, the
label, toggle_inputs tile taps, focus and the width/height scale-to-fit. The
Material and Cupertino skins only map the core's values onto Checkbox and
CupertinoCheckbox, and AdaptiveCheckboxControl hosts the core under the
legacy key.

Material now honors spacing (its default gap stays 0, Cupertino's 10), and a
disabled checkbox on Android ignores tile taps like it already did on iOS.
Snapshots change only for those rows.
Brings in the PRs merged since, so #86 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