Skip to content

Commit

Permalink
[Android] Fixed box view properties (#21322)
Browse files Browse the repository at this point in the history
* Added a Ui Test (#19926)

* [Android] box view properties fix (#19926)

* Revert "[Android] box view properties fix (#19926)"

This reverts commit 1995547.

* Update BoxView (#19926)

* Update BoxView.cs

* Added snapshot

---------

Co-authored-by: Javier Suárez <[email protected]>
  • Loading branch information
kubaflo and jsuarezruiz authored Apr 13, 2024
1 parent d9226a5 commit 70e8800
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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.Issue19926"
Title="Issue19926">

<ContentPage.Resources>
<Style TargetType="BoxView">
<Setter Property="WidthRequest" Value="100"/>
<Setter Property="HeightRequest" Value="100"/>
<Setter Property="Background">
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.4" Color="Red" />
<GradientStop Offset="1" Color="Blue" />
</LinearGradientBrush>
</Setter>
</Style>
</ContentPage.Resources>

<StackLayout Spacing="20">
<StackLayout>
<Label HorizontalTextAlignment="Center" Text="Translation X"/>
<BoxView TranslationX="30" AutomationId="boxView"/>
</StackLayout>

<StackLayout>
<Label HorizontalTextAlignment="Center" Text="Opacity"/>
<BoxView Opacity="0.2"/>
</StackLayout>

<StackLayout>
<Label HorizontalTextAlignment="Center" Text="Scale X"/>
<BoxView ScaleX="1.5"/>
</StackLayout>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 19926, "[Android] Opacity bug on BoxView.Background", PlatformAffected.Android)]

public partial class Issue19926 : ContentPage
{
public Issue19926()
{
InitializeComponent();
}
}
3 changes: 2 additions & 1 deletion src/Controls/src/Core/BoxView/BoxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected override void OnPropertyChanged([CallerMemberName] string? propertyNam

if (propertyName == BackgroundColorProperty.PropertyName ||
propertyName == ColorProperty.PropertyName ||
propertyName == BackgroundProperty.PropertyName ||
propertyName == CornerRadiusProperty.PropertyName)
Handler?.UpdateValue(nameof(IShapeView.Shape));
}
Expand All @@ -64,7 +65,7 @@ protected override void OnPropertyChanged([CallerMemberName] string? propertyNam

PathAspect IShapeView.Aspect => PathAspect.None;

Paint? IShapeView.Fill => Color?.AsPaint() ?? ((IView)this).Background;
Paint? IShapeView.Fill => Color?.AsPaint();

Paint? IStroke.Stroke => null;

Expand Down
23 changes: 23 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19926.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues;

public class Issue19926 : _IssuesUITest
{
public override string Issue => "[Android] Opacity bug on BoxView.Background";

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

[Test]
public void PropertiesShouldBeCorrectlyApplied()
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.iOS, TestDevice.Mac, TestDevice.Windows });
_ = App.WaitForElement("boxView");

VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70e8800

Please sign in to comment.