2016-05-18 04:28:19 +03:00
|
|
|
|
using Xamarin.Forms;
|
2016-05-14 02:57:07 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
2016-05-18 04:28:19 +03:00
|
|
|
|
public class LabeledValueCell : ExtendedViewCell
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
|
|
|
|
public LabeledValueCell(
|
2016-05-14 08:34:42 +03:00
|
|
|
|
string labelText = null,
|
2016-05-14 02:57:07 +03:00
|
|
|
|
string valueText = null,
|
2016-05-14 08:34:42 +03:00
|
|
|
|
string button1Text = null,
|
|
|
|
|
string button2Text = null)
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-05-17 06:54:24 +03:00
|
|
|
|
var containerStackLayout = new StackLayout
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-06-14 03:03:16 +03:00
|
|
|
|
Padding = new Thickness(15, 10),
|
2016-05-17 06:54:24 +03:00
|
|
|
|
Orientation = StackOrientation.Horizontal
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var labelValueStackLayout = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
HorizontalOptions = LayoutOptions.StartAndExpand,
|
2016-08-14 07:54:07 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(labelText != null)
|
|
|
|
|
{
|
|
|
|
|
Label = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = labelText,
|
2016-06-28 03:56:59 +03:00
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
|
2016-08-14 07:54:07 +03:00
|
|
|
|
Style = (Style)Application.Current.Resources["text-muted"]
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
labelValueStackLayout.Children.Add(Label);
|
2016-05-14 02:57:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Value = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = valueText,
|
2016-07-01 01:53:43 +03:00
|
|
|
|
FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
|
2016-08-14 07:54:07 +03:00
|
|
|
|
LineBreakMode = LineBreakMode.TailTruncation
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-08-14 07:54:07 +03:00
|
|
|
|
if(Device.OS == TargetPlatform.Android)
|
|
|
|
|
{
|
|
|
|
|
Value.TextColor = Color.Black;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
labelValueStackLayout.Children.Add(Value);
|
|
|
|
|
|
|
|
|
|
containerStackLayout.Children.Add(labelValueStackLayout);
|
|
|
|
|
|
|
|
|
|
var buttonStackLayout = new StackLayout
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-08-14 07:54:07 +03:00
|
|
|
|
Orientation = StackOrientation.Horizontal,
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
2016-05-14 08:34:42 +03:00
|
|
|
|
|
|
|
|
|
if(button1Text != null)
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-08-17 05:18:45 +03:00
|
|
|
|
Button1 = new ExtendedButton
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-05-14 08:34:42 +03:00
|
|
|
|
Text = button1Text,
|
2016-05-14 02:57:07 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.End,
|
2016-06-14 03:03:16 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.Center,
|
2016-06-17 07:01:25 +03:00
|
|
|
|
Margin = new Thickness(0)
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
buttonStackLayout.Children.Add(Button1);
|
2016-05-14 02:57:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-14 08:34:42 +03:00
|
|
|
|
if(button2Text != null)
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-08-17 05:18:45 +03:00
|
|
|
|
Button2 = new ExtendedButton
|
2016-05-14 02:57:07 +03:00
|
|
|
|
{
|
2016-05-14 08:34:42 +03:00
|
|
|
|
Text = button2Text,
|
2016-05-14 02:57:07 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.End,
|
2016-06-14 03:03:16 +03:00
|
|
|
|
VerticalOptions = LayoutOptions.Center,
|
2016-06-17 07:01:25 +03:00
|
|
|
|
Margin = new Thickness(0)
|
2016-05-14 02:57:07 +03:00
|
|
|
|
};
|
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
buttonStackLayout.Children.Add(Button2);
|
2016-05-14 02:57:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 05:18:45 +03:00
|
|
|
|
if(Device.OS == TargetPlatform.Android)
|
|
|
|
|
{
|
|
|
|
|
if(Button1 != null)
|
|
|
|
|
{
|
|
|
|
|
Button1.Padding = new Thickness(5);
|
|
|
|
|
}
|
|
|
|
|
if(Button2 != null)
|
|
|
|
|
{
|
|
|
|
|
Button2.Padding = new Thickness(5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
containerStackLayout.Children.Add(buttonStackLayout);
|
2016-05-14 02:57:07 +03:00
|
|
|
|
|
2016-05-17 06:54:24 +03:00
|
|
|
|
View = containerStackLayout;
|
2016-05-14 02:57:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Label Label { get; private set; }
|
|
|
|
|
public Label Value { get; private set; }
|
2016-08-17 05:18:45 +03:00
|
|
|
|
public ExtendedButton Button1 { get; private set; }
|
|
|
|
|
public ExtendedButton Button2 { get; private set; }
|
2016-05-14 02:57:07 +03:00
|
|
|
|
}
|
|
|
|
|
}
|