Skip to content

feat: add IndexedStack control - #12

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

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/indexed-stack

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Adds the IndexedStack control (Work Package F, item F3). It shows one child at a time and keeps every child mounted, so a tab body keeps its typed text and scroll position when the user switches away and back. Hiding a child with visible drops its subtree, so it cannot do this.

Ruby counterpart: AdamMusa/ruflet#29

Rendering

lib/src/controls/indexed_stack.dart is one design-neutral file that imports only widgets.dart, like rotated_box.dart. Material and Cupertino render the same thing: a Flutter IndexedStack wrapped in LayoutControl, so the common layout keywords work (expand, width, height, margin, ...).

  • Children are read with children("controls", visibleOnly: false). Each child is keyed by its control id. A hidden child keeps its slot as an empty box, so index always points at the same Ruby child.
  • An index that is negative or past the end is clamped, because Flutter asserts on an out-of-range index. An empty stack renders nothing.

Wire keys

Ruby keyword Flutter Default
controls children []
index index (clamped) 0
alignment alignment AlignmentDirectional.topStart
fit sizing (loose/expand/passthrough, same keyword as Stack) loose
clip_behavior clipBehavior hardEdge
common layout keywords LayoutControl

Events: none apart from the common on_animation_end and on_size_change. Enum strings accept camelCase or snake_case.

Tests

  • New test/widgets/ruby_indexed_stack_test.dart, 12 tests run on both iOS (Cupertino) and Android (Material). They check:
    • only the indexed child is on stage, and the others stay mounted offstage;
    • geometry: 200x120 box, topStart origin;
    • alignment, fit: expand (child is forced to 200x100) and clip_behavior are passed through;
    • text typed into a TextField in child 0 survives switching to 1 and back, with the same EditableTextState;
    • out-of-range and negative indexes clamp;
    • hidden children keep their index slot;
    • an empty stack renders.
  • The default matrix fixture covers it on all 5 platforms.
  • verify_pr.sh with Flutter 3.41.2: flutter test gives +712: All tests passed! (baseline 695). flutter analyze lib test reports No issues found!. The wire-key audit shows 0 new findings.

Render Ruby indexed_stack as a design-neutral IndexedStack that keeps every child mounted, so typed text and scroll offsets survive switching. Out-of-range indexes clamp and hidden children keep their slot.
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