Skip to content

Implement iOS/macOS secondary ToolbarItems - #28185

Merged
PureWeen merged 12 commits into
net10.0from
ios-secondary-toolbaritem
Jul 4, 2025
Merged

PureWeen merged 12 commits into
net10.0from
ios-secondary-toolbaritem

Conversation

@jfversluis

@jfversluis jfversluis commented Mar 5, 2025 •

Copy link
Copy Markdown
Member

Description of Change

Uses a more modern pattern for iOS to show secondary toolbar items. This PR detects toolbar items that have the Order property set to Secondary and displays them in a popover menu. The icon is the system icon from iOS, we might consider letting the people customize that, although I'm not 100% sure how. The current implementation follows the iOS UI guidelines: https://developer.apple.com/design/human-interface-guidelines/pull-down-buttons

The secondary menu is always shown on the far right (or left when RTL is on) and takes into account Priority to order the items.

This PR:

  • Implements the secondary toolbar item functionality for iOS
  • Adds a Toolbar section to the sample app
  • Fixes the Menubar description in the sample app
  • Moves API documentation from external XML files to inline
  • Deletes the (now) unused API docs XML files
  • Adds a new extension method
  • Minor code improvements overall
  • Adds a protected virtual method on the NavigationRenderer so people can provide their own image for the secondary toolbar item (the root item), defaults to what iOS recommends (UIImage.GetSystemImage("ellipsis.circle"))

Note that this uses APIs that are only available on iOS 13+, I think that is the minimum supported version for .NET MAUI on .NET 10 anyway?

We could consider keeping this old way for iOS < 13 and/or add a flag that will let people revert to the old behavior.

Be aware that when enabled changes for one of the secondary items, the menu will be closed. The menu items in there are immutable, so when that happens, the whole menu is rebuilt which causes the menu to close when its opened.

Issues Fixed

Fixes #815

Preview

iOS

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-03-05.at.14.37.15.mp4

macOS

image

This comment was marked as outdated.

@jfversluis
jfversluis marked this pull request as draft March 5, 2025 14:13
@jfversluis
jfversluis force-pushed the ios-secondary-toolbaritem branch from 52c36c7 to 3b21fc6 Compare March 7, 2025 13:40
@jsuarezruiz

Copy link
Copy Markdown
Contributor

/rebase

@github-actions
github-actions Bot force-pushed the ios-secondary-toolbaritem branch from 3b21fc6 to 74f465f Compare March 28, 2025 09:41
@jfversluis
jfversluis force-pushed the ios-secondary-toolbaritem branch from 74f465f to 45e7252 Compare June 17, 2025 08:03
@jfversluis
jfversluis marked this pull request as ready for review June 17, 2025 10:39
@jfversluis
jfversluis requested review from Copilot, jsuarezruiz and rmarinho and removed request for PureWeen and rmarinho June 17, 2025 10:39
@PureWeen PureWeen moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Jun 23, 2025
@lucacivale

Copy link
Copy Markdown

@jfversluis
Hi, I've had look at this PR because I need secondary ToolbarItems in .NET 9.
As I wrote a solution based on your PR I observed that ToolbarItem.Command is executed twice.

Imho here only IMenuItemController.Activate should be called

item.Command?.Execute(item.CommandParameter);
((IMenuItemController)item).Activate();

@dainius-r

Copy link
Copy Markdown

@lucacivale I've also interested in this PR feature but on .NET 9. Can you share your solution or is it private?

@jfversluis
jfversluis force-pushed the ios-secondary-toolbaritem branch from 725fec1 to 5b3faa0 Compare July 3, 2025 15:10
@jfversluis jfversluis moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Jul 3, 2025
@github-project-automation github-project-automation Bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Jul 3, 2025
@PureWeen
PureWeen merged commit 0f8370e into net10.0 Jul 4, 2025
@PureWeen
PureWeen deleted the ios-secondary-toolbaritem branch July 4, 2025 22:29
@github-project-automation github-project-automation Bot moved this from Approved to Done in MAUI SDK Ongoing Jul 4, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-toolbar ToolBar p/0 Current heighest priority issues that we are targeting for a release. platform/ios proposal/open t/breaking 💥

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants