コード例 #1
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
 protected virtual void BoundsSizeChanged()
 {
     //We are changing orientation and we need to tell our layout
     //to update based on new size constrains
     ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);
     //We call ReloadData so our VisibleCells also update their size
     CollectionView.ReloadData();
 }
コード例 #2
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
        protected virtual void UpdateDefaultCell(DefaultCell cell, NSIndexPath indexPath)
        {
            cell.Label.Text = ItemsSource[indexPath].ToString();

            if (cell is ItemsViewCell constrainedCell)
            {
                ItemsViewLayout.PrepareCellForLayout(constrainedCell);
            }
        }
コード例 #3
0
 public CarouselViewController(CarouselView itemsView, ItemsViewLayout layout) : base(itemsView, layout)
 {
     Carousel = itemsView;
     CollectionView.AllowsSelection         = false;
     CollectionView.AllowsMultipleSelection = false;
     Carousel.PropertyChanged += CarouselViewPropertyChanged;
     Carousel.Scrolled        += CarouselViewScrolled;
     _oldViews = new List <View>();
 }
コード例 #4
0
ファイル: ItemsViewRenderer.cs プロジェクト: zmtzawqlp/maui
        protected virtual void UpdateLayout()
        {
            _layout = SelectLayout();

            if (Controller != null)
            {
                Controller.UpdateLayout(_layout);
            }
        }
コード例 #5
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
        protected virtual void UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
        {
            cell.ContentSizeChanged -= CellContentSizeChanged;

            cell.Bind(ItemsView.ItemTemplate, ItemsSource[indexPath], ItemsView);

            cell.ContentSizeChanged += CellContentSizeChanged;

            ItemsViewLayout.PrepareCellForLayout(cell);
        }
コード例 #6
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
        void CheckForEmptySource()
        {
            var wasEmpty = _isEmpty;

            _isEmpty = ItemsSource.ItemCount == 0;

            if (wasEmpty != _isEmpty)
            {
                UpdateEmptyViewVisibility(_isEmpty);
            }

            if (wasEmpty && !_isEmpty)
            {
                // If we're going from empty to having stuff, it's possible that we've never actually measured
                // a prototype cell and our itemSize or estimatedItemSize are wrong/unset
                // So trigger a constraint update; if we need a measurement, that will make it happen
                ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);
            }
        }
コード例 #7
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
        public override void ViewWillLayoutSubviews()
        {
            base.ViewWillLayoutSubviews();

            // We can't set this constraint up on ViewDidLoad, because Forms does other stuff that resizes the view
            // and we end up with massive layout errors. And View[Will/Did]Appear do not fire for this controller
            // reliably. So until one of those options is cleared up, we set this flag so that the initial constraints
            // are set up the first time this method is called.
            if (!_initialConstraintsSet)
            {
                _size = CollectionView.Bounds.Size;
                ItemsViewLayout.ConstrainTo(_size);
                UpdateEmptyView();
                _initialConstraintsSet = true;
            }
            else
            {
                LayoutEmptyView();
            }
        }
