Repository navigation
refactor: move Switch onto the shared control core - #84
Merged
AdamMusa merged 3 commits intoNov 2, 2026
Merged
Conversation
This was referenced Oct 29, 2026
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.
Record the legacy Switch renderers on iOS and Android as JSON snapshots: geometry, semantics, what they send to Ruby during scripted taps, label taps, keyboard focus and ListTile toggling, and invoke outcomes, for the defaults, unlabeled, 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.
SwitchCore now owns everything Ruby sends or receives for a Switch: one parse of every keyword (switchSpec), 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 Switch and CupertinoSwitch, and AdaptiveSwitchControl hosts the core under the legacy key. Both designs now send the new value with change, lay the label out in the same compact row, honor label_text_style, child-control labels, thumb images (either Ruby spelling), image_error, mouse_cursor and scale-to-fit, and a disabled switch ignores tile taps. Snapshots change only for those rows.
AdamMusa
force-pushed
the
refactor/switch-control-core
branch
from
October 29, 2026 01:02
35e1c98 to
8e228ef
Compare
This was referenced Oct 29, 2026
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #81 (control core foundation). Until #81 merges this PR's diff also shows its commit; review the last two commits.
What
Item 1 of the decoupling plan: Switch moves onto the shared core. Exactly two commits:
test: snapshot Switch renderer behaviour: JSON snapshots of the legacy renderers (test/widgets/switch_snapshot_test.dart,test/snapshots/Switch/*.json, 10 fixtures x iOS/Android: defaults, unlabeled, maximal, sized, disabled, child-control label, RTL, nested theme,toggle_inputstile, disabled in tile).refactor: move Switch onto the shared control core: the migration. Snapshots change only for the rows of the parity table below.Design
controls/switch_core.dart(new)switchSpec(every Ruby keyword of the Switch wire type, single-skin entries with reasons),SwitchProps(one parse per build),SwitchCore(FocusableCore+TileToggleCore): value commits (writeBackthenchangewith the new bool), label tap, tile taps (ignored while disabled), sharedstates(selected/disabled/focused),labelled()(oneToggleLabel: compact row, merged semantics, click cursor) and the width/height scale-to-fit indecorate.controls/switch.dartMaterialSwitchSkin: maps the core ontoSwitch; picks the Material disabled label colour.controls/cupertino_switch.dartCupertinoSwitchSkin: maps the core ontoCupertinoSwitch(state colours resolved withcore.states); picks the iOS disabled label colour.controls/adaptive_switch.dartCoreHost<SwitchCore>under the legacyValueKey("control_<id>"),PlatformControlRendererclosures build the skins.width/heightaresharedLayoutKeys(#81):LayoutControlstill sizes (and animates withanimate_size) exactly as before, the core scales the switch + label into that box.Not edited:
ruflet_core_extension.dart,control_type.dart,control_renderer_matrix_test.dart. Manifest: one entry intest/architecture/core_manifest.dart;switch.dartandcupertino_switch.dartleavelegacy_renderers.txt.cupertino_control_independence_test.dartnow mountsAdaptiveSwitchControl(the old Cupertino class took a Control; its assertions are unchanged and pass).Parity changes (DC-5: only toward the more complete behaviour)
changesent without datachangecarries the new boole.datawas nil on iOS, now true/false like AndroidRow()(full width; tapping empty space toggled)MainAxisSize.min)size.w, semantics/label rects in defaults, disabled, maximal, label_control, rtl, nested_themelabel_text_styleignored{value: Custom})label: text(...)works on iOSwidth/heightonly sized the boxtoggle_inputsListTilechangefrom disabled switchespage.invoke(switch, "focus")waited for the invoke timeout (no listener)UnsupportedError("Switch(<id>).focus is not supported on <platform>: no handler ...")(#59's text)invoke focusimage_errorignoredactive_thumb_image(_src),inactive_thumb_image(_src)andimage_errorhonoredruby_switch_keys_test.dart)active_thumb_image/inactive_thumb_imagespellings ignored (only*_srcread)*_srcwins)ruby_switch_keys_test.dartmouse_cursorignoredruby_switch_keys_test.dartNo capability is removed. The audit's 4 baseline Switch findings (
on_focus/on_blurnot fired,active_thumb_image/inactive_thumb_imagenot read) are fixed.Tests
test/widgets/ruby_switch_keys_test.dart(7): thumb images from both spellings on both designs, iOSmouse_cursor+label_text_style,image_errorreaches Ruby on both designs.team/verify_pr.shon head 8e228ef (base 81609d0 + #81 @ 02c2d4b) with rufletorigin/main(b5fd1694): PASS: engineflutter test+985 all passed,flutter analyze lib testno issues, ruflet_core 153/153 files. Wire-key audit: the regex audit did not know the core pattern and listed every Switch key as unread;team/audit/wire_key_audit.rbnow readsPropSpec/EventSpecliterals for migrated types (spec §4; legacy output byte-identical on #81), giving 0 new findings, 4 Switch findings fixed.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:
label,label_position,widthandheightasconsumer: 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.Controltoken or Control imports, and the constructor only forwardssuper.control.Switch/CupertinoSwitch). The parity script starts withtap native, a pointer tap on the native widget, so the skin's ownonChangedwiring is compared on both designs, and it ends withunfocus. C7 now proves the script fires every core event:change(native tap and label/semantics taps),focus(tab) andblur(unfocus).Gate
gh pr list --state openfile check before starting and before opening: no open PR touchesadaptive_switch.dart,switch.dart,cupertino_switch.dartorcupertino_control_independence_test.dart.Sibling migrations (Checkbox, Radio) are also stacked on #81 and each add one manifest entry and replace adjacent lines of
cupertino_control_independence_test.dart; merging them after this one is a keep-both resolution.