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] Allow compat iOS buttons to resize image and to respect spacing and padding #21759

Merged
merged 10 commits into from
Apr 26, 2024
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>
Copy link
Contributor

Choose a reason for hiding this comment

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

fix-18232_2

<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", 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
Loading