Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24856.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<controls:TestContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Maui.Controls.Sample.Issues"
xmlns:cmp="clr-namespace:Microsoft.Maui.Controls.Compatibility;assembly=Microsoft.Maui.Controls"
x:Class="Maui.Controls.Sample.Issues.Issue24856">
<ContentPage.Content>
<VerticalStackLayout>
<Label
AutomationId="WaitForStubControl"
Text="Issue 24856"/>
<ImageButton
Source="avatar.png"
CornerRadius="10"
BorderColor="Red"
BorderWidth="3"
Aspect="AspectFit"
BackgroundColor="Yellow"
WidthRequest="80"
HeightRequest="80"
HorizontalOptions="StartAndExpand"
Margin="24"/>
</VerticalStackLayout>
</ContentPage.Content>
</controls:TestContentPage>
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24856.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 24856, "Android ImageButton Aspect=AspectFit not display correctly", PlatformAffected.Android)]
public partial class Issue24856 : TestContentPage
{
public Issue24856()
{
InitializeComponent();
}

protected override void Init()
{

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if ANDROID
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue24856 : _IssuesUITest
{
public override string Issue => "Android ImageButton Aspect=AspectFit not display correctly";

public Issue24856(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.ImageButton)]
public void ImageButtonAspectFitWorks()
{
App.WaitForElement("WaitForStubControl");

VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public static void MapStrokeColor(IImageButtonHandler handler, IButtonStroke but
public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView?.UpdateStrokeThickness(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView.UpdateCornerRadius(buttonStroke);
handler.PlatformView?.UpdateCornerRadius(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapPadding(IImageButtonHandler handler, IImageButton imageButton)
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public static void MapStrokeColor(IImageButtonHandler handler, IButtonStroke but
public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView.UpdateStrokeThickness(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView.UpdateCornerRadius(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

[MissingMapper]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ public static void MapStrokeColor(IImageButtonHandler handler, IButtonStroke but
public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
(handler.PlatformView as Button)?.UpdateStrokeThickness(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
(handler.PlatformView as Button)?.UpdateCornerRadius(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapBackground(IImageButtonHandler handler, IImageButton imageButton)
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public static void MapStrokeColor(IImageButtonHandler handler, IButtonStroke but
public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView?.UpdateStrokeThickness(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke)
{
handler.PlatformView?.UpdateCornerRadius(buttonStroke);
handler.UpdateValue(nameof(IImageButton.Padding));
}

public static void MapPadding(IImageButtonHandler handler, IImageButton imageButton)
Expand Down
3 changes: 3 additions & 0 deletions src/Core/src/Platform/Android/ImageButtonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static void UpdateCornerRadius(this ShapeableImageView platformButton, IB
public static async void UpdatePadding(this ShapeableImageView platformButton, IImageButton imageButton)
{
var padding = platformButton.Context!.ToPixels(imageButton.Padding);
var (strokeWidth, _, _) = imageButton.GetStrokeProperties(platformButton.Context!, true);
int additionalPadding = strokeWidth;
padding = new Thickness(padding.Left + additionalPadding, padding.Top + additionalPadding, padding.Right + additionalPadding, padding.Bottom + additionalPadding);

// The simple operation we are trying to do.
platformButton.SetContentPadding((int)padding.Left, (int)padding.Top, (int)padding.Right, (int)padding.Bottom);
Expand Down
3 changes: 3 additions & 0 deletions src/Core/src/Platform/iOS/ButtonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static void UpdatePadding(this UIButton platformButton, Thickness padding
if (padding.IsNaN)
padding = defaultPadding ?? Thickness.Zero;

int additionalPadding = (int)platformButton.Layer.BorderWidth;
padding = new Thickness(padding.Left + additionalPadding, padding.Top + additionalPadding, padding.Right + additionalPadding, padding.Bottom + additionalPadding);

// top and bottom insets reset to a "default" if they are exactly 0
// however, internally they are floor-ed, so there is no actual fractions
var top = padding.Top;
Expand Down