/// <summary>
        /// Dispose the specified disposing.
        /// </summary>
        /// <returns>The dispose.</returns>
        /// <param name="disposing">If set to <c>true</c> disposing.</param>
        protected override void Dispose(bool disposing)
        {
            _parentPage.Appearing -= ParentPageAppearing;

            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _insetTracker?.Dispose();
                _insetTracker = null;
                foreach (UIView subview in Subviews)
                {
                    DisposeSubviews(subview);
                }

                _tableview = null;
            }

            _disposed = true;

            base.Dispose(disposing);
        }
예제 #2
0
        /// <summary>
        /// Dispose the specified disposing.
        /// </summary>
        /// <returns>The dispose.</returns>
        /// <param name="disposing">If set to <c>true</c> disposing.</param>
        protected override void Dispose(bool disposing)
        {
            _parentPage.Appearing -= ParentPageAppearing;

            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _contentSizeObserver.Dispose();
                _contentSizeObserver              = null;
                Element.CollectionChanged        -= OnCollectionChanged;
                Element.SectionCollectionChanged -= OnSectionCollectionChanged;
                Element.SectionPropertyChanged   -= OnSectionPropertyChanged;
                Element.CellPropertyChanged      -= OnCellPropertyChanged;
                _insetTracker?.Dispose();
                _insetTracker = null;
                foreach (UIView subview in Subviews)
                {
                    DisposeSubviews(subview);
                }

                _tableview = null;
            }

            _disposed = true;

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _insetTracker?.Dispose();
                _insetTracker = null;

                DataSource?.Dispose();
                DataSource = null;

                if (_refreshControl != null)
                {
                    _refreshControl.ValueChanged -= RefreshControl_ValueChanged;
                    _refreshControl.Dispose();
                    _refreshControl = null;
                }

                _collectionView?.Dispose();
                _collectionView = null;
            }

            _disposed = true;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                _tableview = new UITableView(CGRect.Empty, UITableViewStyle.Grouped);
                SetNativeControl(_tableview);
                _tableview.ScrollEnabled = true;
                _tableview.RowHeight     = UITableView.AutomaticDimension;
                _tableview.Source        = new SettingsTableSource(Element);

                _tableview.CellLayoutMarginsFollowReadableWidth = false;

                _tableview.SectionHeaderHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionHeaderHeight = MinRowHeight;

                //need the following two because of make footer height variable.
                _tableview.SectionFooterHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionFooterHeight = MinRowHeight;

                UpdateBackgroundColor();
                UpdateSeparator();
                UpdateRowHeight();

                Element elm = Element;
                while (elm != null)
                {
                    elm = elm.Parent;
                    if (elm is Page)
                    {
                        break;
                    }
                }

                _parentPage            = elm as Page;
                _parentPage.Appearing += ParentPageAppearing;

                _insetTracker = new KeyboardInsetTracker(_tableview, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
                {
                    var offset = Control.ContentOffset;
                    offset.Y  += point.Y;
                    Control.SetContentOffset(offset, true);
                });
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <CollectionView> e)
        {
            if (e.NewElement != null)
            {
                ViewLayout = new GridViewLayout();
                ViewLayout.ScrollDirection         = UICollectionViewScrollDirection.Vertical;
                ViewLayout.SectionInset            = new UIEdgeInsets(0, 0, 0, 0);
                ViewLayout.MinimumLineSpacing      = 0.0f;
                ViewLayout.MinimumInteritemSpacing = 0.0f;
                ViewLayout.EstimatedItemSize       = UICollectionViewFlowLayout.AutomaticSize;

                _refreshControl = new UIRefreshControl();
                _refreshControl.ValueChanged += RefreshControl_ValueChanged;

                _collectionView = new UICollectionView(CGRect.Empty, ViewLayout);
                _collectionView.RegisterClassForCell(typeof(ContentCellContainer), typeof(ContentCell).FullName);
                _collectionView.RegisterClassForSupplementaryView(typeof(ContentCellContainer), UICollectionElementKindSection.Header, SectionHeaderId);

                _collectionView.AllowsSelection = true;

                SetNativeControl(_collectionView);

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


                DataSource             = new GridCollectionViewSource(e.NewElement, _collectionView);
                _collectionView.Source = DataSource;

                UpdateIsSticky();
                UpdateRowSpacing();
                UpdatePullToRefreshEnabled();
                UpdatePullToRefreshColor();
            }

            base.OnElementChanged(e);
        }
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                _tableview = new UITableView(CGRect.Empty, UITableViewStyle.Grouped);

                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    _tableview.DragDelegate = this;
                    _tableview.DropDelegate = this;

                    _tableview.DragInteractionEnabled = true;
                    _tableview.Source = new SettingsTableSource(Element);
                }
                else
                {
                    _tableview.Editing = true;
                    _tableview.AllowsSelectionDuringEditing = true;
                    // When Editing is true, for some reason, UITableView top margin is displayed.
                    // force removing the margin by the following code.
                    _topInset = 36;
                    _tableview.ContentInset = new UIEdgeInsets(-_topInset, 0, 0, 0);

                    _tableview.Source = new SettingsLagacyTableSource(Element);
                }


                SetNativeControl(_tableview);
                _tableview.ScrollEnabled = true;
                _tableview.RowHeight     = UITableView.AutomaticDimension;


                _tableview.CellLayoutMarginsFollowReadableWidth = false;

                _tableview.SectionHeaderHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionHeaderHeight = MinRowHeight;

                //need the following two because of make footer height variable.
                _tableview.SectionFooterHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionFooterHeight = MinRowHeight;

                UpdateBackgroundColor();
                UpdateSeparator();
                UpdateRowHeight();

                Element elm = Element;
                while (elm != null)
                {
                    elm = elm.Parent;
                    if (elm is Page)
                    {
                        break;
                    }
                }

                _parentPage            = elm as Page;
                _parentPage.Appearing += ParentPageAppearing;

                _insetTracker = new KeyboardInsetTracker(_tableview, () => Control.Window, insets => Control.ContentInset = Control.ScrollIndicatorInsets = insets, point =>
                {
                    var offset = Control.ContentOffset;
                    offset.Y  += point.Y;
                    Control.SetContentOffset(offset, true);
                });
            }
        }
