bitwarden-android/src/App/Controls/FormPickerCell.cs

58 lines
1.5 KiB
C#
Raw Normal View History

using System;
using Bit.App.Resources;
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class FormPickerCell : ExtendedViewCell
{
public FormPickerCell(string labelText, string[] pickerItems)
{
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
TextColor = Color.FromHex("777777")
};
Picker = new ExtendedPicker
{
2016-08-14 07:54:07 +03:00
HasBorder = false
};
foreach(var item in pickerItems)
{
Picker.Items.Add(item);
}
Picker.SelectedIndex = 0;
var stackLayout = new StackLayout
{
2016-08-14 07:54:07 +03:00
Padding = new Thickness(15, 10),
VerticalOptions = LayoutOptions.CenterAndExpand
};
stackLayout.Children.Add(Label);
stackLayout.Children.Add(Picker);
2016-08-14 07:54:07 +03:00
if(Device.OS == TargetPlatform.Android)
{
stackLayout.Spacing = 0;
2016-08-19 03:20:18 +03:00
Picker.Margin = new Thickness(-4, -2, -4, -10);
2016-08-14 07:54:07 +03:00
}
2016-07-05 05:35:49 +03:00
Tapped += FormPickerCell_Tapped;
View = stackLayout;
}
public Label Label { get; private set; }
public ExtendedPicker Picker { get; private set; }
2016-07-05 05:35:49 +03:00
private void FormPickerCell_Tapped(object sender, EventArgs e)
{
Picker.Focus();
}
}
}