Skip to content

feat: add FormRow control for labeled form rows - #21

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/form-row
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/form-row

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Ruby counterpart: AdamMusa/ruflet#37

Adds the FormRow control (SPEC B2): an iOS form row with a leading label, an end-aligned field, and optional helper and error lines.

Ruby usage

list_section(header: "Payment") do
  form_row(text_field(border: "none", text_align: "end"), prefix: "Name")
  form_row(text_field(value: email, border: "none", text_align: "end"),
           prefix: "Email", helper: "We never share it", error: email_error)
  form_row(switch(value: true), prefix: "Save card")
end

Wire

{"_c": "FormRow", "content": {...}, "prefix": ..., "helper": ..., "error": ..., "padding": ...}. The alias CupertinoFormRow maps to FormRow in control_type.dart.

Key Cupertino (iOS/macOS) Material (Android/Windows/Linux/web)
content (control, required) CupertinoFormRow.child, end-aligned Expanded(Align(centerEnd, content))
prefix (string or control) prefix, the row label label in bodyLarge, then a 16 px gap
helper (string or control) helper below the row in bodySmall / onSurfaceVariant
error (string or control) error (SDK destructiveRed, w500) below the helper in bodySmall / colorScheme.error
padding padding (SDK default STEB 20, 6, 6, 6) outer padding (default h16 v8)

Events: none, apart from the common on_animation_end and on_size_change. The common layout keywords go through LayoutControl. If content is missing or invisible, the row renders ErrorControl("FormRow.content must be provided and visible") on both designs. Ruby already rejects a missing content.

Tests

  • test/widgets/ruby_form_row_test.dart (new, 7 tests):
    • iOS: finds CupertinoFormRow. The prefix is at x=20 (SDK padding) and the content lies right of the prefix, ends at 800-6 and is vertically centered with it. Helper and error sit below, in order. The error text color is CupertinoColors.destructiveRed. Ruby padding replaces the SDK default (label x, row top and content end all move). A missing content gives ErrorControl. The CupertinoFormRow alias renders. No Material widget is used.
    • Android: no CupertinoFormRow. The prefix is at x=16 and the row top at 8. The content starts at least 16 px after the label and ends at 800-16. Error color is colorScheme.error and helper color is onSurfaceVariant. Ruby padding applies. Without a prefix the content still ends the row. A missing content gives ErrorControl. No Cupertino widgets.
  • control_renderer_matrix_test.dart: adds a FormRow fixture with a prefix. The type renders on all 5 platforms with no exception, no ErrorControl and no opposite-design widgets.

verify_pr.sh (Flutter 3.41.2):

PASS ruby:ruflet_core                   146/146 files, 628 runs   (baseline 145/145)
PASS ruby:ruflet_rails                  15/15 files, 278 runs     (html_dsl iterates every CLASS_MAP entry)
PASS engine:ruflet flutter test         +707: All tests passed!   (baseline 695 + 7 focused + 5 matrix)
PASS engine:ruflet analyze              No issues found!
INFO wire-key audit                     NEW vs baseline: 0. FormRow: 0 props not read, 0 near misses, full Material/Cupertino prop parity

Notes

  • This pairs with ListSection (engine feat: add ListSection control for grouped lists #16 / ruflet fix: fire Ruby on_focus and on_blur on Cupertino Chip #32) for settings and checkout forms, but does not depend on it.
  • Known issue outside this PR: on iOS, text_field(border: "none") still draws the SDK's rounded border. cupertino_textfield.dart builds its decoration with defaultDecoration.copyWith(border: null), and copyWith keeps the existing border when given null. A FormRow with a text field therefore shows a boxed field on iOS until that is fixed. The fix belongs to the owner of cupertino_textfield.dart (Package C) and is reported to the lead.

Merge note

This PR and #16 (ListSection) both add lines in alphabetical order to the same spots: the adaptive_* imports in ruflet_core_extension.dart, and the Cupertino* -> canonical aliases just above "CupertinoListTile" in control_type.dart. Each merges cleanly on its own. Whichever merges second needs a one-minute rebase that keeps both lines. The Ruby PRs (#32, #37) merge cleanly together.

Render Ruby form_row as CupertinoFormRow on Apple platforms and as a
Material row elsewhere: a leading label, the field aligned to the end, and
optional helper and error lines (destructiveRed / colorScheme.error).
CupertinoFormRow is accepted as an alias.
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