Skip to content

fix: send sliding from cupertino_sliding_segmented_button - #61

Merged
AdamMusa merged 1 commit into
mainfrom
fix/sliding-segmented-button
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
mainfrom
fix/sliding-segmented-button

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Pairs with AdamMusa/ruflet-engine#93 (engine).

Bug

cupertino_sliding_segmented_button sends the canonical SegmentedButton wire type (b9e52ff) and nothing that tells it apart from cupertino_segmented_button. On iOS it therefore rendered as the plain segmented control.

Fix

CupertinoSlidingSegmentedButtonControl declares a sliding keyword with a default of true, the same way cupertino_button keeps size: "large" through its class default. The canonical segmented_button contract takes the union of the segmented classes' KEYWORDS, so sliding is now a canonical SegmentedButton keyword too: segmented_button(sliding: true) works. The engine PR renders the sliding control from it on iOS; Material has no sliding equivalent.

Segment already accepts tooltip: it is an explicit initialize keyword, which ControlFactory.constructor_keywords exposes. Nothing to add, so a test now pins it.

Usage

cupertino_sliding_segmented_button([text("Day"), text("Week")])   # sends sliding: true
segmented_button(controls: [text("A"), text("B")], selected_index: 0, sliding: true)

Tests

test/cupertino_segmented_compatibility_test.rb (+3):

  • the sliding variant sends sliding: true on the canonical wire type, and the plain variant does not; an explicit false is kept;
  • sliding is a canonical segmented_button keyword;
  • segment(tooltip:) serializes.

team/verify_pr.sh (paired with the engine branch, RUBY_PKGS="ruflet_core ruflet ruflet_server ruflet_rails"): PASS:

  • ruflet_core 162/162 (750 runs), ruflet 13/13, ruflet_server 11/11, ruflet_rails 15/15;
  • engine +1127, audit 0 new.

The change is mruby-safe: plain keyword and default lines in the generated style.

The sliding variant sends the canonical SegmentedButton wire type, so the
engine could not tell it from the plain segmented control. Declare a sliding
keyword on cupertino_sliding_segmented_button with a default of true (the way
cupertino_button keeps size "large"); the canonical segmented_button
contract takes it as part of its keyword union.
@AdamMusa
AdamMusa merged commit 59ca61a into main Nov 2, 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