Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="textField">A bordered text field</param>
        public ValidationTextField(BorderedTextField textField)
        {
            _textField        = textField;
            NeutralStateColor = ValidStateColor = ErrorStateColor = _textField.BorderColor;

            EditingColor = _textField.BorderColor;
            _textField.TextField.EditingDidBegin += EditingBegan;
            _textField.TextField.EditingDidEnd   += EditingEnded;

            var superview = _textField.TextField.Superview;

            _errorLabel = new UILabel();
            _errorLabel.TextAlignment = UITextAlignment.Center;
            ErrorFont = _textField.TextField.Font;
            superview.AddSubviews(_errorLabel);
        }
Example #2
0
        /// <summary>
        /// Override of ViewDidLoad
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Instantiate the bordered and validation text fields, set some properties and add triggers
            var borderedField = new BorderedTextField(NameTextField, NameTextField.TextColor.CGColor, BorderDirection.Bottom, 4);

            _validationField = new ValidationTextField(borderedField)
            {
                EditingColor    = UIColor.FromRGB(149, 165, 166).CGColor,
                ErrorStateColor = UIColor.FromRGB(210, 77, 87).CGColor,
                ValidStateColor = UIColor.FromRGB(101, 198, 187).CGColor,
                ErrorFont       = UIFont.SystemFontOfSize(10)
            };
            _validationField.AddNeutralTrigger(Empty);
            _validationField.AddErrorTrigger(IsLannister, "No Lannisters allowed!");

            // UIView extension to resign focus when the view controller is tapped
            View.ResignFirstResponderOnTap();
        }