Skip to content

Commit

Permalink
Background gradients fixes (#25194)
Browse files Browse the repository at this point in the history
* Background gradients fixes

* Add test snapshots

* Pending snapshot

---------

Co-authored-by: Javier Suárez <[email protected]>
  • Loading branch information
kubaflo and jsuarezruiz authored Oct 23, 2024
1 parent 19e900d commit b6ea3df
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25193.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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.Issue25193">
<VerticalStackLayout>
<Label Text="Label: "/>
<Label
Text="Hello, Maui!"
AutomationId="label">
<Label.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Color="Red"
Offset="0.7"/>
<GradientStop Color="Green"
Offset="1.0"/>
</LinearGradientBrush>
</Label.Background>
</Label>

<Label Text="Button: "/>
<Button Text="Hello, Maui!">
<Button.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Color="Blue"
Offset="0.7"/>
<GradientStop Color="Yellow"
Offset="1.0"/>
</LinearGradientBrush>
</Button.Background>
</Button>

<Label Text="Entry: "/>
<Entry Text="Hello, Maui!">
<Entry.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Color="Pink"
Offset="0.7"/>
<GradientStop Color="Lime"
Offset="1.0"/>
</LinearGradientBrush>
</Entry.Background>
</Entry>

<Label Text="Picker: "/>
<Picker
Title="Hello, Maui!">
<Picker.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Color="Brown"
Offset="0.7"/>
<GradientStop Color="Gold"
Offset="1.0"/>
</LinearGradientBrush>
</Picker.Background>
</Picker>


<Label Text="Scroll view: "/>
<ScrollView Orientation="Horizontal"
HeightRequest="100">
<ScrollView.Background>
<LinearGradientBrush StartPoint="0,0.5"
EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Orange"
Offset="0.75"/>
<GradientStop Color="Purple"
Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</ScrollView.Background>

<Border WidthRequest="1200"/>
</ScrollView>

</VerticalStackLayout>
</ContentPage>
12 changes: 12 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25193.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 25193, "Background gradients don't work for some views", PlatformAffected.iOS)]
public partial class Issue25193 : ContentPage
{
public Issue25193()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue25193 : _IssuesUITest
{
public Issue25193(TestDevice device) : base(device) { }

public override string Issue => "Background gradients don't work for some views";

[Test]
[Category(UITestCategories.Label)]
[Category(UITestCategories.ScrollView)]
[Category(UITestCategories.Button)]
[Category(UITestCategories.Entry)]
[Category(UITestCategories.Picker)]
public void BackgroundGradientsShouldRenderCorrectly()
{
App.WaitForElement("label");
VerifyScreenshot();
}
}
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.
3 changes: 2 additions & 1 deletion src/Core/src/Handlers/View/ViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ internal static void MapContextFlyout(IElementHandler handler, IContextFlyoutEle
static partial void MappingFrame(IViewHandler handler, IView view)
{
UpdateTransformation(handler, view);
handler.ToPlatform().UpdateBackgroundLayerFrame();
if (handler.VirtualView?.Background is not null)
handler.ToPlatform().UpdateBackgroundLayerFrame();
}

public static void MapTranslationX(IViewHandler handler, IView view)
Expand Down

0 comments on commit b6ea3df

Please sign in to comment.