From 84836fe89b83e5938850d9f71111e54a7251d770 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 29 Jun 2016 00:34:20 -0400 Subject: [PATCH] adjusting cells for vault list view --- .../Controls/ExtendedViewCellRenderer.cs | 4 ++-- src/App/Controls/LabeledDetailCell.cs | 2 +- src/App/Models/Page/VaultListPageModel.cs | 2 +- src/App/Pages/VaultListSitesPage.cs | 24 +++++++++++++------ src/iOS/Controls/ExtendedTextCellRenderer.cs | 2 +- src/iOS/Controls/ExtendedViewCellRenderer.cs | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Android/Controls/ExtendedViewCellRenderer.cs b/src/Android/Controls/ExtendedViewCellRenderer.cs index dcac0eb3a..432bcdb51 100644 --- a/src/Android/Controls/ExtendedViewCellRenderer.cs +++ b/src/Android/Controls/ExtendedViewCellRenderer.cs @@ -17,7 +17,7 @@ namespace Bit.Android.Controls protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context) { - var View = (BaseCellView)base.GetCellCore(item, convertView, parent, context); + var View = base.GetCellCore(item, convertView, parent, context); var extendedCell = (ExtendedViewCell)item; if(View != null) @@ -37,7 +37,7 @@ namespace Bit.Android.Controls var image = new DisclosureImage(context, extendedCell); image.SetImageResource(resourceId); image.SetPadding(10, 10, 30, 10); - View.SetAccessoryView(image); + //View.SetAccessoryView(image); } } diff --git a/src/App/Controls/LabeledDetailCell.cs b/src/App/Controls/LabeledDetailCell.cs index 6fd7207ce..d6fb8d347 100644 --- a/src/App/Controls/LabeledDetailCell.cs +++ b/src/App/Controls/LabeledDetailCell.cs @@ -22,7 +22,7 @@ namespace Bit.App.Controls var stackLayout = new StackLayout { - Padding = new Thickness(15, 5), + Padding = new Thickness(20, 5), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Children = { Label, Detail }, diff --git a/src/App/Models/Page/VaultListPageModel.cs b/src/App/Models/Page/VaultListPageModel.cs index 3576aaed8..4d3fd73d8 100644 --- a/src/App/Models/Page/VaultListPageModel.cs +++ b/src/App/Models/Page/VaultListPageModel.cs @@ -15,7 +15,7 @@ namespace Bit.App.Models.Page Id = site.Id; FolderId = folderId; Name = site.Name?.Decrypt(); - Username = site.Username?.Decrypt(); + Username = site.Username?.Decrypt() ?? " "; Password = site.Password?.Decrypt(); Uri = site.Uri?.Decrypt(); } diff --git a/src/App/Pages/VaultListSitesPage.cs b/src/App/Pages/VaultListSitesPage.cs index f3bf969fa..bb233d5a5 100644 --- a/src/App/Pages/VaultListSitesPage.cs +++ b/src/App/Pages/VaultListSitesPage.cs @@ -12,6 +12,7 @@ using XLabs.Ioc; using Bit.App.Utilities; using PushNotification.Plugin.Abstractions; using Plugin.Settings.Abstractions; +using System.Windows.Input; namespace Bit.App.Pages { @@ -55,10 +56,13 @@ namespace Bit.App.Pages GroupHeaderTemplate = new DataTemplate(() => new VaultListHeaderViewCell(this)), ItemTemplate = new DataTemplate(() => new VaultListViewCell(this)) }; + if(Device.OS == TargetPlatform.iOS) { listView.Margin = new Thickness(0, 0, -15, 0); + listView.RowHeight = -1; } + listView.ItemSelected += SiteSelected; Title = _favorites ? AppResources.Favorites : AppResources.MyVault; @@ -183,6 +187,9 @@ namespace Bit.App.Pages { private VaultListSitesPage _page; + public static readonly BindableProperty SiteParameterProperty = BindableProperty.Create(nameof(SiteParameter), + typeof(VaultListPageModel.Site), typeof(VaultListViewCell), null); + public VaultListViewCell(VaultListSitesPage page) { _page = page; @@ -196,7 +203,7 @@ namespace Bit.App.Pages moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); moreAction.Clicked += MoreAction_Clicked; - //SetBinding(CommandParameterProperty, new Binding(".")); + SetBinding(SiteParameterProperty, new Binding(".")); Label.SetBinding(Label.TextProperty, s => s.Name); Detail.SetBinding(Label.TextProperty, s => s.Username); @@ -208,6 +215,12 @@ namespace Bit.App.Pages DisclousureImage = "more"; } + public VaultListPageModel.Site SiteParameter + { + get { return GetValue(SiteParameterProperty) as VaultListPageModel.Site; } + set { SetValue(SiteParameterProperty, value); } + } + private void MoreAction_Clicked(object sender, EventArgs e) { var menuItem = sender as MenuItem; @@ -218,8 +231,7 @@ namespace Bit.App.Pages private void VaultListViewCell_DisclousureTapped(object sender, EventArgs e) { var cell = sender as VaultListViewCell; - //var site = cell.CommandParameter as VaultListPageModel.Site; - // _page.MoreClickedAsync(site); + _page.MoreClickedAsync(cell.SiteParameter); } } @@ -230,7 +242,6 @@ namespace Bit.App.Pages var image = new Image { Source = "fa_folder_open.png", - Margin = new Thickness(16, 0, 0, 0), VerticalOptions = LayoutOptions.CenterAndExpand }; @@ -238,7 +249,6 @@ namespace Bit.App.Pages { VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.CenterAndExpand, - FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; @@ -249,11 +259,11 @@ namespace Bit.App.Pages Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, Children = { image, label }, - BackgroundColor = Color.FromHex("efeff4") + BackgroundColor = Color.FromHex("efeff4"), + Padding = new Thickness(16, 0, 0, 0) }; View = stackLayout; - Height = 30; } } } diff --git a/src/iOS/Controls/ExtendedTextCellRenderer.cs b/src/iOS/Controls/ExtendedTextCellRenderer.cs index f54fadd75..985ec8f9c 100644 --- a/src/iOS/Controls/ExtendedTextCellRenderer.cs +++ b/src/iOS/Controls/ExtendedTextCellRenderer.cs @@ -35,7 +35,7 @@ namespace Bit.iOS.Controls detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected); } - detailDisclosureButton.Frame = new CGRect(0f, 0f, 50f, 40f); + detailDisclosureButton.Frame = new CGRect(0f, 0f, 50f, 100f); detailDisclosureButton.TouchUpInside += (sender, e) => { extendedCell.OnDisclousureTapped(); diff --git a/src/iOS/Controls/ExtendedViewCellRenderer.cs b/src/iOS/Controls/ExtendedViewCellRenderer.cs index d983f9746..d234dce44 100644 --- a/src/iOS/Controls/ExtendedViewCellRenderer.cs +++ b/src/iOS/Controls/ExtendedViewCellRenderer.cs @@ -35,7 +35,7 @@ namespace Bit.iOS.Controls detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected); } - detailDisclosureButton.Frame = new CGRect(0f, 0f, 50f, 40f); + detailDisclosureButton.Frame = new CGRect(0f, 0f, 50f, 100f); detailDisclosureButton.TouchUpInside += (sender, e) => { extendedCell.OnDisclousureTapped();