예제 #1
0
 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;
 }
예제 #2
0
        /// <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);
                    }
                }
            });
        }
예제 #3
0
        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);
                    }
                }
            });
        }
예제 #4
0
 /// <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);
             }
         }
     });
 }
예제 #5
0
 bool IsValidEmail(string arg) => ValidatorFunc.IsValidEmail(arg);
예제 #6
0
 bool IsEmptyFieldValue(object arg) => ValidatorFunc.IsEmptyFieldValue(arg);
예제 #7
0
 bool IsValidPassword(string arg) => ValidatorFunc.IsValidPassword(arg);