-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Regression with iOS button resizing with text or image change (#2…
…5122) * allow remeasure for title and image change * add more to the test * screenshots * screenshots 2 * round the titleRect manual measurement * remove one condition for adding additional padding * change internal field to method * Always measure the titleRect and fix edge case with slim titleRects * screenshots * more screenshots
- Loading branch information
1 parent
7a74d0f
commit ee80709
Showing
28 changed files
with
988 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+194 KB
...Android.Tests/snapshots/android/ButtonResizesWhenTitleOrImageChangesAltered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+193 KB
...ndroid.Tests/snapshots/android/ButtonResizesWhenTitleOrImageChangesOriginal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.9 KB
...ndroid.Tests/snapshots/android/ButtonTitleFillsSpaceWhenImageChangesAltered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+107 KB
...droid.Tests/snapshots/android/ButtonTitleFillsSpaceWhenImageChangesOriginal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/Controls/tests/TestCases.HostApp/Issues/Issue25074.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue25074" | ||
Title="Issue25074"> | ||
<VerticalStackLayout> | ||
<Button | ||
AutomationId="Button1" | ||
x:Name="Button1" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="small" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button2" | ||
x:Name="Button2" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized3.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="small" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button3" | ||
x:Name="Button3" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="Start with an even longer title" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button4" | ||
x:Name="Button4" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized3.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="Start with an even longer title" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button5" | ||
x:Name="Button5" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="small" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button6" | ||
x:Name="Button6" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized3.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="small" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button7" | ||
x:Name="Button7" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="Start with an even longer title" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button8" | ||
x:Name="Button8" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized3.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="Start with an even longer title" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button9" | ||
x:Name="Button9" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="small" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
<Button | ||
AutomationId="Button10" | ||
x:Name="Button10" | ||
Background="Purple" | ||
ImageSource="dotnet_bot_resized3.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="Start with an even longer title" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
</VerticalStackLayout> | ||
</ContentPage> |
52 changes: 52 additions & 0 deletions
52
src/Controls/tests/TestCases.HostApp/Issues/Issue25074.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 25074, "Buttons update size when text or image change", PlatformAffected.iOS)] | ||
public partial class Issue25074 : ContentPage | ||
{ | ||
bool toggle = true; | ||
public Issue25074() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnCounterClicked(object sender, EventArgs e) | ||
{ | ||
if (toggle) | ||
{ | ||
Button1.Text = "Give the button a much longer title"; | ||
Button2.Text = "Give the button a much longer title"; | ||
Button3.Text = "small"; | ||
Button4.Text = "small"; | ||
Button5.ImageSource = "dotnet_bot_resized3.png"; | ||
Button6.ImageSource = "dotnet_bot_resized.png"; | ||
Button7.ImageSource = "dotnet_bot_resized3.png"; | ||
Button8.ImageSource = "dotnet_bot_resized.png"; | ||
|
||
Button9.Text = "Give the button a much longer title"; | ||
Button9.ImageSource = "dotnet_bot_resized3.png"; | ||
|
||
Button10.Text = "small"; | ||
Button10.ImageSource = "dotnet_bot_resized.png"; | ||
} | ||
else | ||
{ | ||
Button1.Text = "small"; | ||
Button2.Text = "small"; | ||
Button3.Text = "Start with an even longer title"; | ||
Button4.Text = "Start with an even longer title"; | ||
Button5.ImageSource = "dotnet_bot_resized.png"; | ||
Button6.ImageSource = "dotnet_bot_resized3.png"; | ||
Button7.ImageSource = "dotnet_bot_resized.png"; | ||
Button8.ImageSource = "dotnet_bot_resized3.png"; | ||
|
||
Button9.Text = "small"; | ||
Button9.ImageSource = "dotnet_bot_resized.png"; | ||
|
||
Button10.Text = "Start with an even longer title"; | ||
Button10.ImageSource = "dotnet_bot_resized3.png"; | ||
} | ||
|
||
toggle = !toggle; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Controls/tests/TestCases.HostApp/Issues/Issue25074_2.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue25074_2" | ||
Title="Issue25074_2"> | ||
<VerticalStackLayout> | ||
<Button | ||
x:Name="CounterBtn" | ||
AutomationId="Button1" | ||
Background="Purple" | ||
ImageSource="dotnet_bot.png" | ||
ContentLayout="Top, 0" | ||
TextColor="White" | ||
Text="This is a long title that may be truncated." | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
</VerticalStackLayout> | ||
</ContentPage> |
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.HostApp/Issues/Issue25074_2.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 25074_2, "Button title can extend past previously truncated size", PlatformAffected.iOS)] | ||
public partial class Issue25074_2 : ContentPage | ||
{ | ||
public Issue25074_2() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
int count = 0; | ||
|
||
private void OnCounterClicked(object sender, EventArgs e) | ||
{ | ||
count++; | ||
|
||
if (count % 2 == 0) | ||
{ | ||
CounterBtn.ImageSource = "dotnet_bot.png"; | ||
} | ||
else | ||
{ | ||
CounterBtn.ImageSource = "dotnet_bot_resized.png"; | ||
} | ||
} | ||
} |
Oops, something went wrong.