From 307b6457277e23f731f6201b4495e80b1a391e3a Mon Sep 17 00:00:00 2001 From: adrianknight89 Date: Tue, 17 Sep 2019 03:38:48 -0500 Subject: [PATCH] [iOS] Remove class variable from CarouselViewLayout whose value is always true (#7484) * remove unused variable * comment change --- .../CollectionView/CarouselViewLayout.cs | 14 +++++--------- .../CollectionView/ItemsViewLayout.cs | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewLayout.cs b/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewLayout.cs index 7132165..464484c 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewLayout.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewLayout.cs @@ -1,5 +1,4 @@ using System; -using System.ComponentModel; using CoreGraphics; using UIKit; @@ -8,8 +7,8 @@ namespace Xamarin.Forms.Platform.iOS internal class CarouselViewLayout : ItemsViewLayout { readonly CarouselView _carouselView; - readonly bool _addInsets = true; readonly ItemsLayout _itemsLayout; + public CarouselViewLayout(ItemsLayout itemsLayout, ItemSizingStrategy itemSizingStrategy, CarouselView carouselView) : base(itemsLayout, itemSizingStrategy) { _carouselView = carouselView; @@ -61,29 +60,26 @@ namespace Xamarin.Forms.Platform.iOS public override UIEdgeInsets GetInsetForSection(UICollectionView collectionView, UICollectionViewLayout layout, nint section) { var insets = base.GetInsetForSection(collectionView, layout, section); - if (!_addInsets) - { - return insets; - } var left = insets.Left + (float)_carouselView.PeekAreaInsets.Left; var right = insets.Right + (float)_carouselView.PeekAreaInsets.Right; var top = insets.Top + (float)_carouselView.PeekAreaInsets.Top; var bottom = insets.Bottom + (float)_carouselView.PeekAreaInsets.Bottom; - //We give some insets so the user can be able to scroll to the first and last item + // We give some insets so the user can scroll to the first and last item if (_carouselView.NumberOfSideItems > 0) { if (ScrollDirection == UICollectionViewScrollDirection.Horizontal) { left += ItemSize.Width; right += ItemSize.Width; + return new UIEdgeInsets(insets.Top, left, insets.Bottom, right); } + return new UIEdgeInsets(ItemSize.Height, insets.Left, ItemSize.Height, insets.Right); } return new UIEdgeInsets(top, left, bottom, right); - } } -} +} \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs index 5f1ec53..ca6957a 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using System.Runtime.CompilerServices; using CoreGraphics; using Foundation; using UIKit; -- 2.7.4