Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                _defaultTextColor = null;

                if (_picker != null)
                {
                    _picker.RemoveFromSuperview();
                    _picker.Dispose();
                    _picker = null;
                }

                if (Control != null)
                {
                    Control.EditingDidBegin -= OnStarted;
                    Control.EditingDidEnd   -= OnEnded;
                }
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <TimeSpanPicker> e)
        {
            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    var entry = CreateNativeControl();

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

                    _picker         = new UITimeSpanPickerView();
                    _picker.Time    = e.NewElement.Time;
                    _picker.MinTime = e.NewElement.MinTime;
                    _picker.MaxTime = e.NewElement.MaxTime;

                    var width   = UIScreen.MainScreen.Bounds.Width;
                    var toolbar = new UIToolbar(new CGRect(0, 0, width, 44))
                    {
                        BarStyle = UIBarStyle.Default, Translucent = true
                    };
                    var spacer     = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
                    var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) =>
                    {
                        UpdateElementTime();
                        entry.ResignFirstResponder();
                    });

                    toolbar.SetItems(new[] { spacer, doneButton }, false);

                    entry.InputView          = _picker;
                    entry.InputAccessoryView = toolbar;

                    entry.InputView.AutoresizingMask          = UIViewAutoresizing.FlexibleHeight;
                    entry.InputAccessoryView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

                    entry.InputAssistantItem.LeadingBarButtonGroups  = null;
                    entry.InputAssistantItem.TrailingBarButtonGroups = null;

                    _defaultTextColor = entry.TextColor;

                    entry.AccessibilityTraits = UIAccessibilityTrait.Button;

                    SetNativeControl(entry);
                }

                UpdateFont();
                UpdateTime();
                UpdateTimeConstraints();
                UpdateTextColor();
            }

            base.OnElementChanged(e);
        }