2016-05-13 07:11:32 +03:00
|
|
|
|
using System;
|
|
|
|
|
using Bit.App.Resources;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Controls
|
|
|
|
|
{
|
2016-05-18 04:28:19 +03:00
|
|
|
|
public class FormPickerCell : ExtendedViewCell
|
2016-05-13 07:11:32 +03:00
|
|
|
|
{
|
|
|
|
|
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")
|
2016-05-13 07:11:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Picker = new ExtendedPicker
|
|
|
|
|
{
|
2016-08-14 07:54:07 +03:00
|
|
|
|
HasBorder = false
|
2016-05-13 07:11:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|
2016-05-13 07:11:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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-24 06:57:11 +03:00
|
|
|
|
Picker.AdjustMarginsForDevice();
|
2016-08-26 04:43:47 +03:00
|
|
|
|
stackLayout.AdjustPaddingForDevice();
|
2016-08-14 07:54:07 +03:00
|
|
|
|
|
2016-07-05 05:35:49 +03:00
|
|
|
|
Tapped += FormPickerCell_Tapped;
|
|
|
|
|
|
2016-05-13 07:11:32 +03:00
|
|
|
|
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();
|
|
|
|
|
}
|
2016-05-13 07:11:32 +03:00
|
|
|
|
}
|
|
|
|
|
}
|