Skip to content

Add support for iOS/Mac specific modals styled as popovers #23984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 11, 2025

Conversation

piersdeseilligny
Copy link

@piersdeseilligny piersdeseilligny commented Aug 2, 2024

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

Screen.Recording.2024-08-02.at.17.25.00.mov

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 piersdeseilligny requested a review from a team as a code owner August 2, 2024 16:29
@piersdeseilligny
Copy link
Author

@dotnet-policy-service agree

@jfversluis
Copy link
Member

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

@piersdeseilligny piersdeseilligny changed the base branch from main to net9.0 August 2, 2024 23:48
@piersdeseilligny
Copy link
Author

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.

@MartyIX
Copy link
Contributor

MartyIX commented Aug 4, 2024

@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.

@jfversluis
Copy link
Member

jfversluis commented Aug 6, 2024

/azp run

@jfversluis
Copy link
Member

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

This comment was marked as outdated.

2 similar comments

This comment was marked as outdated.

This comment was marked as off-topic.

@jfversluis

This comment was marked as outdated.

@rmarinho

This comment was marked as off-topic.

@jsuarezruiz
Copy link
Contributor

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

@piersdeseilligny
Copy link
Author

@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.

@rmarinho rmarinho changed the base branch from net9.0 to main November 18, 2024 10:05
@rmarinho
Copy link
Member

Can we rebase this on main please?

@piersdeseilligny
Copy link
Author

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

@Felix-Dev
Copy link

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

This comment was marked as off-topic.

This comment was marked as outdated.

1 similar comment

This comment was marked as outdated.

@jfversluis

This comment was marked as off-topic.

This comment was marked as outdated.

@piersdeseilligny
Copy link
Author

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

@jfversluis jfversluis requested a review from a team as a code owner February 10, 2025 08:45
@jfversluis jfversluis changed the base branch from main to net10.0 February 10, 2025 08:46
@jfversluis jfversluis added this to the .NET 10.0-preview2 milestone Feb 10, 2025
@jfversluis jfversluis self-assigned this Feb 10, 2025
Copy link

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

@jfversluis
Copy link
Member

jfversluis commented Feb 11, 2025

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)

Copy link
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

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

Thanks for this @piersdeseilligny, sorry it took a little while!

The good news is that we're merging this, the bad news is that it will be for .NET 10. So expect to see this pop up in the previews first. It's coming!

@jfversluis jfversluis merged commit db28e2e into dotnet:net10.0 Feb 11, 2025
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS-Specific enum UIModalPresentationStyle does not support all underlying UIKit options
7 participants