зеркало из https://github.com/xamarin/ios-samples.git
CollectionViewTransition ported to 64bits
This commit is contained in:
Родитель
ed90da2638
Коммит
ca2fb95ad3
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.CoreAnimation;
|
using CoreAnimation;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace CollectionViewTransition {
|
||||||
public static readonly NSString Key = new NSString ("APLCollectionViewCell");
|
public static readonly NSString Key = new NSString ("APLCollectionViewCell");
|
||||||
|
|
||||||
[Export ("initWithFrame:")]
|
[Export ("initWithFrame:")]
|
||||||
public APLCollectionViewCell (RectangleF frame) : base (frame)
|
public APLCollectionViewCell (CGRect frame) : base (frame)
|
||||||
{
|
{
|
||||||
BackgroundColor = UIColor.Cyan;
|
BackgroundColor = UIColor.Cyan;
|
||||||
ImageView = new UIImageView (Bounds);
|
ImageView = new UIImageView (Bounds);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//#define NO_IMAGES
|
//#define NO_IMAGES
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ namespace CollectionViewTransition {
|
||||||
CollectionView.RegisterClassForCell (typeof (APLCollectionViewCell), APLCollectionViewCell.Key);
|
CollectionView.RegisterClassForCell (typeof (APLCollectionViewCell), APLCollectionViewCell.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int NumberOfSections (UICollectionView collectionView)
|
public override nint NumberOfSections (UICollectionView collectionView)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetItemsCount (UICollectionView collectionView, int section)
|
public override nint GetItemsCount (UICollectionView collectionView, nint section)
|
||||||
{
|
{
|
||||||
return MAX_COUNT;
|
return MAX_COUNT;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace CollectionViewTransition {
|
||||||
return new APLTransitionLayout (fromLayout, toLayout);
|
return new APLTransitionLayout (fromLayout, toLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual UICollectionViewController NextViewControllerAtPoint (PointF p)
|
public virtual UICollectionViewController NextViewControllerAtPoint (CGPoint p)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@ namespace CollectionViewTransition {
|
||||||
|
|
||||||
public override void ItemSelected (UICollectionView collectionView, NSIndexPath indexPath)
|
public override void ItemSelected (UICollectionView collectionView, NSIndexPath indexPath)
|
||||||
{
|
{
|
||||||
NavigationController.PushViewController (NextViewControllerAtPoint (PointF.Empty), true);
|
NavigationController.PushViewController (NextViewControllerAtPoint (CGPoint.Empty), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UICollectionViewController NextViewControllerAtPoint (PointF p)
|
public override UICollectionViewController NextViewControllerAtPoint (CGPoint p)
|
||||||
{
|
{
|
||||||
UICollectionViewFlowLayout grid = new UICollectionViewFlowLayout () {
|
UICollectionViewFlowLayout grid = new UICollectionViewFlowLayout () {
|
||||||
ItemSize = new SizeF (75.0f, 75.0f),
|
ItemSize = new CGSize (75.0f, 75.0f),
|
||||||
SectionInset = new UIEdgeInsets (10.0f, 10.0f, 10.0f, 10.0f)
|
SectionInset = new UIEdgeInsets (10.0f, 10.0f, 10.0f, 10.0f)
|
||||||
};
|
};
|
||||||
return new APLGridCollectionViewController (grid) {
|
return new APLGridCollectionViewController (grid) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.CoreGraphics;
|
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ namespace CollectionViewTransition {
|
||||||
|
|
||||||
public override void PrepareLayout ()
|
public override void PrepareLayout ()
|
||||||
{
|
{
|
||||||
SizeF size = CollectionView.Bounds.Size;
|
CGSize size = CollectionView.Bounds.Size;
|
||||||
PointF center = new PointF (size.Width / 2.0f, size.Height / 2.0f);
|
CGPoint center = new CGPoint (size.Width / 2.0f, size.Height / 2.0f);
|
||||||
|
|
||||||
int itemCount = CollectionView.NumberOfItemsInSection (0);
|
int itemCount = (int) CollectionView.NumberOfItemsInSection (0);
|
||||||
|
|
||||||
if (attributesArray == null)
|
if (attributesArray == null)
|
||||||
attributesArray = new List<UICollectionViewLayoutAttributes> (itemCount);
|
attributesArray = new List<UICollectionViewLayoutAttributes> (itemCount);
|
||||||
|
@ -48,7 +48,7 @@ namespace CollectionViewTransition {
|
||||||
float angle = angles [angleIndex];
|
float angle = angles [angleIndex];
|
||||||
var path = NSIndexPath.FromItemSection (i, 0);
|
var path = NSIndexPath.FromItemSection (i, 0);
|
||||||
UICollectionViewLayoutAttributes attributes = UICollectionViewLayoutAttributes.CreateForCell (path);
|
UICollectionViewLayoutAttributes attributes = UICollectionViewLayoutAttributes.CreateForCell (path);
|
||||||
attributes.Size = new SizeF (150, 200);
|
attributes.Size = new CGSize (150, 200);
|
||||||
attributes.Center = center;
|
attributes.Center = center;
|
||||||
attributes.Transform = CGAffineTransform.MakeRotation (angle);
|
attributes.Transform = CGAffineTransform.MakeRotation (angle);
|
||||||
attributes.Alpha = (i > stackCount) ? 0.0f : 1.0f;
|
attributes.Alpha = (i > stackCount) ? 0.0f : 1.0f;
|
||||||
|
@ -63,16 +63,16 @@ namespace CollectionViewTransition {
|
||||||
attributesArray = null;
|
attributesArray = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SizeF CollectionViewContentSize {
|
public override CGSize CollectionViewContentSize {
|
||||||
get { return CollectionView.Bounds.Size; }
|
get { return CollectionView.Bounds.Size; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
||||||
{
|
{
|
||||||
return attributesArray [indexPath.Item];
|
return attributesArray [(int)indexPath.Item];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (RectangleF rect)
|
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (CGRect rect)
|
||||||
{
|
{
|
||||||
return attributesArray.ToArray ();
|
return attributesArray.ToArray ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ namespace CollectionViewTransition {
|
||||||
UINavigationController navigationController;
|
UINavigationController navigationController;
|
||||||
IUIViewControllerContextTransitioning context;
|
IUIViewControllerContextTransitioning context;
|
||||||
float initialPinchDistance;
|
float initialPinchDistance;
|
||||||
PointF initialPinchPoint;
|
CGPoint initialPinchPoint;
|
||||||
|
|
||||||
public APLTransitionController (UICollectionView view, UINavigationController controller)
|
public APLTransitionController (UICollectionView view, UINavigationController controller)
|
||||||
{
|
{
|
||||||
|
@ -25,13 +25,13 @@ namespace CollectionViewTransition {
|
||||||
|
|
||||||
public UINavigationControllerOperation NavigationOperation { get; set; }
|
public UINavigationControllerOperation NavigationOperation { get; set; }
|
||||||
|
|
||||||
void InteractionBegan (PointF point)
|
void InteractionBegan (CGPoint point)
|
||||||
{
|
{
|
||||||
UIViewController viewController = ((APLCollectionViewController)navigationController.TopViewController).NextViewControllerAtPoint (point);
|
UIViewController viewController = ((APLCollectionViewController)navigationController.TopViewController).NextViewControllerAtPoint (point);
|
||||||
if (viewController != null) {
|
if (viewController != null) {
|
||||||
navigationController.PushViewController (viewController, true);
|
navigationController.PushViewController (viewController, true);
|
||||||
} else {
|
} else {
|
||||||
navigationController.PopViewControllerAnimated (true);
|
navigationController.PopViewController (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +84,11 @@ namespace CollectionViewTransition {
|
||||||
if (sender.NumberOfTouches < 2)
|
if (sender.NumberOfTouches < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PointF point1 = sender.LocationOfTouch (0, sender.View);
|
CGPoint point1 = sender.LocationOfTouch (0, sender.View);
|
||||||
PointF point2 = sender.LocationOfTouch (1, sender.View);
|
CGPoint point2 = sender.LocationOfTouch (1, sender.View);
|
||||||
float distance = (float) Math.Sqrt ((point1.X - point2.X) * (point1.X - point2.X) +
|
float distance = (float) Math.Sqrt ((point1.X - point2.X) * (point1.X - point2.X) +
|
||||||
(point1.Y - point2.Y) * (point1.Y - point2.Y));
|
(point1.Y - point2.Y) * (point1.Y - point2.Y));
|
||||||
PointF point = sender.LocationInView (sender.View);
|
CGPoint point = sender.LocationInView (sender.View);
|
||||||
|
|
||||||
if (sender.State == UIGestureRecognizerState.Began) {
|
if (sender.State == UIGestureRecognizerState.Began) {
|
||||||
if (HasActiveInteraction)
|
if (HasActiveInteraction)
|
||||||
|
@ -106,14 +106,14 @@ namespace CollectionViewTransition {
|
||||||
|
|
||||||
switch (sender.State) {
|
switch (sender.State) {
|
||||||
case UIGestureRecognizerState.Changed:
|
case UIGestureRecognizerState.Changed:
|
||||||
float offsetX = point.X - initialPinchPoint.X;
|
float offsetX = (float) (point.X - initialPinchPoint.X);
|
||||||
float offsetY = point.Y - initialPinchPoint.Y;
|
float offsetY = (float) (point.Y - initialPinchPoint.Y);
|
||||||
float distanceDelta = distance - initialPinchDistance;
|
float distanceDelta = distance - initialPinchDistance;
|
||||||
|
|
||||||
if (NavigationOperation == UINavigationControllerOperation.Pop)
|
if (NavigationOperation == UINavigationControllerOperation.Pop)
|
||||||
distanceDelta = -distanceDelta;
|
distanceDelta = -distanceDelta;
|
||||||
|
|
||||||
SizeF size = collectionView.Bounds.Size;
|
CGSize size = collectionView.Bounds.Size;
|
||||||
float dimension = (float)Math.Sqrt (size.Width * size.Width + size.Height * size.Height);
|
float dimension = (float)Math.Sqrt (size.Width * size.Width + size.Height * size.Height);
|
||||||
float progress = (float) Math.Max (Math.Min (distanceDelta / dimension, 1.0), 0.0);
|
float progress = (float) Math.Max (Math.Min (distanceDelta / dimension, 1.0), 0.0);
|
||||||
Update (progress, new UIOffset (offsetX, offsetY));
|
Update (progress, new UIOffset (offsetX, offsetY));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Drawing;
|
using CoreGraphics;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ namespace CollectionViewTransition {
|
||||||
public void SetTransitionProgress (float transitionProgress)
|
public void SetTransitionProgress (float transitionProgress)
|
||||||
{
|
{
|
||||||
base.TransitionProgress = transitionProgress;
|
base.TransitionProgress = transitionProgress;
|
||||||
float offsetH = GetValueForAnimatedKey ("offsetH");
|
float offsetH = (float)GetValueForAnimatedKey ("offsetH");
|
||||||
float offsetV = GetValueForAnimatedKey ("offsetV");
|
float offsetV = (float)GetValueForAnimatedKey ("offsetV");
|
||||||
Offset = new UIOffset (offsetH, offsetV);
|
Offset = new UIOffset (offsetH, offsetV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,12 +28,12 @@ namespace CollectionViewTransition {
|
||||||
Offset = offset;
|
Offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (RectangleF rect)
|
public override UICollectionViewLayoutAttributes[] LayoutAttributesForElementsInRect (CGRect rect)
|
||||||
{
|
{
|
||||||
UICollectionViewLayoutAttributes[] attributes = base.LayoutAttributesForElementsInRect (rect);
|
UICollectionViewLayoutAttributes[] attributes = base.LayoutAttributesForElementsInRect (rect);
|
||||||
foreach (var attribute in attributes) {
|
foreach (var attribute in attributes) {
|
||||||
PointF center = attribute.Center;
|
CGPoint center = attribute.Center;
|
||||||
attribute.Center = new PointF (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
attribute.Center = new CGPoint (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
||||||
}
|
}
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ namespace CollectionViewTransition {
|
||||||
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
public override UICollectionViewLayoutAttributes LayoutAttributesForItem (NSIndexPath indexPath)
|
||||||
{
|
{
|
||||||
UICollectionViewLayoutAttributes attributes = base.LayoutAttributesForItem (indexPath);
|
UICollectionViewLayoutAttributes attributes = base.LayoutAttributesForItem (indexPath);
|
||||||
PointF center = attributes.Center;
|
CGPoint center = attributes.Center;
|
||||||
attributes.Center = new PointF (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
attributes.Center = new CGPoint (center.X + Offset.Horizontal, center.Y + Offset.Vertical);
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using MonoTouch.Foundation;
|
using Foundation;
|
||||||
using MonoTouch.UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace CollectionViewTransition {
|
namespace CollectionViewTransition {
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,13 @@
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||||
<DefineConstants>DEBUG;</DefineConstants>
|
<DefineConstants>DEBUG;XAMCORE_2_0;ARCH_64</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<MtouchLink>None</MtouchLink>
|
<MtouchLink>None</MtouchLink>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
<MtouchDebug>true</MtouchDebug>
|
<MtouchDebug>true</MtouchDebug>
|
||||||
|
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
|
@ -84,7 +85,9 @@
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="monotouch" />
|
<Reference Include="Xamarin.iOS">
|
||||||
|
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
|
@ -160,4 +163,4 @@
|
||||||
<ITunesArtwork Include="Resources\iTunesArtwork" />
|
<ITunesArtwork Include="Resources\iTunesArtwork" />
|
||||||
<ITunesArtwork Include="Resources\iTunesArtwork%402x" />
|
<ITunesArtwork Include="Resources\iTunesArtwork%402x" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче