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

[iOS] Fix Button image sizing and layout #22476

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

tj-devel709
Copy link
Contributor

@tj-devel709 tj-devel709 commented May 17, 2024

Description of Change

This PR is a continuation of this previous PR: #21759.
The past PR was rolled-back because it contained an infinite loop in certain circumstances when the parent of the button was resized.
To combat this, the iOS button layout code was moved to the ArrangeOverride method with the size allotted from the parent. This also matches where Android and Windows calculates and arranges the layout.

UITest changing the parent size and rotation:

ButtonRotationResizing.mov

UITest testing the measuring code and changing the image position:

iOSButtonChangingLayoutPosition.mov

UITest testing the image resizing when BorderWidth changes

iOSButtonBorderWidth.mov

If you'd like to test some cases, here are some code samples:

Issues Fixed

Fixes #22306

@tj-devel709 tj-devel709 requested a review from a team as a code owner May 17, 2024 04:11
@tj-devel709 tj-devel709 marked this pull request as draft May 17, 2024 16:46
@tj-devel709
Copy link
Contributor Author

I think this needs to rethink how the Measure for the button is taken in the case of moving all the layout logic into the ArrangeOverride

@tj-devel709 tj-devel709 force-pushed the dev/TJ/iOS18242-Compat3-FixRotation branch from fb92003 to a6d0772 Compare May 22, 2024 14:54
@tj-devel709 tj-devel709 marked this pull request as ready for review May 22, 2024 18:17
@tj-devel709 tj-devel709 force-pushed the dev/TJ/iOS18242-Compat3-FixRotation branch from 44f5aa8 to 3147b11 Compare May 23, 2024 14:44

namespace Microsoft.Maui.Controls
{
public partial class Button
{
CGSize _originalImageSize = CGSize.Empty;

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: To add MeasureOverride, I needed to add this method to the publicAPI.Unshipped. Do-able for SR?

@tj-devel709 tj-devel709 marked this pull request as draft May 28, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button with image not scaling to HeightRequest on iOS
2 participants