Skip to content
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

Add Modal functionality on MacCatalyst TitleBars #27015

Open
tj-devel709 opened this issue Jan 8, 2025 · 0 comments
Open

Add Modal functionality on MacCatalyst TitleBars #27015

tj-devel709 opened this issue Jan 8, 2025 · 0 comments
Labels
Milestone

Comments

@tj-devel709
Copy link
Member

Description

In MAUI on MacCatalyst, we currently support the following UIModalPresentationStyle enums:

  • UIModalPresentationAutomatic
  • UIModalPresentationFullScreen
  • UIModalPresentationOverFullScreen
  • UIModalPresentationPageSheet
  • UIModalPresentationFormSheet

However, when it comes to the TitleBar, we are not able to move the modal frame with the above UIModalPresentationStyles (except OverFullScreen) and you cannot interact with the titlebar with any of these.

There are other enums that you can do this though including the UIModalPresentationCurrentContext and UIModalPresentationOverCurrentContext. With UIModalPresentationCurrentContext, the page behind it gets grayed out where as the page behind does not get grayed out with UIModalPresentationOverCurrentContext. The page behind is not interactable, but you can interact with the titlebar if you move the frame of the modal below the titlebar inside ControlsModalWrapper.ViewDidLayoutSubviews.

Example with OverCurrentContext:

OverCurrentContext.mov

Example with CurrentContext:

CurrentContextModal.mov

Public API Changes

Adding the following in src/Controls/src/Core/Platform/iOS/Extensions/Extensions.cs

	case PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.CurrentContext:
		return UIModalPresentationStyle.CurrentContext;
	case PlatformConfiguration.iOSSpecific.UIModalPresentationStyle.OverCurrentContext:
		return UIModalPresentationStyle.OverCurrentContext;

Adding the following in src/Controls/src/Core/PlatformConfiguration/iOSSpecific/UIModalPresentationStyle.cs

	CurrentContext,
	OverCurrentContext,

Editing the Frame in src/Controls/src/Core/Platform/iOS/ControlsModalWrapper.cs but calculate the actual size of the titlebar

		public override void ViewDidLayoutSubviews()
		{
			base.ViewDidLayoutSubviews();
			// _modal?.PlatformArrange(new Rect(0, 0, View!.Bounds.Width, View.Bounds.Height));
			if (_modal?.ViewController?.View != null)
			{
				var frame = new Rect(0, 200, View!.Bounds.Width, View.Bounds.Height - 200);
				_modal.ViewController.View.Frame = frame;
			}
		}

Intended Use-Case

Be able to have a custom TitleBar be seen and used when we have a modal

@tj-devel709 tj-devel709 added this to the Backlog milestone Jan 9, 2025
@jfversluis jfversluis added the s/triaged Issue has been reviewed label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants