Skip to content

feat: add ListSection control for grouped lists - #16

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

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/list-section

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Ruby counterpart: AdamMusa/ruflet#32

Adds the ListSection control (SPEC B1, P0): iOS-style grouped and inset-grouped lists, with a Material equivalent.

Ruby usage

page.bgcolor = "systemGroupedBackground"
page.add(
  list_section(header: "Account", footer: "Signed in as #{user.email}") do
    list_tile(title: "Profile", leading: icon("person"), on_click: ->(_e) { page.go("/profile") })
    list_tile(title: "Notifications", trailing: switch(value: true), toggle_inputs: true)
  end
)

Wire

{"_c": "ListSection", "controls": [...], ...}. Aliases: CupertinoListSection and CupertinoFormSection map to ListSection in control_type.dart.

Key Cupertino (iOS/macOS) Material (Android/Windows/Linux/web)
controls children rows in a stretched column inside the card
header, footer (string or control) SDK header / footer titleSmall in primary with padding (16,16,16,8) / bodySmall in onSurfaceVariant with padding (16,8,16,0)
variant insetGrouped (default) or base; inset_grouped is also accepted CupertinoListSection.insetGrouped / CupertinoListSection rounded card inset 16 / full-bleed square card
rows_bgcolor rows decoration color (SDK default secondarySystemGroupedBackground) card color (default surfaceContainerLow)
bgcolor backgroundColor (default systemGroupedBackground) ColoredBox behind the section (default none)
separator_color separatorColor Divider.color
has_leading (default true) separator start 20 + 44 / 20 divider indent 16 + 56 / 16
divider_margin, additional_divider_margin dividerMargin + additionalDividerMargin (separator start) divider indent = divider_margin + additional_divider_margin
top_margin base: topMargin (default 22). insetGrouped: space above the section, see below extra top padding
border_radius rows decoration radius (default 10), with the edge rows clipped to it card radius (default 12 inset, 0 base)
clip_behavior clipBehavior (default hardEdge inset, none base) Material.clipBehavior (default antiAlias inset, none base)
margin (common) SDK rows margin. LayoutControl skips it so it applies once outer padding (default h16 v8 inset, 0 base)

Events: none, apart from the common on_animation_end and on_size_change. All other common layout keywords go through LayoutControl.

An empty section, with no visible rows and no header, renders ErrorControl("ListSection needs controls or a header") on both designs. The Cupertino SDK asserts on this case.

Deviations from the spec, and why

  • iOS separators line up with Ruflet tile titles. The SDK's insetGrouped defaults (14 + 42 = 56) are sized for CupertinoListTile.notched. Ruflet's iOS ListTile uses the base geometry: 20 padding + 28 leading + 16 gap, so titles start at 64. The SDK defaults would leave every separator 8pt short of the title above it. Both variants now default to 20 + 44 (or 20 + 0 without leading), which is the SDK's own base default. Ruby can still override both values.
  • Material divider_margin means the divider start, as on iOS. The spec mapped it to Material endIndent, which would give the same Ruby key different meanings on the two designs. Now indent = divider_margin (default 16) + additional_divider_margin (default 56 with leading, 0 without). The defaults still produce the specced 72 / 16, and the divider starts under the ListTile title.
  • top_margin works on insetGrouped. CupertinoListSection.insetGrouped accepts topMargin but never applies it. Ruby's top_margin adds the same grouped-background space above an inset section, so the key behaves the same on both variants and designs.
  • Custom border_radius on iOS. The SDK always clips rows to its fixed 10pt superellipse. When Ruby sets a radius, the renderer passes a BoxDecoration with that radius. It also clips the first and last rows to that radius instead of the SDK's, so a tapped row's highlight follows the drawn corners.
  • Rows span the full width on both designs. The SDK column centers children that are narrower than the section. Each row is given the full section width, matching Material's stretched column. A plain text/switch row therefore starts at the leading edge on both designs.
  • Material clip default is antiAlias for inset. The spec suggested hardEdge, which leaves jagged rounded corners on Material.

Tests

  • test/widgets/ruby_list_section_test.dart (new, 11 tests), covering iOS and Android:
    • iOS: finds CupertinoListSection with the insetGrouped type. Inset row x-offset is 20 on both sides. Row 2 top minus row 1 bottom is between 0 and 1 (the hairline). Header sits above the rows and footer below. Rows are clipped by the SDK's RoundedSuperellipseBorder (radius 10). Exactly one short separator, whose line starts at row.left + 64 and sits right below row 1. In base, the separator starts exactly under the row titles. The margin override moves the rows while the control's own rect stays at x=0, so margin is applied once. Colors, radius, edge-row clips and divider margins reach the SDK, and top_margin works on inset. A header-only section renders and an empty one shows ErrorControl. The CupertinoListSection alias works. No Material widget is used anywhere.
    • Android: card radius 12, antiAlias, surfaceContainerLow. Card inset 16. Divider count is rows-1, with indent 72 and height 1, placed right below row 1. Header text color is primary. Base is full-bleed with radius 0 and the divider line starts under the titles. Margin is applied once. Ruby colors, radius, hard_edge clip, divider indent and top_margin all apply. Header-only and empty cases are covered. No Cupertino widgets.
  • control_renderer_matrix_test.dart: adds a ListSection fixture with a header. The type renders on iOS, Android, macOS, Windows and Linux with no exception, no ErrorControl and no opposite-design widgets.

verify_pr.sh with Flutter 3.41.2:

PASS ruby:ruflet_core                   146/146 files, 628 runs
PASS ruby:ruflet_rails                  15/15 files, 278 runs
PASS engine:ruflet flutter test         +711: All tests passed!   (baseline 695 + 11 focused + 5 matrix)
PASS engine:ruflet analyze              No issues found!
INFO wire-key audit                     ListSection: 0 props not read, 0 events not fired, 0 near misses, full Material/Cupertino prop parity

The audit diff shows one changed line. It is the pre-existing ReorderableDragHandle margin finding, whose "literal elsewhere" example list now cites cupertino_list_section.dart. It is not a new finding.

Notes

  • For a seamless iOS settings screen, use page.bgcolor = "systemGroupedBackground", or spacing: 0 between sections. Each section paints its own grouped background, including its margins.
  • Known issue outside this PR: on iOS, text_field(border: "none") still draws the default rounded border. cupertino_textfield.dart passes copyWith(border: null), which keeps the SDK border. This affects text fields placed in sections, and is reported to the lead for Package C (which owns that file).

Render Ruby list_section as CupertinoListSection (insetGrouped by default,
or base) on Apple platforms and as a Material card of rows with inset
dividers elsewhere. Header and footer accept a string or a control; margin
is applied by the renderer once. iOS separators default to the start of
Ruflet list tile titles, and top_margin also applies to inset sections.
CupertinoListSection and CupertinoFormSection are accepted as aliases.
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