bitwarden-android/src/App/Controls/PinControl.cs
2016-08-16 22:18:45 -04:00

39 lines
1 KiB
C#

using System;
using Xamarin.Forms;
namespace Bit.App.Controls
{
public class PinControl
{
public EventHandler OnPinEntered;
public PinControl()
{
Label = new Label
{
HorizontalTextAlignment = TextAlignment.Center,
FontSize = 35,
FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier")
};
Entry = new ExtendedEntry
{
Keyboard = Keyboard.Numeric,
MaxLength = 4,
Margin = new Thickness(0, int.MaxValue, 0, 0)
};
Entry.TextChanged += Entry_TextChanged;
}
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
if(e.NewTextValue.Length >= 4)
{
OnPinEntered.Invoke(this, null);
}
}
public Label Label { get; set; }
public ExtendedEntry Entry { get; set; }
}
}