コード例 #8
0
        internal UIEdgeInsets GetInsetForSection(ItemsViewLayout itemsViewLayout,
                                                 UICollectionView collectionView, nint section)
        {
            var uIEdgeInsets = ItemsViewLayout.GetInsetForSection(collectionView, itemsViewLayout, section);

            if (!ItemsView.IsGrouped)
            {
                return(uIEdgeInsets);
            }

            // If we're grouping, we'll need to inset the sections to maintain the item spacing between the
            // groups and/or their group headers/footers

            var    itemsLayout     = ItemsView.ItemsLayout;
            var    scrollDirection = itemsViewLayout.ScrollDirection;
            nfloat lineSpacing     = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section);

            if (itemsLayout is GridItemsLayout)
            {
                nfloat itemSpacing = itemsViewLayout.GetMinimumInteritemSpacingForSection(collectionView, itemsViewLayout, section);

                if (scrollDirection == UICollectionViewScrollDirection.Horizontal)
                {
                    return(new UIEdgeInsets(itemSpacing + uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left,
                                            uIEdgeInsets.Bottom, uIEdgeInsets.Right));
                }

                return(new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, itemSpacing + uIEdgeInsets.Left,
                                        uIEdgeInsets.Bottom, uIEdgeInsets.Right));
            }

            if (scrollDirection == UICollectionViewScrollDirection.Horizontal)
            {
                return(new UIEdgeInsets(uIEdgeInsets.Top, lineSpacing + uIEdgeInsets.Left,
                                        uIEdgeInsets.Bottom, uIEdgeInsets.Right));
            }

            return(new UIEdgeInsets(lineSpacing + uIEdgeInsets.Top, uIEdgeInsets.Left,
                                    uIEdgeInsets.Bottom, uIEdgeInsets.Right));
        }
コード例 #9
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
        public void UpdateLayout(ItemsViewLayout newLayout)
        {
            // Ignore calls to this method if the new layout is the same as the old one
            if (CollectionView.CollectionViewLayout == newLayout)
            {
                return;
            }

            ItemsViewLayout = newLayout;
            ItemsViewLayout.GetPrototype = GetPrototype;

            Delegator = CreateDelegator();
            CollectionView.Delegate = Delegator;

            // Make sure the new layout is sized properly
            ItemsViewLayout.ConstrainTo(CollectionView.Bounds.Size);

            CollectionView.SetCollectionViewLayout(ItemsViewLayout, false);

            // Reload the data so the currently visible cells get laid out according to the new layout
            CollectionView.ReloadData();
        }
コード例 #10
0
ファイル: ItemsViewDelegator.cs プロジェクト: zmtzawqlp/maui
 public ItemsViewDelegator(ItemsViewLayout itemsViewLayout, TViewController itemsViewController)
 {
     ItemsViewLayout = itemsViewLayout;
     ViewController  = itemsViewController;
 }
コード例 #11
0
 public GroupableItemsViewDelegator(ItemsViewLayout itemsViewLayout, TViewController itemsViewController)
     : base(itemsViewLayout, itemsViewController)
 {
 }
コード例 #12
0
 protected override TViewController CreateController(TItemsView itemsView, ItemsViewLayout layout)
 {
     return(new StructuredItemsViewController <TItemsView>(itemsView, layout) as TViewController);
 }
コード例 #13
0
ファイル: ItemsViewRenderer.cs プロジェクト: zmtzawqlp/maui
 protected abstract TViewController CreateController(TItemsView newElement, ItemsViewLayout layout);
コード例 #14
0
 public StructuredItemsViewController(TItemsView structuredItemsView, ItemsViewLayout layout)
     : base(structuredItemsView, layout)
 {
 }
コード例 #15
0
 public CarouselViewDelegator(ItemsViewLayout itemsViewLayout, CarouselViewController itemsViewController)
     : base(itemsViewLayout, itemsViewController)
 {
 }
コード例 #16
0
ファイル: ItemsViewController.cs プロジェクト: zmtzawqlp/maui
 protected ItemsViewController(TItemsView itemsView, ItemsViewLayout layout) : base(layout)
 {
     ItemsView       = itemsView;
     ItemsViewLayout = layout;
 }
コード例 #17
0
 public GroupableItemsViewController(TItemsView groupableItemsView, ItemsViewLayout layout)
     : base(groupableItemsView, layout)
 {
     _isGrouped = ItemsView.IsGrouped;
 }
コード例 #18
0
 public SelectableItemsViewController(TItemsView selectableItemsView, ItemsViewLayout layout)
     : base(selectableItemsView, layout)
 {
 }
コード例 #19
0
 protected override CarouselViewController CreateController(CarouselView newElement, ItemsViewLayout layout)
 {
     return(new CarouselViewController(newElement, layout));
 }