Skip to content

feat: accept renderer-supported keywords Ruby rejected - #27

Merged
AdamMusa merged 6 commits into
mainfrom
feat/expose-renderer-keywords
Oct 28, 2026
Merged

AdamMusa merged 6 commits into
mainfrom
feat/expose-renderer-keywords

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Summary

The engine already reads these wire keys, but Ruby's control KEYWORDS did not list them. So Ruflet.list_tile(title: "x", focus_color: "#f00") and the others raised ArgumentError: unknown keyword, and the renderer feature could not be reached from Ruby. This PR adds each key to the right control class and its props copying. There is one commit per control so each change can be reviewed on its own.

I opened each Dart read before adding its keyword. Ruby sends no default for any of them, so the renderer's defaults still apply.

Control (DSL) Keyword Dart read Value type and default Renders on
ListTile (list_tile) focus_color list_tile.dart:76 getColor("focus_color") color, Flutter default Material (keyboard focus highlight). The canonical list_tile contract inherits it. cupertino_list_tile is unchanged because the Cupertino tile has no focus highlight.
Chip (chip) mouse_cursor material_chip.dart:78 getMouseCursor("mouse_cursor") cursor name ("click", "forbidden", ...) Material
PageView (page_view) animation_curve, animation_duration page_view.dart:79-82 curve name in camelCase ("easeInOut", matched case-insensitively), default linear. Duration in ms or a {seconds:, milliseconds:} hash, default 1 s. These are the defaults for the go_to_page/next_page/previous_page methods. both (single renderer)
Container (container) opacity_on_click cupertino_container.dart:95 getDouble("opacity_on_click", 0.4) double, default 0.4. Used only with ink: true on an interactive container. Cupertino. Material keeps its ink splash.
RufletSpinKit (spinkit) line_width, border_width, item_count, wave_type ruflet_spinkit/lib/src/spinkit.dart:33-37 line_width double: ring/dual_ring 7.0, spinning_lines 2.0. border_width double: ripple 6.0. item_count int: wave/piano_wave 5. wave_type "start"/"end"/"center": wave, default start. both
View (view) bottom_sheet view.dart:210 buildWidget("bottom_sheet") a control both, see below

View bottom_sheet: I checked it before adding it

It is a real slot. view.dart:210 passes the built child to PlatformPageScaffold(bottomSheet:):

  • Material: material_page_scaffold.dart:94 puts it in Scaffold.bottomSheet, a persistent bottom sheet.
  • Cupertino: cupertino_page_scaffold.dart:132-136 puts it in Align(alignment: bottomCenter) above the body.

Pagelet already accepts the same bottom_sheet slot in Ruby and Dart. This slot is persistent: it renders any control, such as a container, and it is not the modal BottomSheet control. Modal sheets still go through page.show_bottom_sheet / page.bottom_sheet= (Page::DIALOG_PROP_KEYS). That routing is unchanged, so page.set_view_props(bottom_sheet: ...) still means the modal dialog. Only an explicit Ruflet.view(..., bottom_sheet: ...) gets the persistent slot.

Usage

Ruflet.list_tile(title: "Inbox", focus_color: "#E3F2FD", on_click: ->(e) {})
Ruflet.chip("Archived", mouse_cursor: "forbidden", on_click: ->(e) {})
Ruflet.page_view(pages, animation_curve: "easeInOut", animation_duration: 300)
Ruflet.container(content: Ruflet.text("Tap"), ink: true, opacity_on_click: 0.6, on_click: ->(e) {})
Ruflet.spinkit(wave: { color: "#74c0fc", item_count: 7, wave_type: "center" })
Ruflet.spinkit(ring: { line_width: 3 })
Ruflet.spinkit(ripple: { border_width: 2 })
Ruflet.view(
  [Ruflet.text("Cart")],
  route: "/cart",
  bottom_sheet: Ruflet.container(content: Ruflet.text_button("Checkout", on_click: ->(e) {}), padding: 12)
)

Tests

