Skip to content

feat(ui): add StreamAdaptiveMenuAnchor - #227

Open
renefloor wants to merge 8 commits into
feat/stream-context-menu-anchorfrom
feat/stream-adaptive-menu-anchor
Open

renefloor wants to merge 8 commits into
feat/stream-context-menu-anchorfrom
feat/stream-adaptive-menu-anchor

Conversation

@renefloor

@renefloor renefloor commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked PR (stack #232: #225 → #226 → #227 → #229). This PR targets #226 (feat/stream-context-menu-anchor). #221 (StreamRadioButton) and #223 (StreamContextMenuHeading) are on main now, so the diff shows only the adaptive menu anchor.

What

  • StreamAdaptiveMenuAnchor presents a list of StreamMenuSections in one of two ways. On desktop and web it is an anchored StreamContextMenuAnchor with dense Web / Menu Item rows. On Android and iOS it is a showStreamSheet of StreamListTiles. The split comes from the shared isDesktopOrWeb(context) (feat(ui): add StreamModalDialog #225), so a phone browser gets the anchored menu, as it gets the dialog's desktop variant. Supporting types, all @experimental: StreamMenuEntry (after DropdownMenuEntry), StreamMenuSection (entries), StreamMenuContentBuilder, the StreamMenuSections.hasEntries extension, StreamAdaptiveMenuController (after MenuController) and StreamAdaptiveMenuAnchorBuilder, which has MenuAnchor.builder's (context, controller, child) shape with a child prop passed through. direction is Flutter's VerticalDirection.
    • Section features: headings, collapsible sections (the fold is keyed by heading, so it survives rebuilds), radio choices led by a StreamRadioIndicator (sm, 16px, in the anchored menu and md, 20px, in the sheet; no focus, no semantics of its own), a trailing value, closeOnActivate: false rows, and custom content sections. Choice rows announce checked in a mutually exclusive group, as RadioMenuButton does, and not selected. Optional props: matchAnchorWidth, direction and alignmentOffset, menuItemStyle (passed to the anchor as its actionStyle), menuElevation, useSheet and child.
    • Closing: close() removes the sheet's own route, so a dialog opened from a closeOnActivate: false row stays up. Removing the anchor removes its open sheet.
    • Headings line up with the rows. In the anchored menu, StreamContextMenuAnchor (feat(ui): add StreamContextMenuAnchor #226) already gives headings the Web heading style, and a heading takes its row size and padding from the rows around it, so it comes out 32 tall and at least 200 wide, inset like the rows, and keeps following them when menuItemStyle makes them taller. Anchored rows and headings are themed only through StreamContextMenuAnchorTheme (actionStyle / headingStyle). In the sheet, the heading's horizontal padding is copied from the tiles' contentPadding, and both share the same outer inset. The candidate padded the heading by spacing.xs instead, which only lined up with the video heading's own inset. A collapsible heading passes the heading's isExpanded, so screen readers announce the fold.
  • StreamAdaptiveMenuAnchorTheme / StreamAdaptiveMenuAnchorThemeData {style, useSheet}, ported from the video repo. It is reached through StreamTheme.adaptiveMenuAnchorTheme and context.streamAdaptiveMenuAnchorTheme. StreamAdaptiveMenuAnchorTheme.of(context).merge(...) works, so a panel can force useSheet: false and keep the rest of the app theme. A test covers that.
    • StreamAdaptiveMenuAnchorStyle keeps the candidate's sheetTileStyle. Its menuItemStyle is gone: anchored rows and headings are themed through feat(ui): add StreamContextMenuAnchor #226's StreamContextMenuAnchorTheme, so they can't be themed in two places. It adds these fields for values that were hard-coded:
      • menuGap: the gap on the direction side. Defaults to spacing.xs, which is the candidate's 8.
      • sheetHeadingStyle (StreamContextMenuHeadingStyle)
      • sheetPadding: the inset around sheet rows, headings and content. Defaults to spacing.xxs horizontally.
    • Precedence: widget param, then theme, then defaults. The defaults live in _StreamAdaptiveMenuAnchorStyleDefaults in the widget file.
  • StreamContextMenuAction.selected: resolves the style with WidgetState.selected, and the default backgroundColor fills it with colorScheme.backgroundSelected, as StreamListTile does. An action with no onTap and closeOnActivate: false is drawn as plain content: not focusable, not a button, no ink, with its enabled colors.
  • StreamContextMenuAnchor keyboard fix (separate commit, feat(ui): add StreamContextMenuAnchor #226's file): the arrow keys now reach a menu opened from the keyboard. Opening focuses the anchor's fallback focus node, which traversal skips.
  • Factory hook: StreamComponentBuilders.adaptiveMenuAnchor with StreamAdaptiveMenuAnchorProps / DefaultStreamAdaptiveMenuAnchor. Apps use this top-level widget directly, not as a building block inside another component, so it gets a hook.
  • Gallery: [Components]/Context Menu/StreamAdaptiveMenuAnchor.
    • Playground knobs: presentation (follow platform, sheet, anchored), anchor (caret button, or a full-width field using matchAnchorWidth), direction up/down, section headings, collapsible section, content section (a reaction strip that closes through the controller), toggle row and menu elevation. The radio-choice sections are always shown.
    • Showcase: anchored, sheet, full-width field, and opening upwards.
  • Barrel: video.dart (experimental), in the same sorted export block and "move to core" comment as the rest of the stack. The classes are marked @experimental.

Figma

Why

This graduates the design-system candidate from stream-video-flutter, so the SDK can delete its copy and import this one. Sources on v2:

They were built up in GetStream/stream-video-flutter#1320, #1332, #1365, #1433, #1458 and #1491. Figma: participant layout menu, more menu. I did not re-check against Figma; the row metrics come from StreamContextMenuAnchor (#226).

API changes compared with the candidate:

  • The constructor is no longer const, because it builds props for the factory, as every factory-backed component does. The fields now live on anchor.props.
  • StreamAdaptiveMenuAnchorStyle drops menuItemStyle (use StreamContextMenuAnchorTheme.actionStyle) and gains menuGap, sheetHeadingStyle and sheetPadding.
  • Renames: StreamMenuOption → StreamMenuEntry (and options → entries), StreamMenuHandle → StreamAdaptiveMenuController, closesMenu → closeOnActivate, StreamMenuSectionsX.hasNoOptions → StreamMenuSections.hasEntries. StreamMenuDirection is replaced by VerticalDirection, and the builder takes a child.
  • Without matchAnchorWidth, the panel's constraints now come from StreamContextMenuAnchorThemeData.constraints when that is set, instead of always using defaultConstraints.
  • The sheet's section headings use core's StreamContextMenuHeading defaults (40 tall), and their inset is derived from the tiles. The video heading was 32 tall and was padded by spacing.xs.

Verified

  • melos bootstrap, then melos run generate:flutter, which regenerated stream_theme, the component factory, the new theme and the gallery directories. Re-run after rebasing onto feat(ui): add StreamContextMenuAnchor #226 and main.
  • melos run format:verify, melos run analyze (no issues), melos run check:barrels and melos run check:tokens: all pass.
  • flutter test --exclude-tags golden in stream_core_flutter: all 1167 tests pass. The component's tests are split into main, sheet, heading, theme, fold and controller files sharing a harness. Semantics tests check that choice rows read checked in a group in both presentations and never selected. A keyboard test checks that the arrow keys move between rows and Esc closes and returns focus to the anchor. Tests for close() under a dialog and for removing the anchor with the sheet open fail on the old code.
    • All 55 of the candidate's tests are ported almost unchanged. A local _TestWrapper replaces the video TestWrapper, and showDialog replaces showStreamModalDialog, which is not in core.
    • The new tests cover heading alignment and height in both presentations, a heading that follows a taller menuItemStyle, the isExpanded fold state, the selected-row fill, the inert action, every new theme field with "param beats theme" checks, the of().merge(useSheet: false) pattern, lerp, the context extension and the factory hook. None of them merge two BorderSides.
  • dart analyze --fatal-infos in apps/design_system_gallery: no issues. I have not clicked through it in the running gallery.
  • Goldens (stream_adaptive_menu_anchor_{menu,sheet}_{light,dark}) open both presentations inside a scenario-local Navigator, so the menu and the sheet land in the captured area. I checked the local macOS output by eye: headings sit flush with the radio column in both presentations. The update_goldens bot has committed goldens/ci/ for this branch, and the goldens still pass after the switch to StreamRadioButton.

🤖 Generated with Claude Code
call_incoming_quality_menu_anchored_dark
call_incoming_quality_menu_anchored_light
call_layout_menu_selected_row_dark
call_layout_menu_selected_row_light
call_more_menu_collapsible_sections_dark
call_more_menu_collapsible_sections_light
call_more_menu_section_expanded_dark
call_more_menu_section_expanded_light

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@renefloor
renefloor added this pull request to stack #228 November 10, 2026 13:39
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.93095% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.04%. Comparing base (219a958) to head (03cabfd).

Files with missing lines Patch % Lines
...rc/theme/components/stream_radio_button_theme.dart 70.00% 6 Missing ⚠️
...ents/context_menu/stream_context_menu_heading.dart 96.72% 2 Missing ⚠️
.../components/stream_adaptive_menu_anchor_theme.dart 85.71% 2 Missing ⚠️
.../components/stream_context_menu_heading_theme.dart 81.81% 2 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                         @@
##           feat/stream-context-menu-anchor     #227      +/-   ##
===================================================================
+ Coverage                            73.72%   76.04%   +2.31%     
===================================================================
  Files                                  226      232       +6     
  Lines                                 9703    10098     +395     
===================================================================
+ Hits                                  7154     7679     +525     
+ Misses                                2549     2419     -130     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor
renefloor removed this pull request from stack #228 November 10, 2026 15:28
@renefloor
renefloor added this pull request to stack #232 November 10, 2026 15:28
@renefloor
renefloor force-pushed the feat/stream-adaptive-menu-anchor branch from c8f323c to 6292324 Compare November 24, 2026 14:24
@renefloor
renefloor force-pushed the feat/stream-adaptive-menu-anchor branch from df8227d to b0c1de7 Compare November 24, 2026 14:34
@renefloor
renefloor force-pushed the feat/stream-adaptive-menu-anchor branch from 6b3f627 to 6bc5028 Compare December 1, 2026 11:11
@renefloor
renefloor marked this pull request as ready for review December 1, 2026 11:35
@renefloor
renefloor requested a review from a team as a code owner December 1, 2026 11:35
@github-actions github-actions Bot added the ready Pull request ready to be reviewed label Dec 1, 2026
@getstream-metis

getstream-metis Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

👋 Thanks, Rene! I'm on it.

How to work with me

  • 💬 Disagree with a finding? Reply in its thread and tell me why. I'll withdraw it, or answer with evidence.
  • 🔁 Fixed it? Just push. The next round checks your fix and resolves the thread.
  • 👍 👎 Rate my findings. I learn what your team doesn't want flagged.
  • ✅ I approve once nothing blocking is left: must-fix always blocks, should-fix only in the first two rounds. CI isn't part of that; branch protection still holds the merge until it's green. On repos that require a human approval, a teammate still has to approve too.
Commands

Comment any of these on the PR:

  • /jeffery review · start a review
  • /jeffery next-round · start the next round now
  • /jeffery pause · /jeffery resume · stop or restart reviews on this PR
  • /jeffery status · where things stand
  • /jeffery help · all commands

@renefloor

Copy link
Copy Markdown
Collaborator Author

/jeffery review

@getstream-metis getstream-metis Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 · 🆕 2 new · nothing blocking

➡️ Round 2 started on 9021eed.

getstream-metis[bot]
getstream-metis Bot previously approved these changes Dec 1, 2026

@getstream-metis getstream-metis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Approved · round 1

Nice work, Rene! Nothing blocking is left on d69b805e46ff. Ship it 🚀

Left open, your call:

@xsahil03x xsahil03x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice port, and the coverage is thorough. Most comments are about reusing what #225/#226 already provide rather than adding parallel API, which is cheap to settle while this is @experimental.

@github-actions github-actions Bot added pending Review comments waiting to be addressed and removed ready Pull request ready to be reviewed labels Dec 1, 2026
renefloor and others added 2 commits December 1, 2026 13:45
Graduates the adaptive menu anchor from stream-video-flutter into the
experimental video.dart barrel, with StreamAdaptiveMenuAnchorTheme on
StreamTheme and an adaptiveMenuAnchor factory hook. Section headings in
the anchored menu take their metrics from the menu's rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rows that are a choice now lead with a decorative sm StreamRadioButton.
Since it adds no semantics, the anchored row announces its selected
state itself, as the sheet's list tile already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and anchor APIs

Anchored headings now take the Web heading style from StreamContextMenuAnchor
and their row size from its rows, so the menu only layers menuHeadingStyle on
top. menuHeadingStyle and sheetHeadingStyle are StreamContextMenuHeadingStyles,
choice rows lead with a StreamRadioIndicator, and collapsible headings pass
isExpanded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@renefloor
renefloor force-pushed the feat/stream-adaptive-menu-anchor branch from d69b805 to ce2fd5a Compare December 1, 2026 12:45
@getstream-metis
getstream-metis Bot dismissed their stale review December 1, 2026 12:46

Withdrawing approval until ce2fd5a is reviewed.

@xsahil03x xsahil03x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more from checking against Figma and Flutter's menu APIs.

Widget? _leadingOf(StreamMenuOption option) {
if (option.leading case final leading?) return leading;
if (option.selected case final selected?) {
return StreamRadioIndicator(selected: selected, size: StreamRadioButtonSize.sm);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the sheet, use StreamRadioButtonSize.md (20). The mobile row's icon slot is 20px, the same as its leading icons, so sm (16) looks small there. Keep sm in the anchored menu, where the slot is 16.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d25564c: sheet radios use StreamRadioButtonSize.md (20), and the anchored menu keeps sm (16). There is a test for each size.

/// True for a choice, which is answered once the choice is made. False for a
/// row that reports state the menu is showing — a toggle whose `On` the user
/// has just pressed for, and should see change.
final bool closesMenu;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name this closeOnActivate, as on MenuItemButton and on StreamContextMenuAction (#226), which this row maps onto.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to closeOnActivate in d25564c, along with its docs, tests and the gallery.

/// a group, say — sets neither.
@immutable
@experimental
class StreamMenuOption {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: consider StreamMenuEntry, after DropdownMenuEntry, which is Flutter's closest equivalent: a data entry rendered by the menu rather than a widget.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to StreamMenuEntry in d25564c. StreamMenuSection.options is now entries to match. It is still @experimental.

getstream-metis[bot]
getstream-metis Bot previously approved these changes Dec 1, 2026

@getstream-metis getstream-metis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 · 🎉 Approved

Nice work, Rene! Nothing blocking is left on 9021eede3a4a. Ship it 🚀

Left open, your call:

renefloor and others added 2 commits December 1, 2026 14:07
…om the keyboard

Opening the menu focuses the anchor's fallback focus node, which traversal
skips, so the arrow keys could not reach the rows. Directional focus from that
node now continues from the first focusable widget in the anchor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Theme anchored rows and headings through StreamContextMenuAnchorTheme; drop
  menuItemStyle, menuSelectedItemColor and menuHeadingStyle from the style.
- Add selected to StreamContextMenuAction, and draw an action with nothing to
  do as plain content.
- Use VerticalDirection, isDesktopOrWeb and StreamAdaptiveMenuController, and
  the StreamMenuSections.hasEntries extension.
- close() removes the sheet's own route, and disposing the anchor removes an
  open sheet.
- Announce a choice as checked in a mutually exclusive group.
- Trim the docs, and split the tests by feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@getstream-metis
getstream-metis Bot dismissed their stale review December 1, 2026 13:10

Withdrawing approval until 9cc6177 is reviewed.

@getstream-metis getstream-metis Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 3 · 🆕 2 new · ✅ 2 fixed · nothing blocking

➡️ Round 4 started on c0287ed.

@override
void didUpdateWidget(DefaultStreamAdaptiveMenuAnchor oldWidget) {
super.didUpdateWidget(oldWidget);
if (identical(oldWidget.props.sections, _props.sections)) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider: Open sheet not rebuilt when only title or row state changes
didUpdateWidget bumps _revision only when sections is not identical, but the sheet reads _props.title and _props.sections live. A changed title, or a cached list whose row closures read new state, stays stale in an open sheet. Bumping the revision on any props change fixes it.

Useful? React 👍 or 👎. Disagree? Reply here.

isDismissible: true,
anchorPoint: box?.localToGlobal(box.size.center(Offset.zero)),
builder: (context, scrollController) {
_sheetRoute ??= ModalRoute.of(context);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider: Sheet route is captured only on first build
_sheetRoute is assigned inside the sheet builder, so open(); close(); in one frame returns early at route == null and leaves the sheet open. dispose() before the first build leaves the route orphaned for the same reason. Capturing the route when the sheet is pushed closes both gaps.

Useful? React 👍 or 👎. Disagree? Reply here.

getstream-metis[bot]
getstream-metis Bot previously approved these changes Dec 1, 2026

@getstream-metis getstream-metis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Approved · round 3

Nice work, Rene! Nothing blocking is left on 9cc61771f395. Ship it 🚀

Left open, your call:

Renames StreamMenuOption to StreamMenuEntry, its closesMenu to closeOnActivate and StreamMenuSection.options to entries. The anchor's builder takes MenuAnchor.builder's shape, with a child prop passed through. Sheet radios are 20, the size of the sheet's icon slot. A selected sheet row keeps its fill but no longer announces selected, so a choice reads only as checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@getstream-metis
getstream-metis Bot dismissed their stale review December 1, 2026 13:29

Withdrawing approval until d25564c is reviewed.

@getstream-metis

getstream-metis Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🔍 Round 4 in progress

▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 1 of 1 lenses

Details on the checks tab.

@renefloor renefloor added the ready Pull request ready to be reviewed label Dec 1, 2026
@github-actions github-actions Bot removed the pending Review comments waiting to be addressed label Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jeffery:review ready Pull request ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants