示例#1
0
        /// <summary>
        /// Initializes the UI for the PINView
        /// </summary>
        public void CreateControl()
        {
            hiddenTextEntry.MaxLength = PINLength;
            SetInputType(PINInputType);

            var count = PINBoxContainer.Children.Count;

            if (count < PINLength)
            {
                int    newBoxesToAdd = PINLength - count;
                char[] pinCharsArray = PINValue.ToCharArray();

                for (int i = 1; i <= newBoxesToAdd; i++)
                {
                    BoxTemplate boxTemplate = CreateBox();
                    PINBoxContainer.Children.Add(boxTemplate);

                    // When we assign PINValue in XAML directly, the Boxes outside the default length (4), will not get any value in it, eventhough we have assigned it in XAML
                    // To correct this behavior, we have programatically assigned value to those Boxes which are added after the Default Length
                    if (PINValue.Length >= PINLength)
                    {
                        boxTemplate.SetValueWithAnimation(pinCharsArray[Constants.DefaultPINLength + i - 1]);
                    }
                }
            }
            else if (count > PINLength)
            {
                int boxesToRemove = count - PINLength;
                for (int i = 1; i <= boxesToRemove; i++)
                {
                    PINBoxContainer.Children.RemoveAt(PINBoxContainer.Children.Count - 1);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initializes the UI for the PINView
        /// </summary>
        public void CreateControl()
        {
            hiddenTextEntry.MaxLength = PINLength;
            SetInputType(PINInputType);

            var count = PINBoxContainer.Children.Count;

            if (count < PINLength)
            {
                int newBoxesToAdd = PINLength - count;
                for (int i = 1; i <= newBoxesToAdd; i++)
                {
                    BoxTemplate boxTemplate = CreateBox();
                    PINBoxContainer.Children.Add(boxTemplate);
                }
            }
            else if (count > PINLength)
            {
                int boxesToRemove = count - PINLength;
                for (int i = 1; i <= boxesToRemove; i++)
                {
                    PINBoxContainer.Children.RemoveAt(PINBoxContainer.Children.Count - 1);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Creates the instance of one single PIN box UI
        /// </summary>
        /// <returns></returns>
        private BoxTemplate CreateBox()
        {
            BoxTemplate boxTemplate = new BoxTemplate();

            boxTemplate.HeightRequest       = BoxSize;
            boxTemplate.WidthRequest        = BoxSize;
            boxTemplate.Box.BackgroundColor = BoxBackgroundColor;

            SetRadius(boxTemplate, BoxShape);

            boxTemplate.GestureRecognizers.Add(boxTapGestureRecognizer);
            return(boxTemplate);
        }
示例#4
0
 /// <summary>
 /// Applies the Corner Radius to the PIN Box based on the ShapeType
 /// </summary>
 /// <param name="boxTemplate"></param>
 /// <param name="shapeType"></param>
 private void SetRadius(BoxTemplate boxTemplate, BoxShapeType shapeType)
 {
     if (shapeType == BoxShapeType.Circle)
     {
         boxTemplate.Box.CornerRadius = (float)boxTemplate.Box.HeightRequest / 2;
     }
     else if (shapeType == BoxShapeType.Squere)
     {
         boxTemplate.Box.CornerRadius = 0;
     }
     else if (shapeType == BoxShapeType.RoundCorner)
     {
         boxTemplate.Box.CornerRadius = 10;
     }
 }
示例#5
0
        /// <summary>
        /// Creates the instance of one single PIN box UI
        /// </summary>
        /// <returns></returns>
        private BoxTemplate CreateBox()
        {
            BoxTemplate boxTemplate = new BoxTemplate();

            boxTemplate.HeightRequest       = BoxSize;
            boxTemplate.WidthRequest        = BoxSize;
            boxTemplate.Box.BackgroundColor = BoxBackgroundColor;
            boxTemplate.CharLabel.FontSize  = BoxSize / 2;
            boxTemplate.GestureRecognizers.Add(boxTapGestureRecognizer);
            boxTemplate.BoxFocusColor = BoxFocusColor;
            boxTemplate.SecureMode(IsPassword);
            boxTemplate.SetColor(Color);
            boxTemplate.SetRadius(BoxShape);

            return(boxTemplate);
        }
示例#6
0
        /// <summary>
        /// Creates the instance of one single PIN box UI
        /// </summary>
        /// <returns></returns>
        private BoxTemplate CreateBox(char?charValue = null)
        {
            BoxTemplate boxTemplate = new BoxTemplate();

            boxTemplate.HeightRequest       = BoxSize;
            boxTemplate.WidthRequest        = BoxSize;
            boxTemplate.Box.BackgroundColor = BoxBackgroundColor;
            boxTemplate.CharLabel.FontSize  = BoxSize / 2;
            boxTemplate.GestureRecognizers.Add(boxTapGestureRecognizer);
            boxTemplate.BoxFocusColor      = BoxFocusColor;
            boxTemplate.FocusAnimationType = BoxFocusAnimation;
            boxTemplate.SecureMode(IsPassword);
            boxTemplate.SetColor(Color, BoxBorderColor);
            boxTemplate.SetRadius(BoxShape);

            if (charValue.HasValue)
            {
                boxTemplate.SetValueWithAnimation(charValue.Value);
            }

            return(boxTemplate);
        }