From 961052e806827c15a5ec30e34431d646f3c0962a Mon Sep 17 00:00:00 2001 From: Andrei Date: Tue, 4 Dec 2018 21:17:02 +0300 Subject: [PATCH] [Enhancement] Added GroupHeaderStyle property for iOS specific ListView class (#4616) * Added group header style property for ios specific list view class * removed redundant test line --- .../iOSSpecific/GroupHeaderStyle.cs | 9 ++++++++ .../iOSSpecific/ListView.cs | 23 +++++++++++++++++++ .../Renderers/ListViewRenderer.cs | 5 +++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/GroupHeaderStyle.cs diff --git a/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/GroupHeaderStyle.cs b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/GroupHeaderStyle.cs new file mode 100644 index 000000000..6a8eabe2a --- /dev/null +++ b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/GroupHeaderStyle.cs @@ -0,0 +1,9 @@ + +namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific +{ + public enum GroupHeaderStyle + { + Plain, + Grouped + } +} diff --git a/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ListView.cs b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ListView.cs index 94d78f882..87f2e6e3d 100644 --- a/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ListView.cs +++ b/Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/ListView.cs @@ -26,5 +26,28 @@ SetSeparatorStyle(config.Element, value); return config; } + + public static readonly BindableProperty GroupHeaderStyleProperty = BindableProperty.Create(nameof(GroupHeaderStyle), typeof(GroupHeaderStyle), typeof(FormsElement), GroupHeaderStyle.Plain); + + public static GroupHeaderStyle GetGroupHeaderStyle(BindableObject element) + { + return (GroupHeaderStyle)element.GetValue(GroupHeaderStyleProperty); + } + + public static void SetGroupHeaderStyle(BindableObject element, GroupHeaderStyle value) + { + element.SetValue(GroupHeaderStyleProperty, value); + } + + public static GroupHeaderStyle GetGroupHeaderStyle(this IPlatformElementConfiguration config) + { + return GetGroupHeaderStyle(config.Element); + } + + public static IPlatformElementConfiguration SetGroupHeaderStyle(this IPlatformElementConfiguration config, GroupHeaderStyle value) + { + SetGroupHeaderStyle(config.Element, value); + return config; + } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs index 170132d0c..2fb872c8a 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs @@ -1368,7 +1368,10 @@ namespace Xamarin.Forms.Platform.iOS internal bool _usingLargeTitles; bool _isRefreshing; - public FormsUITableViewController(ListView element, bool usingLargeTitles) + public FormsUITableViewController(ListView element, bool usingLargeTitles) + : base(element.OnThisPlatform().GetGroupHeaderStyle() == GroupHeaderStyle.Plain + ? UITableViewStyle.Plain + : UITableViewStyle.Grouped) { if (Forms.IsiOS9OrNewer) TableView.CellLayoutMarginsFollowReadableWidth = false;