Each control's existing *_compatibility_test.rb gets new assertions that the key is accepted and serializes in to_patch with the right value. Each one raised ArgumentError before its commit.

  • list_tile_compatibility_test.rb: focus_color is lowercased like other colors, works through the listtile alias, and is omitted when unset.
  • chip_compatibility_test.rb: mouse_cursor accepts a string and a symbol.
  • page_view_compatibility_test.rb: curve as a string or symbol, duration as an int or hash, and no default is sent.
  • container_compatibility_test.rb: opacity_on_click together with ink/on_click, and omitted when unset.
  • spinkit_compatibility_test.rb: item_count + wave_type (wave, piano_wave), line_width (ring, dual_ring, spinning_lines), border_width (ripple), and no defaults are sent.
  • view_compatibility_test.rb: the bottom_sheet control serializes as a nested patch, and a button inside it is registered and receives click through page.dispatch_event.

verify_pr.sh "" <ruby-wt>: ruby:ruflet_core PASS, 145/145 files, 626 runs (618 baseline + 8 new).
Extra run with RUBY_PKGS="ruflet ruflet_server ruflet_rails": all PASS. ruflet 13/13 files, 160 runs. ruflet_server 11/11, 40 runs. ruflet_rails 15/15, 278 runs. Same as baseline.

Wire-key audit (wire_key_audit.rb, this branch against the engine): "Dart reads, Ruby lacks" goes from 66 to 56. All 10 keys above are gone, one near-miss is gone (View: ruby=bottom dart=bottom_sheet), and there are no new findings (prop not read 147, event not fired 71, unchanged).

QA finding: qa-baseline.md, section "Dart reads keys Ruby cannot send (missing Ruby keyword, so Ruby raises ArgumentError)".

Follow-up for the integrator: the template's tool/conformance/ruflet_control_surface.json records keywords, so it needs to be regenerated after this lands.

Related engine PRs from the same parity pass, which are independent of this one: AdamMusa/ruflet-engine#6 (Cupertino ListTile on_long_press) and AdamMusa/ruflet-engine#7 (ReorderableDragHandle layout keywords).

The Material ListTile renderer reads focus_color (list_tile.dart:76, a
color) for its keyboard-focus highlight, but the Ruby keyword list rejected it
with ArgumentError. The canonical list_tile contract inherits the keyword from
the Material class. The Cupertino tile has no focus highlight, so
cupertino_list_tile is unchanged.
The Material Chip renderer reads mouse_cursor (material_chip.dart:78, a
cursor name such as "click" parsed by parseMouseCursor), but the Ruby
keyword list rejected it with ArgumentError. The Cupertino chip does not
read it, so it only affects pointer platforms that render Material.
page_view.dart:79-82 reads animation_duration (getDuration: milliseconds as a
number, or a {seconds:, milliseconds:, ...} hash; default 1 second) and
animation_curve (a Flutter curve name such as "easeInOut", matched
case-insensitively; default linear) as the defaults for the go_to_page,
next_page and previous_page methods. The Ruby keyword list rejected both with
ArgumentError. Ruby sends no default, so the renderer's defaults apply.
The Cupertino container renderer reads opacity_on_click
(cupertino_container.dart:95, a double, default 0.4) as the pressed opacity
of an interactive container with ink: true, but the Ruby keyword list
rejected it with ArgumentError. Material containers keep their ink splash
and ignore the value.
…inKit

ruflet_spinkit's renderer (spinkit.dart:33-37) reads four variant options
that the Ruby keyword list rejected with ArgumentError:

- line_width (double): ring and dual_ring (default 7.0), spinning_lines (2.0)
- border_width (double): ripple (default 6.0)
- item_count (int): wave and piano_wave (default 5)
- wave_type ("start", "end" or "center"): wave (default "start")

Ruby sends no default, so the renderer's per-variant defaults still apply.
view.dart:210 builds the bottom_sheet child and hands it to
PlatformPageScaffold. Material places it in Scaffold.bottomSheet, and the
Cupertino scaffold pins it bottom-center above the body
(cupertino_page_scaffold.dart:132-136). Pagelet already accepts the same slot.
View rejected the keyword with ArgumentError.

This is a persistent slot that renders any control. Modal sheets still go
through page.show_bottom_sheet / page.bottom_sheet=, which are unchanged.
@AdamMusa
AdamMusa merged commit 816c862 into main Oct 28, 2026
12 checks passed
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