maui icon indicating copy to clipboard operation
maui copied to clipboard

Add support for iOS/Mac specific modals styled as popovers

Open piersdeseilligny opened this issue 1 year ago • 13 comments
trafficstars

Description of Change

Fixes #23975 by adding support for the iOS/Mac specific feature of modals styled as Popovers.

This is achieved by simply adding PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.Popover, which maps to UIKit.UIModalPresentationStyle.Popover.

In order to specify where the popover is originating from, this PR also adds support for the following:

  • On<iOS>().SetModalPopoverView(Microsoft.Maui.Controls.View);
  • On<iOS>().SetModalPopoverRect(System.Drawing.Rectangle);

Demo

https://github.com/user-attachments/assets/05bbe127-eeb7-4262-b621-0a660697d3e0

Example Usage

Parent page:

Page modalPage = new PopoverPage(originButton, Rectangle.Empty);
await Navigation.PushModalAsync(modalPage);

Modal page:

public partial class PopoverPage : ContentPage
{
	public PopoverPage(View modalOrigin, Rectangle rectangle)
	{
		InitializeComponent();
		On<iOS>().SetModalPopoverView(modalOrigin);
		On<iOS>().SetModalPopoverRect(rectangle);
		On<iOS>().SetModalPresentationStyle(presentationStyle);
	}
}

piersdeseilligny avatar Aug 02 '24 16:08 piersdeseilligny

@dotnet-policy-service agree

piersdeseilligny avatar Aug 02 '24 16:08 piersdeseilligny

Since this introduces new APIs can you please target this for .NET 9? The net9.0 branch?

jfversluis avatar Aug 02 '24 19:08 jfversluis

Sure, that's it done. There's a few conflicts now, mainly around the PublicAPI.Unshipped.txt files, but I'm not very familiar with these so unsure what the correct procedure is.

piersdeseilligny avatar Aug 02 '24 23:08 piersdeseilligny

@piersdeseilligny API tracking is described here: https://github.com/dotnet/maui/blob/main/docs/design/APIChangeTracking.md. If you add new APIs, then there should be new entries in PublicAPI.Unshipped.txt file(s), basically.

CTRL+. in Visual Studio can add the missing entries to those text files for you. Not sure if VS Code can do the same.

MartyIX avatar Aug 04 '24 07:08 MartyIX

/azp run

jfversluis avatar Aug 06 '24 11:08 jfversluis

I rebased your PR, could you confirm the code still looks good? :)

jfversluis avatar Aug 06 '24 11:08 jfversluis

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Aug 06 '24 11:08 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Aug 06 '24 12:08 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Aug 06 '24 12:08 azure-pipelines[bot]

/rebase

jfversluis avatar Aug 08 '24 18:08 jfversluis

/rebase

rmarinho avatar Sep 24 '24 16:09 rmarinho

@piersdeseilligny Could you rebase and fix the conflicts? Let me know if need help in some way.

jsuarezruiz avatar Oct 23 '24 09:10 jsuarezruiz

@jsuarezruiz let me know if that's all looking ok now? Sorry I don't have a good grasp on these PublicAPI .txt files so i'm not entirely sure if i merged everything correctly.

piersdeseilligny avatar Oct 26 '24 12:10 piersdeseilligny

Can we rebase this on main please?

rmarinho avatar Nov 18 '24 10:11 rmarinho

Any chance this could make it into .NET 9 SR2?

piersdeseilligny avatar Nov 25 '24 21:11 piersdeseilligny

@jsuarezruiz @rmarinho We would also like to see this merged into MAUI.

Felix-Dev avatar Nov 26 '24 19:11 Felix-Dev

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Nov 27 '24 08:11 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 02 '24 11:12 azure-pipelines[bot]

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 02 '24 12:12 azure-pipelines[bot]

/rebase

jfversluis avatar Dec 03 '24 10:12 jfversluis

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 03 '24 12:12 azure-pipelines[bot]

Not to nag, but any update on when this may get merged?

piersdeseilligny avatar Feb 04 '25 21:02 piersdeseilligny

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

azure-pipelines[bot] avatar Feb 10 '25 08:02 azure-pipelines[bot]

Successful build for .NET 10 is here: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=10992030&view=results (includes the latest changes done after this comment)

jfversluis avatar Feb 11 '25 08:02 jfversluis