2012-09-19 22:06:30 +04:00
|
|
|
using System;
|
2015-01-19 18:09:40 +03:00
|
|
|
using CoreGraphics;
|
2012-09-19 22:06:30 +04:00
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
using UIKit;
|
|
|
|
using Foundation;
|
|
|
|
using CoreAnimation;
|
2012-09-19 22:06:30 +04:00
|
|
|
|
2023-02-17 16:55:43 +03:00
|
|
|
namespace PinchIt {
|
|
|
|
public class PinchLayout : UICollectionViewFlowLayout {
|
2012-09-19 22:06:30 +04:00
|
|
|
float pinchedCellScale;
|
2023-02-17 16:55:43 +03:00
|
|
|
CGPoint pinchedCellCenter;
|
2012-09-19 22:06:30 +04:00
|
|
|
public NSIndexPath pinchedCellPath { get; set; }
|
|
|
|
|
|
|
|
public void applyPinchToLayoutAttributes (UICollectionViewLayoutAttributes layoutAttributes)
|
|
|
|
{
|
|
|
|
if (layoutAttributes.IndexPath.Equals (pinchedCellPath)) {
|
|
|
|
layoutAttributes.Transform3D = CATransform3D.MakeScale (pinchedCellScale, pinchedCellScale, 1.0f);
|
|
|
|
layoutAttributes.Center = pinchedCellCenter;
|
|
|
|
layoutAttributes.ZIndex = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-17 16:55:43 +03:00
|
|
|
public override UICollectionViewLayoutAttributes [] LayoutAttributesForElementsInRect (CGRect rect)
|
2012-09-19 22:06:30 +04:00
|
|
|
{
|
|
|
|
var array = base.LayoutAttributesForElementsInRect (rect);
|
|
|
|
|
|
|
|
foreach (var cellAttributes in array)
|
|
|
|
applyPinchToLayoutAttributes (cellAttributes);
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2012-09-19 22:06:30 +04:00
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
|
|
|
{
|
2023-02-17 16:55:43 +03:00
|
|
|
var attributes = base.LayoutAttributesForItem (indexPath);
|
2012-09-19 22:06:30 +04:00
|
|
|
|
|
|
|
applyPinchToLayoutAttributes (attributes);
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPinchedCellScale (float scale)
|
|
|
|
{
|
|
|
|
pinchedCellScale = scale;
|
2023-02-17 16:55:43 +03:00
|
|
|
InvalidateLayout ();
|
2012-09-19 22:06:30 +04:00
|
|
|
}
|
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
public void setPinchedCellCenter (CGPoint origin)
|
2012-09-19 22:06:30 +04:00
|
|
|
{
|
|
|
|
pinchedCellCenter = origin;
|
2023-02-17 16:55:43 +03:00
|
|
|
InvalidateLayout ();
|
2012-09-19 22:06:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|