From 83985965f25c5611a233f38222341c6b5d2f9f9e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 18 Dec 2016 00:19:14 -0500 Subject: [PATCH] Performance tuning layouts: remove stack layouts in favor of grid. --- src/App/Controls/LabeledDetailCell.cs | 33 ++++++++++------------- src/App/Pages/Vault/VaultListSitesPage.cs | 21 ++++++++------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/App/Controls/LabeledDetailCell.cs b/src/App/Controls/LabeledDetailCell.cs index b3961353c..152c9701d 100644 --- a/src/App/Controls/LabeledDetailCell.cs +++ b/src/App/Controls/LabeledDetailCell.cs @@ -19,37 +19,32 @@ namespace Bit.App.Controls Style = (Style)Application.Current.Resources["text-muted"] }; - var labelDetailStackLayout = new StackLayout - { - HorizontalOptions = LayoutOptions.StartAndExpand, - VerticalOptions = LayoutOptions.CenterAndExpand, - Children = { Label, Detail }, - Padding = Device.OnPlatform( - iOS: new Thickness(15, 5, 5, 5), - Android: new Thickness(15, 0, 5, 5), - WinPhone: new Thickness(15, 5, 5, 5)), - Spacing = 0 - }; - Button = new ExtendedButton { - HorizontalOptions = LayoutOptions.End, - VerticalOptions = LayoutOptions.CenterAndExpand, - WidthRequest = 50 + WidthRequest = 60 }; - var containerStackLayout = new StackLayout + var grid = new Grid { - Orientation = StackOrientation.Horizontal, - Children = { labelDetailStackLayout, Button } + ColumnSpacing = 0, + RowSpacing = 0, + Padding = new Thickness(15, 3, 0, 3) }; + grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); + grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); + grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); + grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60, GridUnitType.Absolute) }); + grid.Children.Add(Label, 0, 0); + grid.Children.Add(Detail, 0, 1); + grid.Children.Add(Button, 1, 0); + Grid.SetRowSpan(Button, 2); if(Device.OS == TargetPlatform.Android) { Label.TextColor = Color.Black; } - View = containerStackLayout; + View = grid; } public Label Label { get; private set; } diff --git a/src/App/Pages/Vault/VaultListSitesPage.cs b/src/App/Pages/Vault/VaultListSitesPage.cs index 76966d374..cd5b16487 100644 --- a/src/App/Pages/Vault/VaultListSitesPage.cs +++ b/src/App/Pages/Vault/VaultListSitesPage.cs @@ -473,29 +473,30 @@ namespace Bit.App.Pages var image = new Image { Source = "folder", - VerticalOptions = LayoutOptions.CenterAndExpand + WidthRequest = 18, + HeightRequest = 18 }; var label = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), - VerticalTextAlignment = TextAlignment.Center, - VerticalOptions = LayoutOptions.CenterAndExpand, Style = (Style)Application.Current.Resources["text-muted"] }; label.SetBinding(Label.TextProperty, s => s.Name); - var stackLayout = new StackLayout + var grid = new Grid { - Orientation = StackOrientation.Horizontal, - VerticalOptions = LayoutOptions.FillAndExpand, - Children = { image, label }, - Padding = new Thickness(16, 0, 0, 0) + ColumnSpacing = 10, + Padding = new Thickness(16, 8, 0, 8) }; + grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); + grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(18, GridUnitType.Absolute) }); + grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); + grid.Children.Add(image, 0, 0); + grid.Children.Add(label, 1, 0); - View = stackLayout; - Height = 40; + View = grid; BackgroundColor = Color.FromHex("efeff4"); } }