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

                Element?.ClearValue(Platform.RendererProperty);
                SetElement(null);

                _packager.Dispose();
                _packager = null;

                _tracker.NativeControlUpdated -= OnNativeControlUpdated;
                _tracker.Dispose();
                _tracker = null;

                _events.Dispose();
                _events = null;

                _insetTracker.Dispose();
                _insetTracker = null;

                ScrollAnimationEnded -= HandleScrollAnimationEnded;
                Scrolled             -= HandleScrolled;
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && _insetTracker != null)
            {
                _insetTracker.Dispose();
                _insetTracker = null;

                var viewsToLookAt = new Stack <UIView>(Subviews);
                while (viewsToLookAt.Count > 0)
                {
                    var view             = viewsToLookAt.Pop();
                    var viewCellRenderer = view as ViewCellRenderer.ViewTableCell;
                    if (viewCellRenderer != null)
                    {
                        viewCellRenderer.Dispose();
                    }
                    else
                    {
                        foreach (var child in view.Subviews)
                        {
                            viewsToLookAt.Push(child);
                        }
                    }
                }
            }

            base.Dispose(disposing);
        }
Esempio n. 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <TableView> e)
        {
            if (e.NewElement != null)
            {
                var style = UITableViewStyle.Plain;
                if (e.NewElement.Intent != TableIntent.Data)
                {
                    style = UITableViewStyle.Grouped;
                }

                if (Control == null || Control.Style != style)
                {
                    if (Control != null)
                    {
                        _insetTracker.Dispose();
                        Control.Dispose();
                    }

                    var tv = new UITableView(RectangleF.Empty, style);
                    _originalBackgroundView = tv.BackgroundView;

                    SetNativeControl(tv);
                    if (System.Maui.Maui.IsiOS9OrNewer)
                    {
                        tv.CellLayoutMarginsFollowReadableWidth = false;
                    }

                    _insetTracker = new KeyboardInsetTracker(tv, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
                    {
                        var offset = Control.ContentOffset;
                        offset.Y  += point.Y;
                        Control.SetContentOffset(offset, true);
                    }, this);
                }

                SetSource();
                UpdateRowHeight();
                UpdateEstimatedRowHeight();
                UpdateBackgroundView();
            }

            base.OnElementChanged(e);
        }
Esempio n. 4
0
        public void SetElement(VisualElement element)
        {
            _requestedScroll = null;
            var oldElement = Element;

            Element = element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                ((ScrollView)oldElement).ScrollToRequested -= OnScrollToRequested;
            }

            if (element != null)
            {
                element.PropertyChanged += HandlePropertyChanged;
                ((ScrollView)element).ScrollToRequested += OnScrollToRequested;
                if (_packager == null)
                {
                    _packager = new VisualElementPackager(this);
                    _packager.Load();

                    _tracker = new VisualElementTracker(this);
                    _tracker.NativeControlUpdated += OnNativeControlUpdated;
                    _events = new EventTracker(this);
                    _events.LoadEvents(this);


                    _insetTracker = new KeyboardInsetTracker(this, () => Window, insets =>
                    {
                        ContentInset = ScrollIndicatorInsets = insets;
                    },
                                                             point =>
                    {
                        var offset = ContentOffset;
                        offset.Y  += point.Y;
                        SetContentOffset(offset, true);
                    }, this);
                }

                UpdateDelaysContentTouches();
                UpdateContentSize();
                UpdateBackgroundColor();
                UpdateIsEnabled();
                UpdateVerticalScrollBarVisibility();
                UpdateHorizontalScrollBarVisibility();

                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

                if (element != null)
                {
                    element.SendViewInitialized(this);
                }

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    AccessibilityIdentifier = element.AutomationId;
                }
            }
        }