mirror of
https://github.com/bitwarden/mobile
synced 2025-12-20 18:23:51 +00:00
Updated PIN lock page with gesture recognizer to refocus entry
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Bit.App.Models.Page;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
@@ -7,10 +6,12 @@ namespace Bit.App.Controls
|
||||
public class PinControl
|
||||
{
|
||||
private Action _pinEnteredAction;
|
||||
private Action _confirmPinEnteredAction;
|
||||
|
||||
public PinControl(Action pinEnteredAction)
|
||||
public PinControl(Action pinEnteredAction, Action confirmPinEnteredAction = null)
|
||||
{
|
||||
_pinEnteredAction = pinEnteredAction;
|
||||
_confirmPinEnteredAction = confirmPinEnteredAction;
|
||||
|
||||
Label = new Label
|
||||
{
|
||||
@@ -19,7 +20,6 @@ namespace Bit.App.Controls
|
||||
TextColor = Color.FromHex("333333"),
|
||||
FontFamily = "Courier"
|
||||
};
|
||||
Label.SetBinding<PinPageModel>(Label.TextProperty, s => s.LabelText);
|
||||
|
||||
Entry = new ExtendedEntry
|
||||
{
|
||||
@@ -27,19 +27,35 @@ namespace Bit.App.Controls
|
||||
MaxLength = 4,
|
||||
Margin = new Thickness(0, int.MaxValue, 0, 0)
|
||||
};
|
||||
Entry.SetBinding<PinPageModel>(Xamarin.Forms.Entry.TextProperty, s => s.PIN);
|
||||
Entry.TextChanged += PinEntry_TextChanged;
|
||||
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 PinEntry_TextChanged(object sender, TextChangedEventArgs e)
|
||||
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if(e.NewTextValue.Length >= 4)
|
||||
if(e.NewTextValue.Length >= 4 && _pinEnteredAction != null)
|
||||
{
|
||||
_pinEnteredAction();
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfirmEntry_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if(e.NewTextValue.Length >= 4 && _confirmPinEnteredAction != null)
|
||||
{
|
||||
_confirmPinEnteredAction();
|
||||
}
|
||||
}
|
||||
|
||||
public Label Label { get; set; }
|
||||
public ExtendedEntry Entry { get; set; }
|
||||
public ExtendedEntry ConfirmEntry { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user