Remove restriction for displaying Popup on iOS#1369
Remove restriction for displaying Popup on iOS#1369TheCodeTraveler merged 20 commits intoCommunityToolkit:mainfrom
Conversation
|
@cat0363 Just FYI - the latest PR we merged today introduced a merge conflict in |
|
@cat0363 Just FYI - a PR we merged today introduced a merge conflict here in this PR |
|
@brminnick , I resolved the conflict and merged. |
|
@cat0363 Thanks for this PR and all the others... But I don't think this is the correct solution, forcing the popup to open when we have a |
|
@pictos , Thank you for your valuable opinion.
As an aside, the results of verification in PR before WeakReference is applied are described below. [Case 1] Open popup from popup. The first popup is displayed on the top left, the second popup is displayed in the center. iPhone.14.iOS.16.4.2023-08-29.09-09-50.mp4[Case 2] Open a Popup with the click event of MyButton, which inherits the Button class. iPhone.14.iOS.16.4.2023-08-29.09-10-07.mp4The above case works equally well on Android and Windows. As a result of discussion, if it is determined that there is no need to fix it, I will withdraw this PR. |
|
@cat0363 there are no bad questions at all, just ask as you need (:. I'll do my best do answer your questions, since it has been a long long time since I wrote those lines...
iOS doesn't have a
Since Android and Windows have the concept of Popup, everything is handled by each platform. So, the limitation on iOS is to make the popup implementation there as close as possible to other platforms. As I mentioned, has been a long time since I wrote these lines, maybe something changes that we can modify this code. Or even if Apple releases a popup control, we can use that instead. |
|
@pictos , Thank you for answering my question.
I understand why Windows and Android don't impose restrictions. The concept is to bring the incapable side closer to the capable side as much as possible, rather than matching the incapable side to the capable side, isn't it?
Is it correct to recognize that there are things that cannot be done if it is not PageHandler? In the issue that led to this PR, the type of If the answer is yes, then you can add a condition, but the
So the implementation would look something like this: Wouldn't it be possible to add allowable parents as above? |
|
@brminnick , I resolved the conflict. But, I got a build error after merging, I will fix it on Monday. This PR does not give a clear answer to the question. I need to know a clear reason why element.Parent must be a PageHandler. I think MacCatalyst at least needs to be considered separately from iOS since it is limited to PageHandler in PR #1409. |
|
For MacCatalyst, element.Parent must be a PageHandler, so we reinstated the restriction. [src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs] In the case of MacCatalyst, if you set overlayView.Frame = view.Frame, the overlay does not completely cover the original view, so I fixed it as follows. For MacCatalyst, this is because there is an offset in the Y coordinate. [src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs] Changed null judgment from ==null to is null. [src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs] |
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Great improvements! Thanks @cat0363!!
This PR makes it possible to use Popup when the display source of Popup is not PageHandler.
Description of Change
The SetElement method in MauiPopup.macios.cs imposes a restriction that the Parent type must be PageHandler.
[src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs]
By removing this restriction, we fix it so that the Popup can be displayed even if the Popup's parent is not a PageHandler.
However, removing the above constraint causes the following problem.
the background color of the Popup is dimmed to achieve the overlay. However, if the page
from which the Popup is displayed is displayed modally, if the background color of the page
displayed modally is made translucent, the page from which the page displayed modally is
displayed will also be visible.
Below is the verification video.
iPhone.14.iOS.16.4.2023-08-25.11-12-35.mp4
which it was displayed. As a result, it will transition to the display source page of
the page that was displayed modally.
Below is the verification video.
iPhone.14.iOS.16.4.2023-08-25.11-35-54.mp4
To solve the first problem, stop making the page from which the Popup is displayed
semi-transparent to achieve the overlay. Add a new UIView to Subview to overlay on the
page where the Popup is displayed.
[src\CommunityToolkit.Maui.Core\Views\Popup\MauiPopup.macios.cs]
By detecting the rotation of the screen and specifying the size of the frame
after rotation before rotation, the overlay view is not animated by the resize
animation. I'm inverting the width and height.
The above solves the first problem.
To solve the second problem, stop calling the ViewController's DismissViewControllerAsync method.
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopupHandler.macios.cs]
If the popup is displayed from a non-modally displayed page, the above will not be a problem,
but if the popup is displayed from a modally displayed page, it will be closed, including
the modally displayed page.
In order to properly close only the Popup, you need to change it as follows.
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopupHandler.macios.cs]
The above solves the second problem.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
I first verified it with the source code provided in Issue #1347.
Below are the verification results.
iPhone.14.iOS.16.4.2023-08-25.12-48-29.mp4
You can see that the page from which the Popup is displayed is translucent and the page behind it is no longer visible.
Also, when you close the Popup, you can see that the display source of the Popup is no longer closed.
Next, I tried rotating the screen while displaying the Popup.
iPhone.14.iOS.16.4.2023-08-25.12-49-52.mp4
You can see that the overlay resize animation does not occur and the overlay is displayed at its after rotated size.
Next, I displayed the Popup from a non-modal page and verified it.
iPhone.14.iOS.16.4.2023-08-25.13-05-23.mp4
You can see that the Popup appears and closes as intended.