mirror of
https://github.com/bitwarden/android.git
synced 2026-05-22 04:22:11 -05:00
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using Bit.App.Utilities;
|
|
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 = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier")
|
|
};
|
|
|
|
Entry = new ExtendedEntry
|
|
{
|
|
Keyboard = Keyboard.Numeric,
|
|
MaxLength = 4,
|
|
HideCursor = true
|
|
};
|
|
|
|
Entry.BackgroundColor = Entry.TextColor = Color.Transparent;
|
|
|
|
if(Device.RuntimePlatform == Device.Android)
|
|
{
|
|
Label.TextColor = Color.Black;
|
|
}
|
|
else
|
|
{
|
|
Entry.Margin = new Thickness(0, int.MaxValue, 0, 0);
|
|
}
|
|
}
|
|
|
|
public Label Label { get; set; }
|
|
public ExtendedEntry Entry { get; set; }
|
|
|
|
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
if(e.NewTextValue.Length >= 4)
|
|
{
|
|
OnPinEntered.Invoke(this, null);
|
|
}
|
|
}
|
|
|
|
public void InitEvents()
|
|
{
|
|
Entry.TextChanged += Entry_TextChanged;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Entry.TextChanged -= Entry_TextChanged;
|
|
}
|
|
}
|
|
}
|