Skip to content

HideShowPassword is a xamarin ios extension of UITextField and/or the MaterialComponents TextField to toggle the password visibility in a text field. Just tap the eye icon on right view to toggle visibility.

License

JabusKotze/HideShowPassword

Repository files navigation

HideShowPassword

HideShowPassword is an easy to use xamarin ios extension of UITextField and/or the MaterialComponents TextField to toggle the password visibility in a text field. Just tap the eye icon on right view to toggle visibility.

HideShowPassword for Xamarin.iOS

GitHub release NuGet Badge licenseGitHub Issues Contributions welcome

Install NuGet Package

Sample Usage - Native UITextField

View the sample application - * HideShowPasswordSample

  1. Add a UITextField to your Storyboard or Nib layout and select HideShowPasswordTextField as the Class
  2. Or just select the Hide Show Password Text Field from toolbox custom controls
  3. Optionally extend IHideShowPassWordTextFieldDelegate and implement IsValidPassword to show a checkmark if password is valid and set passwordDelegate
  4. Optionally extend IUITextFieldDelegate and override EditingEnded to reset secure entry when not in focus and set text field Delegate
public class ViewController : UIViewController, IHideShowPassWordTextFieldDelegate, IUITextFieldDelegate
{
	      protected ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            InitComponents();
        }

        void InitComponents()
        {
            // Set Delegates on normal UITextField password
            password.passwordDelegate = this;
            password.Delegate = this;
            // Optionally set tint color on right view
            password.RightView.TintColor = UIColor.Blue;
        }
        
        /* Optionally implement interface member for Native UITextField IsValidPassword, 
         * To show a checkmark in field if the entered password is correct
         */
        public bool IsValidPassword(UITextField textField, string password)
        {
            return password.Length > 5;
        }
        
        [Export("textFieldDidEndEditing:")]
        public void EditingEnded(UITextField textField)
        {
            /* After editing of text field was complete, 
             * you can call the TextFieldDidEndEditing to change it back to a secure text entry.
             * 
             * You can set an Accessibility label for these text fields in the UI designer to determine from which textField the editing was ended
             */            
            switch (textField.AccessibilityLabel)
            {
                case "Password":
                    password.TextFieldDidEndEditing(textField);
                    break;
            }

        }
}

License

Xamarin HideShowPassword for iOS

Copyright (c) 2019 Xamarin HideShowPassword for iOS Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

HideShowPassword is a xamarin ios extension of UITextField and/or the MaterialComponents TextField to toggle the password visibility in a text field. Just tap the eye icon on right view to toggle visibility.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages