clear value after invalid pin

This commit is contained in:
Kyle Spearrin 2016-07-20 23:51:31 -04:00
parent 1a9d58eecc
commit 98335c6acb
2 changed files with 20 additions and 12 deletions

View file

@ -27,12 +27,12 @@ namespace Bit.iOS.Core.Utilities
return alert;
}
public static UIAlertController CreateAlert(string title, string message, string accept)
public static UIAlertController CreateAlert(string title, string message, string accept, Action<UIAlertAction> acceptHandle = null)
{
var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
var oldFrame = alert.View.Frame;
alert.View.Frame = new RectangleF((float)oldFrame.X, (float)oldFrame.Y, (float)oldFrame.Width, (float)oldFrame.Height - 20);
alert.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, null));
alert.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, acceptHandle));
return alert;
}
}

View file

@ -51,13 +51,7 @@ namespace Bit.iOS.Extension
private void PinTextField_EditingChanged(object sender, EventArgs e)
{
var newText = string.Empty;
for(int i = 0; i < 4; i++)
{
newText += PinTextField.Text.Length <= i ? "- " : "● ";
}
PinLabel.Text = newText.TrimEnd();
SetLabelText();
if(PinTextField.Text.Length >= 4)
{
@ -70,14 +64,28 @@ namespace Bit.iOS.Extension
{
// TODO: keep track of invalid attempts and logout?
var alert = Dialogs.CreateAlert(null, "Invalid PIN. Try again.", AppResources.Ok);
PresentViewController(alert, true, null);
var alert = Dialogs.CreateAlert(null, "Invalid PIN. Try again.", AppResources.Ok, (a) =>
{
PinTextField.Text = string.Empty;
SetLabelText();
PinTextField.BecomeFirstResponder();
});
PresentViewController(alert, true, null);
}
}
}
private void SetLabelText()
{
var newText = string.Empty;
for(int i = 0; i < 4; i++)
{
newText += PinTextField.Text.Length <= i ? "- " : "● ";
}
PinLabel.Text = newText.TrimEnd();
}
partial void CancelButton_Activated(UIBarButtonItem sender)
{
CompleteRequest();