예제 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (this.Control != null && this.Element != null && e.NewElement != null)
            {
                _ultimateEntry = (UltimateEntry)this.Element;
                _textField     = (UITextField)this.Control;

                if (_ultimateEntry.ImageButtonType == UltimateEntryImageButton.Password)
                {
                    _ultimateEntry.IsPassword = true;
                }

                _textField.Layer.CornerRadius = 5;
                _textField.Layer.BorderWidth  = 2;
                // Add padding to the entry field
                _textField.LeftView     = new UIView(new CGRect(0, 0, 10, 0));
                _textField.LeftViewMode = UITextFieldViewMode.Always;


                SetImage();
                SetReturnType();

                if (e.NewElement != null)
                {
                    //subscribe
                    _textField.EditingDidBegin += TextField_FocusChanged;
                    _textField.EditingDidEnd   += TextField_FocusChanged;
                    _textField.EditingChanged  += TextField_FocusChanged;
                    _textField.ShouldReturn    += TextField_ShouldReturn;
                }

                UpdateControlUI();
            }

            if (e.OldElement != null)
            {
                // Unsubscribe
                _textField.EditingDidBegin -= TextField_FocusChanged;
                _textField.EditingDidEnd   -= TextField_FocusChanged;
                _textField.EditingChanged  -= TextField_FocusChanged;
                _textField.ShouldReturn    -= TextField_ShouldReturn;
                if (_imageButton != null)
                {
                    _imageButton.TouchUpInside -= ImageButton_TouchUpInside;
                }
            }
        }
예제 #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (this.Control != null && this.Element != null && e.NewElement != null)
            {
                _ultimateEntry        = (UltimateEntry)this.Element;
                _editText             = (EditText)this.Control;
                _entryBackgroundColor = _ultimateEntry.BackgroundColor;

                if (_ultimateEntry.ImageButtonType == UltimateEntryImageButton.Password)
                {
                    _ultimateEntry.IsPassword = true;
                }

                if (!string.IsNullOrEmpty(_ultimateEntry.RightImageSource))
                {
                    SetImage(_ultimateEntry.RightImageSource);
                }

                _editText.SetPadding(50, 50, 50, 50);

                SetReturnType(_ultimateEntry.ReturnButtonType);

                // Switch the stroke color to blue if the field is in focus and it doesn't have a validation error
                _editText.FocusChange += EditText_FocusChange;

                // Update UI when text is changed
                _editText.TextChanged += EditText_TextChanged;

                UpdateControlUI();
            }

            if (e.OldElement != null)
            {
                // Unsubscribe
                _editText.FocusChange -= EditText_FocusChange;
                _editText.TextChanged -= EditText_TextChanged;
                if (_editText.HasOnClickListeners)
                {
                    _editText.SetOnTouchListener(null);
                }
            }
        }