Skip to content

refactor: move the IconButton family onto the shared control core - #91

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

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

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Depends on #90 (Button family), then #88 (entry-shape rule + wireType/parentWireType/parentSlot), then #81. The legacy CupertinoButtonControl this PR converts was shared with the legacy Button until #90. Until those merge, this PR's diff also shows their commits; review the last two.

What

Item 5 of the decoupling plan: the four IconButton wire types (IconButton, FilledIconButton, FilledTonalIconButton, OutlinedIconButton) move onto the shared core. Exactly two own commits:

  1. test: snapshot IconButton renderer behaviour: JSON snapshots of the legacy renderers (test/widgets/icon_button_snapshot_test.dart, test/snapshots/IconButton/*.json). There are 8 fixtures × iOS/Android:
    • each wire type's defaults, scripted as semantics tap, pointer tap, long press, mouse hover in/out, Tab, invoke focus, invoke blur;
    • selected (with selected_icon and selected_icon_color), disabled (with disabled_color), maximal (every key plus a style map);
    • an AppBar's leading back arrow.
  2. refactor: move the IconButton family onto the shared control core: the migration. Snapshots change only per the parity table below.

Design

File Now
controls/icon_button_core.dart (new) One const spec per wire type (Ruby declares the same keys on all four). IconButtonProps and a single IconButtonCore (FocusableCore), which picks its spec and variant from wireType. It owns: click (with url); long press; hover and pressed state (one MouseRegion + Listener, the same as Button); the selected state; focus; the focus/blur methods; isAppBarLeading (parentWireType == 'AppBar' && parentSlot == 'leading', #88).
controls/material_icon_button.dart MaterialIconButtonSkin -> IconButton / .filled / .filledTonal / .outlined.
controls/cupertino_button.dart Converted in place from the legacy CupertinoButtonControl into CupertinoIconButtonSkin, a CupertinoButton around the icon with the style map resolved against core.states. Keys IconButton does not have keep their legacy defaults (pressed opacity 0.4, radius 8, large size). The iOS back chevron for a Material back arrow in an AppBar's leading slot is unchanged.
controls/icon_button.dart Same class/file (registry untouched); canonical entry (create: IconButtonCore.new, C1e). The key is control_<wire type>_<id>.

Core-consumed: url. Material-only, with reasons: highlight_color, hover_color, splash_color, splash_radius (ink), visual_density, size_constraints. Cupertino-only: bgcolor (Material takes it through style). The manifest has four entries (native widgets IconButton / CupertinoButton), each with a parity script of tap native, long press, hover, Tab and unfocus. Both skin files leave legacy_renderers.txt, and nothing uses the legacy class any more.

Parity changes (DC-5)

# Platform Before After Ruby impact Snapshot rows
1 both page.invoke(icon_button, "blur") raised "Unknown IconButton method" blur unfocuses (blur event) blur works defaults_* invoke blur
2 iOS no enabled state for accessibility hasEnabledState/isEnabled, as on Material and as the Button family (#90) VoiceOver dims disabled icon buttons every iOS fixture's semantics
3 iOS selected_icon ignored shown while selected, as on Material toggle icon buttons work on iOS selected.ios (icon glyph)
4 iOS selected_icon_color, disabled_color, top-level enable_feedback ignored honored (icon colour while selected or disabled; haptic on press) colours and haptics match the Ruby call not visible; ruby_icon_button_keys_test.dart
5 Android Ruby style ignored (only the never-sent _internals.style was read); visual_density ignored both honored styled and compact icon buttons on Android maximal.android (56 → 48 px under compact); style in the keys test
6 both no icon. Android: an ErrorControl, unless the non-Ruby content child was set, which was rendered as the icon. iOS: content, when set, was rendered as the button's child (CupertinoButtonControl's fallback); otherwise the button was empty. an empty native button on both designs; content is no longer read. content is not an IconButton keyword in Ruby, so no Ruby app sends it; the renderer matrix's default fixture was the one place that did. icon_button() without icon renders empty on both designs, as old iOS did; no Ruby call can set content not in the snapshots (renderer matrix)
7 both unknown methods raised Exception(...) #59's UnsupportedError text error text only —

Unchanged on both designs (identical snapshots): geometry (except row 5), click/long-press/hover/focus payloads, disabled behaviour, the iOS AppBar back chevron and the maximal style rendering on iOS. The audit's 12 baseline findings (on_focus/on_blur not fired and visual_density not read, on all four types) are fixed.

Tests

  • Snapshot test: 16 (commit 1 against legacy, commit 2 updated per the table).
  • test/widgets/ruby_icon_button_keys_test.dart (3): Android style, iOS selected_icon_color, iOS disabled_color.
  • Existing native_back_icon_test.dart, button_platform_size_test.dart and the renderer matrix pass unchanged.
  • Contract test, 4 entries: C1, C1e, C2/C2b, C3 (62 Ruby keywords), C4, C5, C6, C7.

team/verify_pr.sh on head 968d610 (on #90 f7a7e8f) with ruflet origin/main 43928509: PASS: engine flutter test +1109 all passed, flutter analyze lib test no issues, ruflet_core 157/157 files, wire-key audit 0 new findings, 12 fixed.

Gate

No open PR touches icon_button.dart, material_icon_button.dart or cupertino_button.dart; checked before starting and before opening.

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.
Brings in the PRs merged since, so #91 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