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

Commit 204380d

Browse files
committed
Merge branch '4.8.0' into 5.0.0
2 parents 3fce598 + 0a742b2 commit 204380d

File tree

5 files changed

+148
-4
lines changed

5 files changed

+148
-4
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using System.Collections.Generic;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
using System.Runtime.CompilerServices;
5+
using System.Windows.Input;
6+
using NUnit.Framework;
7+
using Xamarin.Forms.CustomAttributes;
8+
using Xamarin.Forms.Markup;
9+
10+
namespace Xamarin.Forms.Controls.Issues
11+
{
12+
[Issue(IssueTracker.None, 11311, "[Regression] CollectionView NSRangeException", PlatformAffected.iOS)]
13+
public class Issue11311 : TestTabbedPage
14+
{
15+
const string Success = "Success";
16+
17+
protected override void Init()
18+
{
19+
Device.SetFlags(new[] { "Markup_Experimental" });
20+
21+
Children.Add(FirstPage());
22+
Children.Add(CollectionViewPage());
23+
}
24+
25+
ContentPage FirstPage()
26+
{
27+
var firstPage = new ContentPage
28+
{
29+
Title = "The first page",
30+
Content = new Label { Text = Success }
31+
};
32+
33+
firstPage.Appearing += (sender, args) => {
34+
if (firstPage.Parent is TabbedPage tabbedPage
35+
&& tabbedPage.Children[1] is ContentPage collectionViewPage
36+
&& collectionViewPage.Content is RefreshView refreshView)
37+
{
38+
refreshView.IsRefreshing = true;
39+
}
40+
};
41+
42+
return firstPage;
43+
}
44+
45+
ContentPage CollectionViewPage()
46+
{
47+
BindingContext = new _11311ViewModel();
48+
49+
var refreshView = new RefreshView
50+
{
51+
Content = new CollectionView
52+
{
53+
Footer = new BoxView { BackgroundColor = Color.Red, HeightRequest = 53 }
54+
}.Bind(ItemsView.ItemsSourceProperty, nameof(_11311ViewModel.ScoreCollectionList))
55+
56+
}.Bind(RefreshView.CommandProperty, nameof(_11311ViewModel.PopulateCollectionCommand))
57+
.Bind(RefreshView.IsRefreshingProperty, nameof(_11311ViewModel.IsRefreshing));
58+
59+
var page = new ContentPage
60+
{
61+
Title = "CollectionView Page",
62+
Content = refreshView
63+
};
64+
65+
return page;
66+
}
67+
68+
class _11311ViewModel : INotifyPropertyChanged
69+
{
70+
bool _isRefreshing;
71+
IEnumerable<int> _scoreCollectionList;
72+
73+
public _11311ViewModel()
74+
{
75+
PopulateCollectionCommand = new Command(ExecuteRefreshCommand);
76+
_scoreCollectionList = Enumerable.Empty<int>();
77+
}
78+
79+
public event PropertyChangedEventHandler PropertyChanged;
80+
81+
public ICommand PopulateCollectionCommand { get; }
82+
83+
public IEnumerable<int> ScoreCollectionList
84+
{
85+
get => _scoreCollectionList;
86+
set
87+
{
88+
_scoreCollectionList = value;
89+
OnPropertyChanged();
90+
}
91+
}
92+
93+
public bool IsRefreshing
94+
{
95+
get => _isRefreshing;
96+
set
97+
{
98+
if (IsRefreshing != value)
99+
{
100+
_isRefreshing = value;
101+
OnPropertyChanged();
102+
}
103+
}
104+
}
105+
106+
void ExecuteRefreshCommand()
107+
{
108+
ScoreCollectionList = Enumerable.Range(0, 100);
109+
IsRefreshing = false;
110+
}
111+
112+
void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
113+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
114+
}
115+
116+
#if UITEST
117+
[Test]
118+
public void CollectionViewWithFooterShouldNotCrashOnDisplay()
119+
{
120+
// If this hasn't already crashed, the test is passing
121+
RunningApp.WaitForElement(Success);
122+
}
123+
#endif
124+
}
125+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
<Compile Include="$(MSBuildThisFileDirectory)Issue11137.cs" />
3838
<Compile Include="$(MSBuildThisFileDirectory)Issue11106.cs" />
3939
<Compile Include="$(MSBuildThisFileDirectory)Issue11251.cs" />
40-
<Compile Include="$(MSBuildThisFileDirectory)Issue11259.cs" />
4140
<Compile Include="$(MSBuildThisFileDirectory)Issue11523.cs" />
41+
<Compile Include="$(MSBuildThisFileDirectory)Issue11259.cs" />
42+
<Compile Include="$(MSBuildThisFileDirectory)Issue11311.cs" />
4243
<Compile Include="$(MSBuildThisFileDirectory)Issue8291.cs" />
4344
<Compile Include="$(MSBuildThisFileDirectory)Issue2674.cs" />
4445
<Compile Include="$(MSBuildThisFileDirectory)Issue6484.cs" />

Xamarin.Forms.Platform.Android/Platform.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,13 @@ public static SizeRequest GetNativeSize(VisualElement view, double widthConstrai
13291329
{
13301330
Performance.Start(out string reference);
13311331

1332-
// FIXME: potential crash
13331332
IVisualElementRenderer visualElementRenderer = GetRenderer(view);
13341333

1334+
if (visualElementRenderer == null || visualElementRenderer.View.IsDisposed())
1335+
{
1336+
return new SizeRequest(Size.Zero, Size.Zero);
1337+
}
1338+
13351339
var context = visualElementRenderer.View.Context;
13361340

13371341
// negative numbers have special meanings to android they don't to us

Xamarin.Forms.Platform.Tizen/FormsApplication.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using ElmSharp.Wearable;
1212
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.Application;
1313
using Xamarin.Forms.Platform.Tizen.Native;
14+
using Tizen.Common;
1415

1516
namespace Xamarin.Forms.Platform.Tizen
1617
{
@@ -60,6 +61,12 @@ protected override void OnPreCreate()
6061
base.OnPreCreate();
6162
Application.ClearCurrent();
6263

64+
if (DotnetUtil.TizenAPIVersion < 5)
65+
{
66+
// We should set the env variable to support IsolatedStorageFile on tizen 4.0 or lower version.
67+
Environment.SetEnvironmentVariable("XDG_DATA_HOME", Current.DirectoryInfo.Data);
68+
}
69+
6370
var type = typeof(Window);
6471
// Use reflection to avoid breaking compatibility. ElmSharp.Window.CreateWindow() is has been added since API6.
6572
var methodInfo = type.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static);

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,16 @@ void UpdateHeaderFooterPosition()
205205
_headerUIView.Frame = new CoreGraphics.CGRect(0, -headerHeight, CollectionView.Frame.Width, headerHeight);
206206
}
207207

208-
if (_footerUIView != null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || emptyHeight > 0))
208+
nfloat height = 0;
209+
210+
if (IsViewLoaded && View.Window != null)
211+
{
212+
height = ItemsViewLayout.CollectionViewContentSize.Height;
213+
}
214+
215+
if (_footerUIView != null && (_footerUIView.Frame.Y != height || emptyHeight > 0))
209216
{
210-
_footerUIView.Frame = new CoreGraphics.CGRect(0, ItemsViewLayout.CollectionViewContentSize.Height + emptyHeight, CollectionView.Frame.Width, footerHeight);
217+
_footerUIView.Frame = new CoreGraphics.CGRect(0, height + emptyHeight, CollectionView.Frame.Width, footerHeight);
211218
}
212219
}
213220
}

0 commit comments

Comments
 (0)