From ecc15363b5209256f1bda9e5c1796af21a02bf6f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 15 Jun 2016 23:39:49 -0400 Subject: [PATCH] Added listview renderer that implements margins as contentinset. Added margin to vault listview. --- src/App/Pages/VaultListSitesPage.cs | 1 + src/iOS/Controls/ExtendedTextCellRenderer.cs | 3 +- src/iOS/Controls/ListViewRenderer.cs | 41 ++++++++++++++++++++ src/iOS/iOS.csproj | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/iOS/Controls/ListViewRenderer.cs diff --git a/src/App/Pages/VaultListSitesPage.cs b/src/App/Pages/VaultListSitesPage.cs index 2d0d46ef1..8c7c50a3f 100644 --- a/src/App/Pages/VaultListSitesPage.cs +++ b/src/App/Pages/VaultListSitesPage.cs @@ -44,6 +44,7 @@ namespace Bit.App.Pages var listView = new ListView { + Margin = new Thickness(0, 0, -15, 0), IsGroupingEnabled = true, ItemsSource = Folders, HasUnevenRows = true, diff --git a/src/iOS/Controls/ExtendedTextCellRenderer.cs b/src/iOS/Controls/ExtendedTextCellRenderer.cs index 2e7eb705f..f54fadd75 100644 --- a/src/iOS/Controls/ExtendedTextCellRenderer.cs +++ b/src/iOS/Controls/ExtendedTextCellRenderer.cs @@ -35,8 +35,7 @@ namespace Bit.iOS.Controls detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected); } - detailDisclosureButton.Frame = new CGRect(0f, 0f, 40f, 40f); - detailDisclosureButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right; + detailDisclosureButton.Frame = new CGRect(0f, 0f, 50f, 40f); detailDisclosureButton.TouchUpInside += (sender, e) => { extendedCell.OnDisclousureTapped(); diff --git a/src/iOS/Controls/ListViewRenderer.cs b/src/iOS/Controls/ListViewRenderer.cs new file mode 100644 index 000000000..661c745f4 --- /dev/null +++ b/src/iOS/Controls/ListViewRenderer.cs @@ -0,0 +1,41 @@ +using System; +using System.ComponentModel; +using UIKit; +using Xamarin.Forms; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(ListView), typeof(Bit.iOS.Controls.ListViewRenderer))] +namespace Bit.iOS.Controls +{ + public class ListViewRenderer : Xamarin.Forms.Platform.iOS.ListViewRenderer + { + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + var view = e.NewElement as ListView; + if(view != null) + { + SetMargin(view); + } + } + + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + base.OnElementPropertyChanged(sender, e); + if(e.PropertyName == View.MarginProperty.PropertyName) + { + SetMargin(Element); + } + } + + private void SetMargin(ListView view) + { + Control.ContentInset = new UIEdgeInsets( + new nfloat(view.Margin.Top), + new nfloat(view.Margin.Left), + new nfloat(view.Margin.Bottom), + new nfloat(view.Margin.Right)); + } + } +} diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index d159e8b75..2e8c57ba2 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -109,6 +109,7 @@ +