1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-20 10:13:42 +00:00

PIN settings page

This commit is contained in:
Kyle Spearrin
2016-06-12 00:49:35 -04:00
parent 243a32c62b
commit e85fd53d56
7 changed files with 140 additions and 33 deletions

View File

@@ -5,14 +5,10 @@ namespace Bit.App.Controls
{
public class PinControl
{
private Action _pinEnteredAction;
private Action _confirmPinEnteredAction;
public EventHandler OnPinEntered;
public PinControl(Action pinEnteredAction, Action confirmPinEnteredAction = null)
public PinControl()
{
_pinEnteredAction = pinEnteredAction;
_confirmPinEnteredAction = confirmPinEnteredAction;
Label = new Label
{
HorizontalTextAlignment = TextAlignment.Center,
@@ -28,34 +24,17 @@ namespace Bit.App.Controls
Margin = new Thickness(0, int.MaxValue, 0, 0)
};
Entry.TextChanged += Entry_TextChanged;
ConfirmEntry = new ExtendedEntry
{
Keyboard = Keyboard.Numeric,
MaxLength = 4,
Margin = new Thickness(0, int.MaxValue, 0, 0)
};
Entry.TextChanged += ConfirmEntry_TextChanged;
}
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
if(e.NewTextValue.Length >= 4 && _pinEnteredAction != null)
if(e.NewTextValue.Length >= 4)
{
_pinEnteredAction();
}
}
private void ConfirmEntry_TextChanged(object sender, TextChangedEventArgs e)
{
if(e.NewTextValue.Length >= 4 && _confirmPinEnteredAction != null)
{
_confirmPinEnteredAction();
OnPinEntered.Invoke(this, null);
}
}
public Label Label { get; set; }
public ExtendedEntry Entry { get; set; }
public ExtendedEntry ConfirmEntry { get; set; }
}
}