Bitwarden-app-android-iphon.../src/App/Controls/PinControl.cs

45 lines
1.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;
if(Device.OS == TargetPlatform.Android)
{
Label.TextColor = Color.Black;
}
}
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; }
}
}