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

Commit 758bdd3

Browse files
committed
Merge branch '4.5.0'
2 parents c5bea02 + 35c8c2c commit 758bdd3

File tree

10 files changed

+326
-37
lines changed

10 files changed

+326
-37
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<controls:TestContentPage
3+
xmlns="http://xamarin.com/schemas/2014/forms"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5+
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
6+
x:Class="Xamarin.Forms.Controls.Issues.Issue8557">
7+
<CollectionView
8+
ItemsSource="{Binding GroupContent}"
9+
IsGrouped="True"
10+
ItemSizingStrategy="{OnPlatform Android=MeasureAllItems, iOS=MeasureFirstItem}">
11+
<CollectionView.GroupHeaderTemplate>
12+
<DataTemplate>
13+
<Grid
14+
ColumnSpacing="0"
15+
Margin="0,30"
16+
BackgroundColor="Yellow">
17+
<Grid.ColumnDefinitions>
18+
<ColumnDefinition Width="*" />
19+
<ColumnDefinition Width="120" />
20+
<ColumnDefinition Width="*" />
21+
</Grid.ColumnDefinitions>
22+
<BoxView
23+
Grid.Column="0"
24+
VerticalOptions="Center"
25+
HeightRequest="1"
26+
BackgroundColor="Gray"/>
27+
<Label
28+
Grid.Column="1"
29+
Text="{Binding Name}"
30+
HorizontalTextAlignment="Center"
31+
VerticalTextAlignment="Center"
32+
FontSize="26"/>
33+
<BoxView
34+
Grid.Column="2"
35+
VerticalOptions="Center"
36+
HeightRequest="1"
37+
BackgroundColor="Gray"/>
38+
</Grid>
39+
</DataTemplate>
40+
</CollectionView.GroupHeaderTemplate>
41+
<CollectionView.ItemsLayout>
42+
<GridItemsLayout
43+
Orientation="Vertical"
44+
Span="2"/>
45+
</CollectionView.ItemsLayout>
46+
<CollectionView.ItemTemplate>
47+
<DataTemplate>
48+
<Frame
49+
HasShadow="false"
50+
Padding="0">
51+
<Label
52+
Text="{Binding Description}"
53+
HorizontalTextAlignment="Center"
54+
VerticalTextAlignment="Center"
55+
HeightRequest="100"/>
56+
</Frame>
57+
</DataTemplate>
58+
</CollectionView.ItemTemplate>
59+
</CollectionView>
60+
</controls:TestContentPage>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Xamarin.Forms.CustomAttributes;
2+
using Xamarin.Forms.Internals;
3+
using Xamarin.Forms.Xaml;
4+
using System.Collections.Generic;
5+
6+
#if UITEST
7+
using Xamarin.UITest;
8+
using Xamarin.UITest.Queries;
9+
using NUnit.Framework;
10+
using Xamarin.Forms.Core.UITests;
11+
using System.Linq;
12+
#endif
13+
14+
namespace Xamarin.Forms.Controls.Issues
15+
{
16+
#if UITEST
17+
[NUnit.Framework.Category(UITestCategories.CollectionView)]
18+
#endif
19+
#if APP
20+
[XamlCompilation(XamlCompilationOptions.Compile)]
21+
#endif
22+
[Preserve(AllMembers = true)]
23+
[Issue(IssueTracker.Github, 8557, "[Bug] Grouped header with incorrect size when use GridItemsLayout with two columns on the CollectionView", PlatformAffected.iOS)]
24+
public partial class Issue8557 : TestContentPage
25+
{
26+
#if APP
27+
public Issue8557()
28+
{
29+
InitializeComponent();
30+
31+
BindingContext = new Issue8557ViewModel();
32+
}
33+
#endif
34+
35+
protected override void Init()
36+
{
37+
38+
}
39+
}
40+
41+
[Preserve(AllMembers = true)]
42+
public class Issue8557Model
43+
{
44+
public string Description { get; set; }
45+
}
46+
47+
[Preserve(AllMembers = true)]
48+
public class Issue8557GroupModel : List<Issue8557Model>
49+
{
50+
public string Name { get; set; }
51+
52+
public Issue8557GroupModel(string name, List<Issue8557Model> data) : base(data)
53+
{
54+
Name = name;
55+
}
56+
}
57+
58+
[Preserve(AllMembers = true)]
59+
public class Issue8557ViewModel
60+
{
61+
public List<Issue8557GroupModel> GroupContent { get; private set; }
62+
63+
public Issue8557ViewModel()
64+
{
65+
GroupContent = new List<Issue8557GroupModel>
66+
{
67+
new Issue8557GroupModel(
68+
"Group 1",
69+
new List<Issue8557Model>
70+
{
71+
new Issue8557Model { Description = "Description 1.1" },
72+
new Issue8557Model { Description = "Description 1.2" },
73+
new Issue8557Model { Description = "Description 1.3" },
74+
new Issue8557Model { Description = "Description 1.4" }
75+
}
76+
),
77+
new Issue8557GroupModel(
78+
"Group 2",
79+
new List<Issue8557Model>
80+
{
81+
new Issue8557Model { Description = "Description 2.1" },
82+
new Issue8557Model { Description = "Description 2.2" },
83+
new Issue8557Model { Description = "Description 2.3" },
84+
new Issue8557Model { Description = "Description 2.4" }
85+
}
86+
)
87+
};
88+
}
89+
}
90+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<controls:TestContentPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
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+
x:Class="Xamarin.Forms.Controls.Issues.Issue9196">
9+
<ContentPage.Content>
10+
<StackLayout>
11+
12+
<Label Text="Success"/>
13+
14+
<CollectionView x:Name="ReceiptsCollection" SelectionMode="Single" ItemSizingStrategy="MeasureAllItems"
15+
ItemsSource="{Binding ReceiptsList}">
16+
17+
<CollectionView.EmptyView>
18+
<StackLayout Padding="30">
19+
<Label Text="No Receipt Available" HorizontalTextAlignment="Center"
20+
VerticalTextAlignment="Center" LineBreakMode="WordWrap" Margin="0,10"></Label>
21+
</StackLayout>
22+
</CollectionView.EmptyView>
23+
24+
<CollectionView.ItemTemplate>
25+
<DataTemplate>
26+
<StackLayout>
27+
<Grid Padding="10">
28+
<Grid.RowDefinitions>
29+
<RowDefinition Height="Auto"/>
30+
<RowDefinition Height="Auto"/>
31+
</Grid.RowDefinitions>
32+
<Grid.ColumnDefinitions>
33+
<ColumnDefinition Width="2*"/>
34+
<ColumnDefinition Width="1*"/>
35+
</Grid.ColumnDefinitions>
36+
<Label VerticalOptions="CenterAndExpand"
37+
Text="DateTime"/>
38+
<Label VerticalOptions="CenterAndExpand" FontAttributes="Bold" Grid.Column="1"
39+
HorizontalTextAlignment="End">
40+
<Label.FormattedText>
41+
<FormattedString>
42+
<Span Text="$" />
43+
<Span Text="100" />
44+
</FormattedString>
45+
</Label.FormattedText>
46+
</Label>
47+
<Label VerticalOptions="CenterAndExpand" Grid.Row="1" Grid.ColumnSpan="2"
48+
Text="Item"/>
49+
</Grid>
50+
</StackLayout>
51+
</DataTemplate>
52+
</CollectionView.ItemTemplate>
53+
</CollectionView>
54+
</StackLayout>
55+
</ContentPage.Content>
56+
</controls:TestContentPage>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using Xamarin.Forms;
8+
using Xamarin.Forms.CustomAttributes;
9+
using Xamarin.Forms.Xaml;
10+
11+
#if UITEST
12+
using Xamarin.Forms.Core.UITests;
13+
using Xamarin.UITest;
14+
using NUnit.Framework;
15+
#endif
16+
17+
namespace Xamarin.Forms.Controls.Issues
18+
{
19+
[Issue(IssueTracker.Github, 9196, "[Bug] [iOS] CollectionView EmptyView causes the application to crash",
20+
PlatformAffected.iOS)]
21+
public partial class Issue9196 : TestContentPage
22+
{
23+
public Issue9196()
24+
{
25+
#if APP
26+
InitializeComponent();
27+
#endif
28+
}
29+
30+
protected override void Init()
31+
{
32+
BindingContext = new _9196ViewModel();
33+
}
34+
35+
#if UITEST
36+
[Test, Category(UITestCategories.CollectionView)]
37+
public void EmptyViewShouldNotCrash()
38+
{
39+
RunningApp.WaitForElement("Success");
40+
}
41+
#endif
42+
}
43+
44+
public class _9196ViewModel
45+
{
46+
public _9196ViewModel()
47+
{
48+
ReceiptsList = new List<string>();
49+
}
50+
51+
public List<string> ReceiptsList { get; set; }
52+
}
53+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@
175175
<Compile Include="$(MSBuildThisFileDirectory)Issue8743.cs" />
176176
<Compile Include="$(MSBuildThisFileDirectory)Issue9092.cs" />
177177
<Compile Include="$(MSBuildThisFileDirectory)Issue9087.cs" />
178+
<Compile Include="$(MSBuildThisFileDirectory)Issue9196.xaml.cs">
179+
<DependentUpon>Issue9196.xaml</DependentUpon>
180+
<SubType>Code</SubType>
181+
</Compile>
178182
<Compile Include="$(MSBuildThisFileDirectory)Issue9355.cs" />
179183
<Compile Include="$(MSBuildThisFileDirectory)Issue8784.cs" />
180184
<Compile Include="$(MSBuildThisFileDirectory)Issue9360.cs" />
@@ -1252,6 +1256,7 @@
12521256
<Compile Include="$(MSBuildThisFileDirectory)Issue8417.xaml.cs" />
12531257
<Compile Include="$(MSBuildThisFileDirectory)Issue8647.cs" />
12541258
<Compile Include="$(MSBuildThisFileDirectory)Issue7510.cs" />
1259+
<Compile Include="$(MSBuildThisFileDirectory)Issue8557.xaml.cs" />
12551260
<Compile Include="$(MSBuildThisFileDirectory)Issue8753.cs" />
12561261
<Compile Include="$(MSBuildThisFileDirectory)Issue8693.cs" />
12571262
<Compile Include="$(MSBuildThisFileDirectory)Issue7813.xaml.cs" />
@@ -1414,6 +1419,7 @@
14141419
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue6932_emptyviewtemplate.xaml" />
14151420
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue6932_emptyviewstring.xaml" />
14161421
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8417.xaml" />
1422+
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8557.xaml" />
14171423
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue7813.xaml" />
14181424
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8638.xaml" />
14191425
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8779.xaml" />
@@ -1831,4 +1837,10 @@
18311837
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
18321838
</EmbeddedResource>
18331839
</ItemGroup>
1840+
<ItemGroup>
1841+
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue9196.xaml">
1842+
<SubType>Designer</SubType>
1843+
<Generator>MSBuild:Compile</Generator>
1844+
</EmbeddedResource>
1845+
</ItemGroup>
18341846
</Project>

Xamarin.Forms.Platform.Android/CollectionView/IndicatorViewRenderer.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,8 @@ void SetUpNewElement(IndicatorView newElement)
198198
UpdateItemsSource();
199199

200200
ElevationHelper.SetElevation(this, newElement);
201-
}
202201

203-
void IndicatorsViewItemSourcePropertyChanged(object sender, PropertyChangedEventArgs changedProperty)
204-
{
205-
if (changedProperty.Is(ItemsView.ItemsSourceProperty))
206-
{
207-
UpdateItemsSource();
208-
}
209-
else if (changedProperty.Is(SelectableItemsView.SelectedItemProperty))
210-
{
211-
UpdateSelectedIndicator();
212-
}
202+
UpdateSelectedIndicator();
213203
}
214204

215205
void UpdateSelectedIndicator()

Xamarin.Forms.Platform.iOS/CollectionView/GroupableItemsViewController.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void UpdateDefaultSupplementaryView(DefaultCell cell, NSString elementKind, NSIn
8888

8989
if (cell is ItemsViewCell)
9090
{
91-
cell.ConstrainTo(ItemsViewLayout.ConstrainedDimension);
91+
cell.ConstrainTo(GetLayoutSpanCount() * ItemsViewLayout.ConstrainedDimension);
9292
}
9393
}
9494

@@ -104,7 +104,7 @@ void UpdateTemplatedSupplementaryView(TemplatedCell cell, NSString elementKind,
104104

105105
if (cell is ItemsViewCell)
106106
{
107-
cell.ConstrainTo(ItemsViewLayout.ConstrainedDimension);
107+
cell.ConstrainTo(GetLayoutSpanCount() * ItemsViewLayout.ConstrainedDimension);
108108
}
109109
}
110110

@@ -172,6 +172,18 @@ internal void HandleScrollAnimationEnded()
172172
_scrollAnimationEndedCallback = null;
173173
}
174174

175+
int GetLayoutSpanCount()
176+
{
177+
var span = 1;
178+
179+
if (ItemsView?.ItemsLayout is GridItemsLayout gridItemsLayout)
180+
{
181+
span = gridItemsLayout.Span;
182+
}
183+
184+
return span;
185+
}
186+
175187
internal UIEdgeInsets GetInsetForSection(ItemsViewLayout itemsViewLayout,
176188
UICollectionView collectionView, nint section)
177189
{

0 commit comments

Comments
 (0)