Performance tuning layouts: remove stack layouts in favor of grid.

This commit is contained in:
Kyle Spearrin 2016-12-18 00:19:14 -05:00
parent 7bc38a35e8
commit 83985965f2
2 changed files with 25 additions and 29 deletions

View File

@ -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; }

View File

@ -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<VaultListPageModel.Folder>(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");
}
}