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

            if (!(e.NewElement is BlankTimePicker bPicker))
            {
                return;
            }
            blankPicker = bPicker;
            if (e.NewElement != null)
            {
                if (Control != null)
                {
                    //this.Control.Click += OnPickerClick;
                    //this.Control.Text = Element.Time.ToString(Element.Format);
                    //this.Control.KeyListener = null;

                    Control.TextChanged += (sender, arg) =>
                    {
                        var selectedDate = arg.Text.ToString();
                        if (selectedDate == bPicker.Placeholder)
                        {
                            Control.Text = DateTime.Now.ToString(bPicker.Format);
                        }
                    };
                }
            }
            SetPlaceholder();
            SetAlignment();
            Control.SetPadding(0, 7, 0, 3);
            Control.Gravity = Android.Views.GravityFlags.Fill;
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (!(e.NewElement is BlankTimePicker bPicker))
            {
                return;
            }
            blankPicker = bPicker;
            if (e.NewElement != null)
            {
                if (Control != null)
                {
                    if (!string.IsNullOrEmpty(Control.Text))
                    {
                        bPicker.Text = Control.Text;
                    }

                    Control.Focusable    = true;
                    Control.Clickable    = false;
                    Control.InputType    = InputTypes.Null;
                    blankPicker.Focused += OnClick;


                    //Control.TextChanged += (sender, arg) =>
                    //{
                    //    var selectedDate = arg.Text.ToString();
                    //    if (selectedDate == bPicker.Placeholder) Control.Text = DateTime.Now.ToString(bPicker.Format);

                    //    bPicker.Text = arg.Text.ToString();
                    //};

                    SetAttributes();
                    UpdateTime();
                }
            }

            if (e.OldElement != null)
            {
                Control.SetOnClickListener(null);
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (!(e.NewElement is BlankTimePicker bPicker))
            {
                return;
            }
            blankPicker = bPicker;

            if (Control != null)
            {
                Control.SpellCheckingType      = UITextSpellCheckingType.No;
                Control.AutocorrectionType     = UITextAutocorrectionType.No;
                Control.AutocapitalizationType = UITextAutocapitalizationType.None;
                Control.BorderStyle            = UITextBorderStyle.RoundedRect;
                Control.AccessibilityTraits    = UIAccessibilityTrait.Button;
                UIMenuController.SharedMenuController.MenuVisible = false;

                Control.EditingDidBegin += OnStarted;
                Control.EditingDidEnd   += OnEnded;

                if (IsiOS9OrNewer)
                {
                    Control.InputAssistantItem.LeadingBarButtonGroups  = null;
                    Control.InputAssistantItem.TrailingBarButtonGroups = null;
                }

                _picker = new UIDatePicker {
                    Mode = UIDatePickerMode.Time, TimeZone = new NSTimeZone("UTC")
                };
                _picker.ValueChanged            += OnValueChanged;
                _picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
                Control.InputView = _picker;
                Control.InputView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

                SetInputAccessoryView();
                UpdateTime();
                SetAttributes();
            }
        }
예제 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <TimePicker> e)
        {
            base.OnElementChanged(e);

            if (!(e.NewElement is BlankTimePicker bPicker))
            {
                return;
            }
            blankPicker = bPicker;
            if (Control == null)
            {
                SetNativeControl(new UITextField
                {
                    RightViewMode   = UITextFieldViewMode.Always,
                    ClearButtonMode = UITextFieldViewMode.WhileEditing,
                });
            }

            SetPlaceholder();
            SetAlignment();
            SetUIButtons();
        }