Skip to content

feat: add IndexedStack control - #29

Merged
AdamMusa merged 2 commits into
mainfrom
feat/indexed-stack
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
feat/indexed-stack

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Adds the Ruby side of IndexedStack (Work Package F, item F3). It keeps every tab body mounted and shows the one at index. Unlike visible, switching tabs keeps their state.

Engine counterpart (renderer): AdamMusa/ruflet-engine#12

Usage

body = indexed_stack(expand: true, controls: [home_view, search_view, profile_view])
page.navigation_bar = navigation_bar(
  destinations: [...],
  on_change: ->(e) { page.update(body, index: e.value) }
)

# positional children and block children work like stack
indexed_stack([text("A"), text("B")], index: 1)
indexed_stack(index: 0) do
  text("First")
  text("Second")
end

API

  • Class: controls/shared/indexedstack_control.rb, RufletComponents::IndexedStackControl, TYPE indexedstack, WIRE IndexedStack.
  • CLASS_MAP has indexed_stack and indexedstack in both the shared and the top-level registry.
  • DSL helpers indexed_stack(children = nil, **props, &block) and indexedstack are in material_control_methods.rb, shared_control_forwarders.rb and dsl.rb.
  • KEYWORDS: alignment clip_behavior controls fit index plus the common layout keywords (align animate_* aspect_ratio badge bottom col data disabled expand expand_loose height key left margin offset opacity right rotate rtl scale size_change_interval tooltip top visible width). Events: on_animation_end, on_size_change.
  • index defaults to 0 (SPEC R5), so page.update(body, index: n) round-trips. Flutter's own defaults cover fit (loose) and clip_behavior (hardEdge).

Tests

  • New test/indexed_stack_compatibility_test.rb (7 runs). It covers:
    • _c, positional, controls: and block children, and the serialized props;
    • the compact alias, Ruflet.control(:indexed_stack) and Ruflet::DSL helpers;
    • the index default;
    • has_handler? for the layout events;
    • unknown keyword raises ArgumentError;
    • page.update(body, index: 1).
  • verify_pr.sh: ruflet_core 146/146 files, 625 runs, all green. The engine pair passes too (+712 tests, analyze clean). The wire-key audit shows 0 new findings, and IndexedStack has no unread keys.

Add indexed_stack/indexedstack helpers and the IndexedStack wire type with the common layout keywords. index defaults to 0 so page updates round-trip.
@AdamMusa
AdamMusa merged commit b5fd169 into main Oct 29, 2026
5 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