-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Allow compat iOS buttons to resize image and to respect spacing…
… and padding (#21759) * Fix the iOS button to resize the image, respect padding, and respect spacing * allow UITest - waiting for CI results * Allow the image to actually take up the whole space and fix issue with buttons without images or titles resizing * Add UITest screenshot * remove changes to sandbox * Added manual testing sample * More changes in the sample * Do not hide the text if it doesn't fit and resize if no title * UITests cannot share the same name --------- Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
- Loading branch information
1 parent
70c2903
commit 63eb6b6
Showing
5 changed files
with
304 additions
and
61 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/Controls/samples/Controls.Sample.UITests/Issues/Issue18242_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,70 @@ | ||
<?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.Issue18242_2"> | ||
<ScrollView> | ||
<VerticalStackLayout | ||
Margin="0,10,0,0"> | ||
<Label | ||
Text="Image on Bottom" | ||
HorizontalTextAlignment="Center" /> | ||
<Button | ||
x:Name="BottonButton" | ||
ImageSource="dotnet_bot.png" | ||
Text="Button 1" | ||
TextColor="Black" | ||
ContentLayout="Bottom, 20" | ||
Background="LightGray"/> | ||
<BoxView | ||
HeightRequest="30"/> | ||
<Label | ||
Text="Image on Top" | ||
HorizontalTextAlignment="Center" /> | ||
<Button | ||
x:Name="TopButton" | ||
ImageSource="dotnet_bot.png" | ||
Text="Button 2" | ||
TextColor="Black" | ||
ContentLayout="Top, 20" | ||
Background="LightGray"/> | ||
<BoxView | ||
HeightRequest="30"/> | ||
<Label | ||
Text="Image on Left" | ||
HorizontalTextAlignment="Center" /> | ||
<Button | ||
x:Name="LeftButton" | ||
ImageSource="dotnet_bot.png" | ||
Text="Button 3" | ||
TextColor="Black" | ||
ContentLayout="Left, 20" | ||
Background="LightGray"/> | ||
<BoxView | ||
HeightRequest="30"/> | ||
<Label | ||
Text="Image on Right" | ||
HorizontalTextAlignment="Center" /> | ||
<Button | ||
x:Name="RightButton" | ||
ImageSource="dotnet_bot.png" | ||
Text="Button 4" | ||
TextColor="Black" | ||
ContentLayout="Right, 20" | ||
Background="LightGray"/> | ||
<BoxView | ||
HeightRequest="30"/> | ||
<Label | ||
Text="Button Padding"/> | ||
<Slider | ||
Minimum="0" | ||
Maximum="40" | ||
Value="20" | ||
ValueChanged="OnSliderPaddingValueChanged"/> | ||
<Label | ||
Text="Button Size"/> | ||
<Button | ||
Text="Update Button Size" | ||
Clicked="OnUpdateSizeButtonClicked"/> | ||
</VerticalStackLayout> | ||
</ScrollView> | ||
</ContentPage> |
38 changes: 38 additions & 0 deletions
38
src/Controls/samples/Controls.Sample.UITests/Issues/Issue18242_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,38 @@ | ||
using System; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.ManualTest, "18242_2", "Button ImageSource not Scaling as expected - manual test", PlatformAffected.iOS)] | ||
public partial class Issue18242_2 : ContentPage | ||
{ | ||
readonly Random _random; | ||
|
||
public Issue18242_2() | ||
{ | ||
InitializeComponent(); | ||
|
||
_random = new Random(); | ||
} | ||
|
||
void OnSliderPaddingValueChanged(object sender, ValueChangedEventArgs e) | ||
{ | ||
TopButton.Padding = | ||
BottonButton.Padding = | ||
LeftButton.Padding = | ||
RightButton.Padding = new Thickness(e.NewValue); | ||
} | ||
|
||
void OnUpdateSizeButtonClicked(object sender, EventArgs e) | ||
{ | ||
TopButton.HeightRequest = TopButton.WidthRequest = | ||
BottonButton.HeightRequest = BottonButton.WidthRequest = | ||
LeftButton.HeightRequest = LeftButton.WidthRequest = | ||
RightButton.HeightRequest = RightButton.WidthRequest = | ||
_random.Next(200, 300); | ||
} | ||
} | ||
} |
Oops, something went wrong.