예제 #7
0
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                e.OldElement.CollectionChanged        -= OnCollectionChanged;
                e.OldElement.SectionCollectionChanged -= OnSectionCollectionChanged;
                e.OldElement.SectionPropertyChanged   -= OnSectionPropertyChanged;
                e.OldElement.CellPropertyChanged      -= OnCellPropertyChanged;
            }

            if (e.NewElement != null)
            {
                _tableview = new UITableView(CGRect.Empty, UITableViewStyle.Grouped);

                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    _tableview.DragDelegate = this;
                    _tableview.DropDelegate = this;

                    _tableview.DragInteractionEnabled = true;
                    _tableview.Source = new SettingsTableSource(Element);
                }
                else
                {
                    _tableview.Editing = true;
                    _tableview.AllowsSelectionDuringEditing = true;
                    // When Editing is true, for some reason, UITableView top margin is displayed.
                    // force removing the margin by the following code.
                    _topInset = 36;
                    _tableview.ContentInset = new UIEdgeInsets(-_topInset, 0, 0, 0);

                    _tableview.Source = new SettingsLagacyTableSource(Element);
                }

                SetNativeControl(_tableview);
                _tableview.ScrollEnabled       = true;
                _tableview.RowHeight           = UITableView.AutomaticDimension;
                _tableview.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;

                _tableview.CellLayoutMarginsFollowReadableWidth = false;

                _tableview.SectionHeaderHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionHeaderHeight = UITableView.AutomaticDimension;

                _tableview.SectionFooterHeight          = UITableView.AutomaticDimension;
                _tableview.EstimatedSectionFooterHeight = UITableView.AutomaticDimension;

                _tableview.RegisterClassForHeaderFooterViewReuse(typeof(TextHeaderView), TextHeaderId);
                _tableview.RegisterClassForHeaderFooterViewReuse(typeof(TextFooterView), TextFooterId);
                _tableview.RegisterClassForHeaderFooterViewReuse(typeof(CustomHeaderView), CustomHeaderId);
                _tableview.RegisterClassForHeaderFooterViewReuse(typeof(CustomFooterView), CustomFooterId);

                e.NewElement.CollectionChanged        += OnCollectionChanged;
                e.NewElement.SectionCollectionChanged += OnSectionCollectionChanged;
                e.NewElement.SectionPropertyChanged   += OnSectionPropertyChanged;
                e.NewElement.CellPropertyChanged      += OnCellPropertyChanged;

                UpdateBackgroundColor();
                UpdateSeparator();
                UpdateRowHeight();

                Element elm = Element;
                while (elm != null)
                {
                    elm = elm.Parent;
                    if (elm is Page)
                    {
                        break;
                    }
                }

                _parentPage            = elm as Page;
                _parentPage.Appearing += ParentPageAppearing;

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

                _contentSizeObserver = _tableview.AddObserver("contentSize", NSKeyValueObservingOptions.New, OnContentSizeChanged);
            }
        }