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

Commit

Permalink
Fix issue with ListView wrong top padding in iOS 15 (#14671)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz authored Oct 7, 2021
1 parent 0e1ba44 commit 9fb6583
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 14664, "[Bug] ImageButton.Aspect Property is always Fill",
PlatformAffected.iOS)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.ListView)]
[NUnit.Framework.Category(UITestCategories.ManualReview)]
#endif
public class Issue14664 : TestContentPage
{
protected override void Init()
{
var layout = new Grid
{
BackgroundColor = Color.Red
};

var listView = new ListView
{
BackgroundColor = Color.Green,
ItemsSource = new string[]
{
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5",
"Item 6",
"Item 7",
"Item 8",
"Item 9"
}
};

layout.Children.Add(listView);

Content = layout;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue10101.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13818.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FrameBackgroundIssue.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14664.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14192.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14505.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14505-II.cs" />
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
_tableViewController = new FormsUITableViewController(e.NewElement, _usingLargeTitles);
SetNativeControl(_tableViewController.TableView);

if (Forms.IsiOS15OrNewer)
_tableViewController.TableView.SectionHeaderTopPadding = new nfloat(0);

_backgroundUIView = _tableViewController.TableView.BackgroundView;

_insetTracker = new KeyboardInsetTracker(_tableViewController.TableView, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
Expand Down

0 comments on commit 9fb6583

Please sign in to comment.