Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit d1af641

Browse files
[iOS] Fix Brush issue in Shapes after swipes in CarouselView (#13386)
* Added repro sample * Fix the issue Co-authored-by: Rui Marinho <me@ruimarinho.net>
1 parent eefa372 commit d1af641

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<local:TestContentPage
3+
xmlns="http://xamarin.com/schemas/2014/forms"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
mc:Ignorable="d"
8+
Title="Test 13376" xmlns:local="using:Xamarin.Forms.Controls"
9+
x:Class="Xamarin.Forms.Controls.Issues.Issue13376">
10+
<StackLayout>
11+
<Label
12+
Padding="12"
13+
BackgroundColor="Black"
14+
TextColor="White"
15+
Text="Swipe and passes at least twice for each item, if the Ellipse is always rendered correctly the test has passed."/>
16+
<CarouselView
17+
ItemsSource="{Binding Items}">
18+
<CarouselView.ItemTemplate>
19+
<DataTemplate>
20+
<Grid RowDefinitions="*,*">
21+
<Ellipse
22+
Stroke="Red"
23+
Fill="Yellow"
24+
VerticalOptions="Center"
25+
HeightRequest="200"
26+
HorizontalOptions="Center"
27+
WidthRequest="200"/>
28+
<Label
29+
x:Name="GreenLabel"
30+
Text="{Binding Text}"
31+
TextColor="DarkGreen"
32+
FontSize="Large"
33+
Grid.Row="0"
34+
VerticalOptions="Center"
35+
HorizontalOptions="Center"/>
36+
<Ellipse
37+
Fill="Gray"
38+
Grid.Row="1"
39+
VerticalOptions="Center"
40+
HeightRequest="200"
41+
HorizontalOptions="Center"
42+
WidthRequest="200"/>
43+
</Grid>
44+
</DataTemplate>
45+
</CarouselView.ItemTemplate>
46+
</CarouselView>
47+
</StackLayout>
48+
</local:TestContentPage>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System.Collections.Generic;
2+
using System.Collections.ObjectModel;
3+
using Xamarin.Forms.CustomAttributes;
4+
using Xamarin.Forms.Internals;
5+
6+
#if UITEST
7+
using Xamarin.UITest;
8+
using NUnit.Framework;
9+
using Xamarin.Forms.Core.UITests;
10+
#endif
11+
12+
namespace Xamarin.Forms.Controls.Issues
13+
{
14+
[Preserve(AllMembers = true)]
15+
[Issue(IssueTracker.Github, 13376,
16+
"[Bug] [iOS] Brush color lost on swiping",
17+
PlatformAffected.iOS)]
18+
public partial class Issue13376 : TestContentPage
19+
{
20+
public Issue13376()
21+
{
22+
#if APP
23+
InitializeComponent();
24+
BindingContext = new Issue13376ViewModel();
25+
#endif
26+
}
27+
28+
protected override void Init()
29+
{
30+
}
31+
}
32+
33+
[Preserve(AllMembers = true)]
34+
public class Issue13376Model
35+
{
36+
public Issue13376Model(string text)
37+
{
38+
Text = text;
39+
}
40+
41+
public string Text { get; }
42+
}
43+
44+
[Preserve(AllMembers = true)]
45+
public class Issue13376ViewModel
46+
{
47+
public Issue13376ViewModel()
48+
{
49+
Items = new List<Issue13376Model>
50+
{
51+
new Issue13376Model("Item 1"),
52+
new Issue13376Model("Item 2"),
53+
new Issue13376Model("Item 3"),
54+
new Issue13376Model("Item 4"),
55+
new Issue13376Model("Item 5"),
56+
};
57+
}
58+
59+
public List<Issue13376Model> Items { get; }
60+
}
61+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@
17211721
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutBackground.cs" />
17221722
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutContentOffest.cs" />
17231723
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutContentWithZeroMargin.cs" />
1724+
<Compile Include="$(MSBuildThisFileDirectory)Issue13376.xaml.cs" />
17241725
<Compile Include="$(MSBuildThisFileDirectory)LabelFormattedTextHtmlPadding.cs" />
17251726
<Compile Include="$(MSBuildThisFileDirectory)Issue13436.xaml.cs" />
17261727
<Compile Include="$(MSBuildThisFileDirectory)Issue12259.cs" />
@@ -2122,6 +2123,9 @@
21222123
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13136.xaml">
21232124
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
21242125
</EmbeddedResource>
2126+
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13376.xaml">
2127+
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
2128+
</EmbeddedResource>
21252129
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue12521.xaml">
21262130
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
21272131
</EmbeddedResource>

Xamarin.Forms.Platform.iOS/Shapes/ShapeRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<TShape> args)
4242
{
4343
_height = Element.Height;
4444
_width = Element.Width;
45+
4546
UpdateSize();
4647
}
4748
}

0 commit comments

Comments
 (0)