public InputFieldObserver(InputField inputField, ValidatorFunc validator = null) { IsValid = false; _Value = 0f; _Length = 0; inputField.onValueChanged.AddListener(OnChange); _Validator = validator; if (_Validator != null) { inputField.onValidateInput += _Validator; } _OnChange = null; }
/// <summary> /// Initializes a new instance of the <see cref="T:FormsPinView.PCL.PinViewModel"/> class. /// </summary> public PinViewModel() { KeyPressCommand = new Command <string>(arg => { if (arg == "Backspace") { if (EnteredPin.Count > 0) { EnteredPin.RemoveAt(EnteredPin.Count - 1); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else if (arg == "Clear") { if (EnteredPin.Count > 0) { _enteredPin = new List <char>(); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else if (EnteredPin.Count < TargetPinLength) { EnteredPin.Add(arg[0]); if (EnteredPin.Count == TargetPinLength) { var pass = new string(EnteredPin.ToArray()); if (ValidatorFunc.Invoke(pass)) { Success?.Invoke(this, new PinEventArgs() { EnteredPin = pass }); EnteredPin.Clear(); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } else { EnteredPin.Clear(); Error?.Invoke(this, EventArgs.Empty); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else { DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } }); }
public PinViewModel() { KeyPressCommand = new Command <string>(arg => { var v = CrossVibrate.Current; v.Vibration(TimeSpan.FromMilliseconds(100)); if (arg == "Backspace") { if (EnteredPin.Count > 0) { EnteredPin.RemoveAt(EnteredPin.Count - 1); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else if (EnteredPin.Count < TargetPinLength) { EnteredPin.Add(arg[0]); if (EnteredPin.Count == TargetPinLength) { if (ValidatorFunc.Invoke(EnteredPin)) { EnteredPin.Clear(); Success?.Invoke(this, EventArgs.Empty); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } else { EnteredPin.Clear(); Error?.Invoke(this, EventArgs.Empty); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else { DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } }); }
/// <summary> /// Initializes a new instance of the <see cref="T:FormsPinView.PCL.PinViewModel"/> class. /// </summary> public PinViewModel() { KeyPressCommand = new Command<string>(arg => { if (arg == "Backspace") { if (EnteredPin.Count > 0) { EnteredPin.RemoveAt(EnteredPin.Count - 1); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else if (EnteredPin.Count < TargetPinLength) { EnteredPin.Add(arg[0]); if (EnteredPin.Count == TargetPinLength) { if (ValidatorFunc.Invoke(EnteredPin)) { EnteredPin.Clear(); Success?.Invoke(this, EventArgs.Empty); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } else { EnteredPin.Clear(); Error?.Invoke(this, EventArgs.Empty); DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } else { DisplayedTextUpdated?.Invoke(this, EventArgs.Empty); } } }); }
bool IsValidEmail(string arg) => ValidatorFunc.IsValidEmail(arg);
bool IsEmptyFieldValue(object arg) => ValidatorFunc.IsEmptyFieldValue(arg);
bool IsValidPassword(string arg) => ValidatorFunc.IsValidPassword(arg);