Skip to content

Commit

Permalink
[iOS] Allow compat iOS buttons to resize image and to respect spacing…
Browse files Browse the repository at this point in the history
… 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
tj-devel709 and jsuarezruiz authored Apr 26, 2024
1 parent 70c2903 commit 63eb6b6
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 61 deletions.
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>
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);
}
}
}
Loading

0 comments on commit 63eb6b6

Please sign in to comment.