Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class AnimationFrame
public Single Angle;
public Transform3D Transform = new Transform3D();
public Single Scale;
public Single constraintConstant;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public enum AnimationType
Angle,
Transform,
Scale,
constraintConstant
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using MonoTouch.UIKit;
using System.Linq;
using MonoTouch.CoreGraphics;

namespace Screenmedia.IFTTT.JazzHands
{
public class ConstraintsAnimation: Animation
{
public ConstraintsAnimation (UIView view) : base(view)
{
}
public override void Animate(int time)
{
if (KeyFrames.Count() <= 1)
return;

AnimationFrame animationFrame = AnimationFrameForTime(time);

// NSLayoutConstraint viewConstraint = new NSLayoutConstraint ();
// viewConstraint.Constant=animationFrame.constraintConstant;

View.TranslatesAutoresizingMaskIntoConstraints = false;

View.Frame = animationFrame.Frame;

View.AddConstraints (new[] {
NSLayoutConstraint.Create (View, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 14),
NSLayoutConstraint.Create (View, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, animationFrame.constraintConstant),
});

View.LayoutIfNeeded ();

}

public override AnimationFrame FrameForTime(int time,
AnimationKeyFrame startKeyFrame,
AnimationKeyFrame endKeyFrame)
{
AnimationFrame animationFrame = new AnimationFrame ();
animationFrame.constraintConstant = TweenValueForStartTime (startKeyFrame.Time, endKeyFrame.Time, startKeyFrame.constraintConstant, endKeyFrame.constraintConstant, time);

return animationFrame;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="src\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -53,6 +54,7 @@
<Compile Include="ScaleAnimation.cs" />
<Compile Include="Transform3DAnimation.cs" />
<Compile Include="Transform3D.cs" />
<Compile Include="ConstraintsAnimation.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ namespace Screenmedia.IFTTT.JazzHandsDemo
{
public class JHViewController : AnimatedScrollViewController, IAnimatedScrollViewController
{
private const int NumberOfPages = 4;
private const int NumberOfPages = 5;

public UIImageView Wordmark { get; set;}
public UIImageView Unicorn { get; set;}
public UILabel LastLabel { get; set;}
public UILabel FirstLabel { get; set;}
public UITextField InputText { get; set;}
public UIButton InputButton { get; set;}


public override void DidReceiveMemoryWarning ()
Expand Down Expand Up @@ -72,6 +74,25 @@ private void PlaceViews ()
UILabel fourthPageText = AddLabel ("Optimized for scrolling intros", true, 4, 0);
ScrollView.AddSubview(fourthPageText);

InputText = AddTextField ("Animation Test", true, 5, 0);

//InputText.TranslatesAutoresizingMaskIntoConstraints = false;

InputText.AddConstraints (new[] {
NSLayoutConstraint.Create (InputText, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 30),
NSLayoutConstraint.Create (InputText, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 180),
});


ScrollView.Add (InputText);

ScrollView.AddConstraints (new[] {
NSLayoutConstraint.Create (InputText, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ScrollView, NSLayoutAttribute.Left, 1, (View.Frame.Size.Width * 4)+50),
NSLayoutConstraint.Create (InputText, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ScrollView, NSLayoutAttribute.Top, 1, 130),
});

View.LayoutIfNeeded ();

LastLabel = fourthPageText;
}

Expand All @@ -96,6 +117,22 @@ private UILabel AddLabel(string text, bool IsOffset, int page = 0, float y = 0)
return l;
}

private UITextField AddTextField(string text, bool IsOffset, int page = 0, float y = 0)
{
var l = new UITextField();
l.Text = text;
l.SizeToFit();
l.Center = View.Center;
l.BackgroundColor = UIColor.Gray;
if (IsOffset)
{
var rect = l.Frame;
rect.Offset (new PointF (TimeForPage (page), y));
l.Frame = rect;
}
return l;
}

private void ConfigureAnimation()
{
Single dy = 240;
Expand Down Expand Up @@ -244,6 +281,32 @@ private void ConfigureAnimation()
Alpha = 0.0f
});
Animator.AddAnimation(labelAlphaAnimation);

//Constraint Animation on textfield of last page

ConstraintsAnimation textFieldConstraintAnimation = new ConstraintsAnimation (this.InputText);

textFieldConstraintAnimation.AddKeyFrame (new AnimationKeyFrame ()
{
Time = TimeForPage(4),
constraintConstant=180
});

textFieldConstraintAnimation.AddKeyFrame (new AnimationKeyFrame ()
{
Time = TimeForPage(4.50f),
constraintConstant=200
});

textFieldConstraintAnimation.AddKeyFrame (new AnimationKeyFrame ()
{
Time = TimeForPage(5),
constraintConstant=80
});



Animator.AddAnimation(textFieldConstraintAnimation);

}

Expand Down