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
Fix display position and size of Popup #1320
Conversation
…onException`, Add message to `InvalidOperationException`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cat0363!
I confirmed that this code definitely fixes the Popup layout / sizing bugs.
I'd love to avoid using hard-coded strings on Android if it's possible. Hopefully it is! If it is truly the only way to retrieve this data, then we can merge it, but I'd prefer to avoid it if possible.
Just FYI - I updated the exceptions in PopupExtensions.android.cs
. It isn't directly related to this bug fix. Making these exceptions for descriptive will better help devs in the future.
src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
Outdated
Show resolved
Hide resolved
@brminnick, I am glad that I was able to help you even a little. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @cat0363!!
This PR is going to make a lot of devs very happy 💯
@brminnick, Thank you, too. P.S. |
Ah - sorry - I finally understand the reason behind I agree - we should ensure that Popup is laid-out the same on Android + iOS. If you're able to, feel free to open up a new PR for this and I'll review + approve it. I think we may have an existing Issue already opened too. |
@brminnick , Thank you for releasing the latest version of CommunityToolkit. |
This PR fixes an issue where popups are displayed in the wrong size and position on iOS and Android.
It also fixes an issue where the size of the displayed Popup is not updated when rotating an Android device.
Description of Change
I changed the PopupExtensions.macios.cs file to:
[src\CommunityToolkit.Maui.Core\Views\Popup\PopupExtensions.macios.cs]
Changed how the SourceRect position is calculated depending on whether it does not exceed the size of the
Window's frame. I specified PopoverLayoutMargins so that the display area of the Popup extends to the entire screen.
I also posted in Issue, but if the Top value of PopoverLayoutMargins is 0, the margin will be taken, so I intentionally
set it to 1.
Originally there was a calculation process for position correction for MacCatalyst, but it was deleted because it
does not make sense.
I changed the PopupExtensions.android.cs file to:
[src\CommunityToolkit.Maui.Core\Views\Popup\PopupExtensions.android.cs]
I got the DisplayDensity to calculate the screen size and not exceed the screen size if the Popup's size
exceeds the screen size. That point is below. I'm getting the height of the status bar and navigation bar
and calculating the content area. If the screen orientation is landscape, the height of the NavigationBar is set to 0.
I changed the PopUpHandler.android.cs file to:
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopUpHandler.android.cs]
I listened to the LayoutChange event and called the SetSize method of the PopupExtensions class
on screen rotation so that the size of the Popup would be updated dynamically.
I have solved two issues by above.
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
I used the following that I made myself to verify the operation.
https://github.com/cat0363/MauiComm-IssuePopupSizePosition.git
Below are the verification results.
This is the verification result when the popup size does not exceed the screen size.
I specified the Size below.
Changed HorizontalOptions and VerticalOptions of Popup as below.
This is the verification result when the popup size does not exceed the screen size.
I specified the size below.
Changed HorizontalOptions and VerticalOptions of Popup as below.
Other patterns are the same, so they are omitted.
I specified the Size below.
Changed HorizontalOptions and VerticalOptions of Popup as below.
Other patterns are the same, so they are omitted.
I specified the Size below.
Changed HorizontalOptions and VerticalOptions of Popup as below.
Other patterns are the same, so they are omitted.
The results are the same on both iOS and Android, confirming that the popup is displayed at the intended size and position.
Finally, it is a verification result when the terminal is rotated on the Android device.
I specified Size, HorizontalOptions, VerticalOptions as below.
From the above, you can confirm that the Popup has been resized after rotation.