[iOS] Remove class variable from CarouselViewLayout whose value is always true (...
authoradrianknight89 <adrianknight89@outlook.com>
Tue, 17 Sep 2019 08:38:48 +0000 (03:38 -0500)
committerGerald Versluis <gerald.versluis@microsoft.com>
Tue, 17 Sep 2019 08:38:48 +0000 (10:38 +0200)
* remove unused variable

* comment change

Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewLayout.cs
Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs

index 7132165..464484c 100644 (file)
@@ -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
index 5f1ec53..ca6957a 100644 (file)
@@ -1,6 +1,5 @@
 using System;
 using System.ComponentModel;
-using System.Runtime.CompilerServices;
 using CoreGraphics;
 using Foundation;
 using UIKit;