예제 #1
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 spacing between the
            // groups and their group headers/footers

            nfloat spacing = itemsViewLayout.GetMinimumLineSpacingForSection(collectionView, itemsViewLayout, section);

            var top  = uIEdgeInsets.Top;
            var left = uIEdgeInsets.Left;

            if (itemsViewLayout.ScrollDirection == UICollectionViewScrollDirection.Horizontal)
            {
                left += spacing;
            }
            else
            {
                top += spacing;
            }

            return(new UIEdgeInsets(top, left,
                                    uIEdgeInsets.Bottom, uIEdgeInsets.Right));
        }
        public override nfloat GetMinimumLineSpacingForSection(UICollectionView collectionView,
                                                               UICollectionViewLayout layout, nint section)
        {
            if (ItemsViewLayout == null)
            {
                return(default(nfloat));
            }

            return(ItemsViewLayout.GetMinimumLineSpacingForSection(collectionView, layout, section));
        }
예제 #3
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));
        }