Esempio n. 1
0
        public SearchTextField(Action returnButtonTapped)
        {
            ClearButton        = new UIButton();
            ClearButton.Hidden = true;
            ClearButton.SetImage(UIImage.FromBundle("ic_delete_tag"), UIControlState.Normal);
            ClearButton.Frame      = new CGRect(0, 0, 16, 16);
            ClearButton.TouchDown += (sender, e) =>
            {
                Text = string.Empty;
                ClearButton.Hidden = true;
                ((TagFieldDelegate)Delegate).ChangeBackground(this);
                ClearButtonTapped?.Invoke();
            };
            RightView     = ClearButton;
            RightViewMode = UITextFieldViewMode.Always;

            var _searchPlaceholderAttributes = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("Hashtag", _searchPlaceholderAttributes));
            AttributedPlaceholder  = at;
            AutocorrectionType     = UITextAutocorrectionType.No;
            AutocapitalizationType = UITextAutocapitalizationType.None;
            Font = Constants.Regular14;
            Layer.CornerRadius = 20;

            Delegate = new TagFieldDelegate(returnButtonTapped);
        }
        public SearchTextField(Action returnButtonTapped, string placeholder)
        {
            var rightView = new UIView();

            Loader                  = new UIActivityIndicatorView();
            Loader.Color            = Constants.R231G72B0;
            Loader.HidesWhenStopped = true;

            ClearButton        = new UIButton();
            ClearButton.Hidden = true;
            ClearButton.SetImage(UIImage.FromBundle("ic_delete_tag"), UIControlState.Normal);
            ClearButton.TouchDown += (sender, e) =>
            {
                Clear();
                ClearButtonTapped?.Invoke();
            };

            rightView.AddSubview(Loader);
            rightView.AddSubview(ClearButton);

            ClearButton.AutoSetDimensionsToSize(new CGSize(16, 16));
            ClearButton.AutoPinEdge(ALEdge.Left, ALEdge.Right, Loader, 5);
            ClearButton.AutoAlignAxis(ALAxis.Horizontal, Loader);
            Loader.AutoSetDimensionsToSize(new CGSize(16, 16));
            Loader.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            _loaderLeftMargin = Loader.AutoPinEdgeToSuperviewEdge(ALEdge.Left);

            RightView = rightView;
            rightView.AutoSetDimensionsToSize(new CGSize(37, 16));
            RightViewMode = UITextFieldViewMode.Always;

            var _searchPlaceholderAttributes = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(placeholder, _searchPlaceholderAttributes));
            AttributedPlaceholder  = at;
            AutocorrectionType     = UITextAutocorrectionType.No;
            AutocapitalizationType = UITextAutocapitalizationType.None;
            BackgroundColor        = Constants.R245G245B245;
            Font = Constants.Regular14;
            Layer.CornerRadius = 20;

            Delegate        = new TagFieldDelegate(returnButtonTapped);
            EditingChanged += DoEditingChanged;
            LayoutLoader();
        }