Skip to content

Commit 84a3ccc

Browse files
kubafloPureWeen
authored andcommitted
ScrollView's Background on iOS (#25541)
1 parent 9fd1d54 commit 84a3ccc

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed
23.6 KB
Loading
12.4 KB
Loading
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue24061"
5+
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
6+
<VerticalStackLayout>
7+
<ScrollView Orientation="Horizontal"
8+
x:Name="scrollView"
9+
HeightRequest="120">
10+
11+
<ScrollView.Background>
12+
<LinearGradientBrush StartPoint="0,0.5"
13+
EndPoint="1,0.5">
14+
<LinearGradientBrush.GradientStops>
15+
<GradientStop Color="White"
16+
Offset="0.75"/>
17+
<GradientStop Color="Green"
18+
Offset="1"/>
19+
</LinearGradientBrush.GradientStops>
20+
</LinearGradientBrush>
21+
</ScrollView.Background>
22+
<StackLayout Orientation="Horizontal">
23+
<BindableLayout.ItemsSource>
24+
<x:Array Type="{x:Type x:String}">
25+
<x:String>Item1</x:String>
26+
<x:String>Item2</x:String>
27+
<x:String>Item3</x:String>
28+
<x:String>Item4</x:String>
29+
<x:String>Item5</x:String>
30+
</x:Array>
31+
</BindableLayout.ItemsSource>
32+
<BindableLayout.ItemTemplate>
33+
<DataTemplate>
34+
<BoxView WidthRequest="100"
35+
HeightRequest="100"
36+
AutomationId="{Binding .}"
37+
BackgroundColor="Black"
38+
Margin="10"/>
39+
</DataTemplate>
40+
</BindableLayout.ItemTemplate>
41+
</StackLayout>
42+
</ScrollView>
43+
<Button AutomationId="button"
44+
Clicked="Button_Clicked"
45+
Text="Remove/Add scroll view background"/>
46+
</VerticalStackLayout>
47+
</ContentPage>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
[Issue(IssueTracker.Github, 24061, "ScrollView's gradient background doesn't work with ScrollView", PlatformAffected.iOS)]
4+
public partial class Issue24061 : ContentPage
5+
{
6+
LinearGradientBrush _linearGradientBrush;
7+
8+
public Issue24061()
9+
{
10+
InitializeComponent();
11+
_linearGradientBrush = new LinearGradientBrush
12+
{
13+
StartPoint = new Point(0, 0.5),
14+
EndPoint = new Point(1, 0.5),
15+
GradientStops = new GradientStopCollection
16+
{
17+
new GradientStop { Color = Colors.White, Offset = 0.75f },
18+
new GradientStop { Color = Colors.Green, Offset = 1 }
19+
}
20+
};
21+
scrollView.Background = _linearGradientBrush;
22+
}
23+
24+
private void Button_Clicked(object sender, EventArgs e)
25+
{
26+
if (scrollView.Background != null)
27+
scrollView.Background = null;
28+
else
29+
scrollView.Background = _linearGradientBrush;
30+
}
31+
}
32+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class Issue24061 : _IssuesUITest
8+
{
9+
public Issue24061(TestDevice testDevice) : base(testDevice)
10+
{
11+
}
12+
13+
public override string Issue => "ScrollView's gradient background doesn't work with ScrollView";
14+
15+
[Test]
16+
[Category(UITestCategories.ScrollView)]
17+
public void ScrollViewGradientBackgroundShouldWorkWithScrollView()
18+
{
19+
App.WaitForElement("Item2");
20+
App.SwipeRightToLeft("Item2", 0.99);
21+
22+
VerifyScreenshot("ScrollViewGradientBackground");
23+
App.Click("button");
24+
VerifyScreenshot("ScrollViewWithoutGradientBackground");
25+
App.Click("button");
26+
VerifyScreenshot("ScrollViewGradientBackground");
27+
}
28+
}
29+
}
53.8 KB
Loading
11.3 KB
Loading

0 commit comments

Comments
 (0)