Skip to content

feat: add selected to AdaptivePopupMenuItem (single-select checkmark) - #147

Open
gem85247 wants to merge 2 commits into
berkaycatak:mainfrom
gem85247:feat/popup-menu-selected-state
Open

gem85247 wants to merge 2 commits into
berkaycatak:mainfrom
gem85247:feat/popup-menu-selected-state

Conversation

@gem85247

Copy link
Copy Markdown

Summary

Adds a selected flag to AdaptivePopupMenuItem so a popup menu can act as a single-select control and show which option is currently active — the piece missing for using AdaptivePopupMenuButton as a settings-style value picker.

  • iOS 14+ native menus: sets UIAction.state = .on, so the system renders its native trailing checkmark on the selected item.
  • Material popup menus: shows a trailing check (Icons.check, colorScheme.primary).
  • iOS <26 action-sheet fallback: shows a leading CupertinoIcons.checkmark.

The flag is plumbed through the iOS platform view (creationParams + updateMenuItems), added to _hasMenuItemsChanged and the view key, so toggling selection updates the live menu. Defaults to false, so this is fully backward compatible.

Why

Today there's no way to indicate the current value in a popup menu — you can only fake it by swapping an item's leading icon to a checkmark, which fights the native leading-image layout and never produces the real iOS trailing checkmark. isDestructive/subtitle/imageBytes already follow this same three-surface pattern; selected fills the gap.

Usage

AdaptivePopupMenuButton.text<String>(
  label: current,
  items: [
    for (final o in options)
      AdaptivePopupMenuItem(label: o, value: o, selected: o == current),
  ],
  onSelected: (_, item) => setState(() => current = item.value!),
)

Changes

  • AdaptivePopupMenuItem.selected (default false) + dartdoc
  • iOS 26 native: parse isSelected, apply UIAction.state
  • Material + iOS <26 fallback: checkmark rendering
  • README single-select example, CHANGELOG entry, version bump to 0.1.112

Test plan

  • iOS 26 device/sim: selected item shows the native trailing checkmark; changing selection updates it live
  • Android: selected item shows a trailing check in the Material menu
  • iOS <26: selected item shows a leading checkmark in the action sheet
  • Existing menus (no selected set) render unchanged

Made with Cursor

gem85247 and others added 2 commits August 17, 2026 13:36
…select

Marks the current choice in a single-selection menu:
- iOS 14+ native menus set `UIAction.state = .on` (system trailing checkmark)
- Material popup menus and the iOS <26 action-sheet fallback show a checkmark

The flag is plumbed through the iOS platform view (creation params +
`updateMenuItems`) and included in change detection so toggling selection
updates the live menu.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ding

IOS26Button forced SizedBox(width: minSize.width) — callers passing
Size(0, h) ('no min width', Cupertino semantics, and what the shared
_wrapIOSButton ConstrainedBox does) got a zero-width invisible button
on iOS 26. Child mode now sizes to its Flutter-drawn child with
ConstrainedBox min constraints, and applies [padding] around the child
so the glass pill extends past the label. Title mode keeps the explicit
size since the native label has no Flutter intrinsic width.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gem85247 added a commit to gem85247/adaptive_platform_ui that referenced this pull request Aug 19, 2026
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