Skip to content

Commit

Permalink
[MacCatalyst] Get correct window associated with the Popup (#1409)
Browse files Browse the repository at this point in the history
* Get correct window associated with the Popup

* Update src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Use PageHandler to get the native UIViewController.

Use PageHandler to get native UIViewController associated with the popup.

* Nit: Removed explicitly declared ‘rootViewController’ variable and merged it with the variable assignment.

---------

Co-authored-by: vbabenko <vitaliy.babenko@idx.us>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
  • Loading branch information
3 people committed Sep 18, 2023
1 parent 4c17fef commit cfc7832
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -95,7 +95,8 @@ public void SetElement(IPopup element)
_ = View ?? throw new InvalidOperationException($"{nameof(View)} cannot be null.");
_ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null.");

var rootViewController = WindowStateManager.Default.GetCurrentUIViewController() ?? throw new InvalidOperationException($"{nameof(PageHandler.ViewController)} cannot be null.");
var pagehandler = VirtualView.Parent.Handler as PageHandler;
var rootViewController = pagehandler?.ViewController ?? WindowStateManager.Default.GetCurrentUIViewController() ?? throw new InvalidOperationException($"{nameof(PageHandler.ViewController)} cannot be null.");
ViewController ??= rootViewController;
SetDimmingBackgroundEffect();
}
Expand Down

0 comments on commit cfc7832

Please sign in to comment.