public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            UIView containerView = transitionContext.ContainerView;

            var fromView = transitionContext.GetViewFor(UITransitionContext.FromViewKey);
            var toView   = transitionContext.GetViewFor(UITransitionContext.ToViewKey);

            fromView.Frame = transitionContext.GetInitialFrameForViewController(fromViewController);
            toView.Frame   = transitionContext.GetFinalFrameForViewController(toViewController);

            fromView.Alpha = 1f;
            toView.Alpha   = 0f;

            containerView.AddSubview(toView);
            var transitionDuration = TransitionDuration(transitionContext);

            UIView.Animate(transitionDuration, 0, UIViewAnimationOptions.TransitionNone, () => {
                fromView.Alpha = 0f;
                toView.Alpha   = 1f;
            }, () => {
                bool wasCancel = transitionContext.TransitionWasCancelled;
                transitionContext.CompleteTransition(!wasCancel);
            }
                           );
        }
Beispiel #2
0
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromController = transitionContext.GetViewControllerForKey(
                UITransitionContext.FromViewControllerKey);
            var toController = transitionContext.GetViewControllerForKey(
                UITransitionContext.ToViewControllerKey);

            if (fromController is PestoDetailViewController &
                toController is PestoViewController)
            {
                CGRect detailFrame = fromController.View.Frame;
                detailFrame.Y = this.View.Frame.Size.Height;


                UIView.AnimateNotify(TransitionDuration(transitionContext),
                                     0.5f,
                                     UIViewAnimationOptions.CurveEaseIn,
                                     () => {
                    fromController.View.Frame = detailFrame;
                }, new UICompletionHandler((bool finished) => {
                    if (fromController.View != null)
                    {
                        fromController.View.RemoveFromSuperview();
                    }
                    transitionContext.CompleteTransition(true);
                }));
            }
        }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController =
                transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            var screenBounds = UIScreen.MainScreen.Bounds;
            var fromFrame = fromViewController.View.Frame;

            UIView.AnimateNotify(_transitionDuration,
                () =>
                {
                    toViewController.View.Alpha = 1.0f;

                    switch (fromViewController.InterfaceOrientation)
                    {
                        case UIInterfaceOrientation.Portrait:
                            fromViewController.View.Frame = new CGRect(0, screenBounds.Height, fromFrame.Width,
                                fromFrame.Height);
                            break;
                        case UIInterfaceOrientation.LandscapeLeft:
                            fromViewController.View.Frame = new CGRect(screenBounds.Width, 0, fromFrame.Width,
                                fromFrame.Height);
                            break;
                        case UIInterfaceOrientation.LandscapeRight:
                            fromViewController.View.Frame = new CGRect(screenBounds.Width * -1, 0, fromFrame.Width,
                                fromFrame.Height);
                            break;
                    }
                },
                finished => transitionContext.CompleteTransition(true));
        }
Beispiel #4
0
        public override async void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            // Get the from and to View Controllers and their views
            var fromVC   = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var fromView = fromVC.View;

            var toVC   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var toView = toVC.View;

            // Add the to view to the transition container view
            var containerView = transitionContext.ContainerView;

            // Set the desired target for the transition
            var appearedFrame = transitionContext.GetFinalFrameForViewController(fromVC);

            // Set how the animation shall end
            var finalFrame = new CGRect(_animationOrigin.Frame.GetMidX(), _animationOrigin.Frame.GetMidY(), 0, 0);

            fromView.Frame = appearedFrame;

            var isAnimationCompleted = await UIView.AnimateAsync(TransitionDuration(transitionContext), () => {
                fromView.Frame = finalFrame;
            });

            fromView.RemoveFromSuperview();

            transitionContext.CompleteTransition(isAnimationCompleted);
        }
        private void AnimateTransitionForPresent(IUIViewControllerContextTransitioning transitionContext)
        {
            var source      = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var destination = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            transitionContext.ContainerView.InsertSubviewAbove(destination.View, source.View);
            destination.View.Alpha = 0;
            source.ViewWillDisappear(true);
            destination.ViewWillAppear(true);

            var duration = TransitionDuration(transitionContext);

            CATransaction.Begin();

            CATransaction.CompletionBlock = () =>
            {
                transitionContext.CompleteTransition(true);
            };

            UIView.Animate(duration, 0, new UIViewAnimationOptions(),
                           () =>
            {
                destination.View.Alpha = (nfloat)1.0;
            }, () =>
            {
                destination.ViewDidAppear(true);
                source.ViewDidDisappear(true);
            });

            SpotlightTransitionWillPresent?.Invoke(this, transitionContext);

            CATransaction.Commit();
        }
Beispiel #6
0
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var container = transitionContext.ContainerView;

            container.UserInteractionEnabled = false;

            //Getting target and source VC
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

            if (!IsMenuOpen)
            {
                //if container changed orientation, menucontroller doesn't know about that
                //we should update bounds for this case
                fromViewController.View.Frame = container.Bounds;


                _originalSuperview = toViewController.View.Superview;
                MainViewController = toViewController;
                MenuWillAppear?.Invoke(this, EventArgs.Empty);
                ShowMenu(transitionContext, container, fromViewController, toViewController);
            }
            else
            {
                MenuWillDisappear?.Invoke(this, EventArgs.Empty);
                HideMenu(transitionContext, container, fromViewController, toViewController);
            }
        }
Beispiel #7
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var containerView = transitionContext.ContainerView;

            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

            containerView.AddSubview(toViewController.View);
            toViewController.View.Frame = CGRect.Empty;

            var startPoint = GetStartPoint(fromViewController.InterfaceOrientation);

            if (fromViewController.InterfaceOrientation == UIInterfaceOrientation.Portrait)
            {
                toViewController.View.Frame = new CGRect(startPoint.X, startPoint.Y, fromViewController.View.Frame.Width, fromViewController.View.Frame.Height);
            }
            else
            {
                toViewController.View.Frame = new CGRect(startPoint.X, startPoint.Y, fromViewController.View.Frame.Height, fromViewController.View.Frame.Width);
            }

            UIView.AnimateNotify(Duration, delegate {
                toViewController.View.Frame   = new CGRect(0, 0, fromViewController.View.Frame.Width, fromViewController.View.Frame.Height);
                fromViewController.View.Alpha = 0.5f;
            }, delegate {
                transitionContext.CompleteTransition(true);
            });
        }
		public async override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			UIViewController fromVC = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
			UIView fromView = fromVC.View;
			UIViewController toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			UIView toView = toVC.View;

			UIView containerView = transitionContext.ContainerView;
			if (IsPresentation)
				containerView.AddSubview (toView);

			UIViewController animatingVC = IsPresentation? toVC : fromVC;
			UIView animatingView = animatingVC.View;

			animatingView.Frame = transitionContext.GetFinalFrameForViewController (animatingVC);

			CGAffineTransform presentedTransform = CGAffineTransform.MakeIdentity ();
			CGAffineTransform dismissedTransform = CGAffineTransform.MakeScale (0.001f, 0.001f) * CGAffineTransform.MakeRotation (8 * (float)Math.PI);

			animatingView.Transform = IsPresentation ? dismissedTransform : presentedTransform;

			var opt = UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.BeginFromCurrentState;
			await UIView.AnimateNotifyAsync (TransitionDuration (transitionContext), 0, 300, 5, opt, () => {
				animatingView.Transform = IsPresentation ? presentedTransform : dismissedTransform;
			});
			animatingView.Transform = CGAffineTransform.MakeIdentity ();

			if (!IsPresentation)
				fromView.RemoveFromSuperview ();

			transitionContext.CompleteTransition (true);
		}
        private void AnimateTransitionForDismiss(IUIViewControllerContextTransitioning transitionContext)
        {
            var source      = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var destination = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            source.ViewWillDisappear(true);
            destination.ViewWillAppear(true);

            var duration = TransitionDuration(transitionContext);

            CATransaction.Begin();

            CATransaction.CompletionBlock = () =>
            {
                transitionContext.CompleteTransition(true);
            };

            UIView.Animate(duration, 0, new UIViewAnimationOptions(),
                           animation: () =>
            {
                source.View.Alpha = 0;
            }, completion: () =>
            {
                destination.ViewDidAppear(true);
                source.ViewDidDisappear(true);
            });

            SpotlightTransitionWillDismiss?.Invoke(this, transitionContext);

            CATransaction.Commit();
        }
Beispiel #10
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var          inView   = transitionContext.ContainerView;
            var          fromVC   = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            BaseActivity toVC     = (BaseActivity)transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var          fromView = fromVC.View;
            var          toView   = toVC.View;

            inView.AddSubview(toView);

            var frame = toView.Frame;

            toView.Frame = new CGRect(frame.Width, 0, frame.Width, frame.Height);

            UIView.Animate(TransitionDuration(transitionContext), () => {
                fromView.Frame = new CGRect(-frame.Width, 0, frame.Width, frame.Height);
                toView.Frame   = new CGRect(0, 0, frame.Width, frame.Height);
            }, () => {
                transitionContext.CompleteTransition(true);

                CommonMethods.transitionRunning = false;
                if (CommonMethods.transitionTarget != "empty")
                {
                    CommonMethods.OpenPage(CommonMethods.transitionTarget, CommonMethods.transitionAnim);
                    CommonMethods.transitionTarget = "empty";
                }
            });
        }
Beispiel #11
0
            public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
            {
                var toController   = (DurationChangeViewController)transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
                var fromController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
                var container      = transitionContext.ContainerView;

                var imageView = (UIImageView)toController.View;

                imageView.Image = GetBlurred(fromController.View);

                toController.View.Frame = transitionContext.GetFinalFrameForViewController(toController);
                toController.View.Alpha = 0;
                container.InsertSubviewAbove(toController.View, fromController.View);

                UIView.Animate(
                    TransitionDuration(transitionContext),
                    delegate {
                    toController.View.Alpha = 1;
                },
                    delegate {
                    if (!transitionContext.TransitionWasCancelled)
                    {
                        fromController.View.RemoveFromSuperview();
                    }
                    transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
                }
                    );
            }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {

            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            var screenBounds = UIScreen.MainScreen.Bounds;
            var fromFrame = fromViewController.View.Frame;

            UIView.AnimateNotify(_transitionDuration, 
                                 () =>
            {
                toViewController.View.Alpha = 1.0f;

                switch(fromViewController.InterfaceOrientation)
                {
                    case UIInterfaceOrientation.Portrait:
                        fromViewController.View.Frame = new CGRect(0, screenBounds.Height, fromFrame.Width, fromFrame.Height);
                        break;
                    case UIInterfaceOrientation.LandscapeLeft:
                        fromViewController.View.Frame = new CGRect(screenBounds.Width, 0, fromFrame.Width, fromFrame.Height);
                        break;
                    case UIInterfaceOrientation.LandscapeRight:
                        fromViewController.View.Frame = new CGRect(screenBounds.Width * -1, 0, fromFrame.Width, fromFrame.Height);
                        break;
                    default:
                        break;
                }

            },
                                 (finished) => transitionContext.CompleteTransition(true));
        }
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			_transitionContext = transitionContext;

			var containerView = transitionContext.ContainerView;

			FlashCardViewController toViewController;
			UIViewController fromViewController;

			if (Presenting) {
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as UIViewController;
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as FlashCardViewController;
			} else {
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as FlashCardViewController;
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as UIViewController;
			}

			if(Presenting)
				containerView.AddSubview(toViewController.View);

			var originRect = toViewController.SourceFrame;

			var circleRect = new CGRect (originRect.GetMidX(), originRect.GetMidY(), 10, 10);

			var circleMaskPathInitial = UIBezierPath.FromOval(circleRect); //(ovalInRect: button.frame);
			var extremePoint = new CGPoint(circleRect.X - toViewController.View.Bounds.Width, circleRect.Y - toViewController.View.Bounds.Height ); //CGRect.GetHeight (toViewController.view.bounds));
			var radius = (float)Math.Sqrt((extremePoint.X * extremePoint.X) + (extremePoint.Y * extremePoint.Y));
			var largeCircleRect = circleRect.Inset (-radius, -radius);
			var circleMaskPathFinal = UIBezierPath.FromOval (largeCircleRect);

			CGPath fromPath;
			CGPath toPath;

			if (Presenting) {
				fromPath = circleMaskPathInitial.CGPath;
				toPath = circleMaskPathFinal.CGPath;
			} else {
				var path = new CGPath ();
				fromPath = circleMaskPathFinal.CGPath;
				toPath = circleMaskPathInitial.CGPath;
			}

			var maskLayer = new CAShapeLayer();
			maskLayer.Path = fromPath;
			if (Presenting) {
				toViewController.View.Layer.Mask = maskLayer;
			} else {
				toViewController.View.Layer.Mask = maskLayer;
			}

			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.From = ObjCRuntime.Runtime.GetNSObject(fromPath.Handle);
			maskLayerAnimation.To = ObjCRuntime.Runtime.GetNSObject(toPath.Handle);
			maskLayerAnimation.Duration = this.TransitionDuration(transitionContext);
			_animDoneDelegate = new AnimDoneDelegate (transitionContext);
			maskLayerAnimation.Delegate = _animDoneDelegate;
			maskLayer.AddAnimation(maskLayerAnimation, "path");

		}
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var fromView           = fromViewController.View;
            var toView             = toViewController.View;

            Animate(transitionContext, fromViewController, toViewController, fromView, toView);
        }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            UIViewController fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
            UIViewController toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);

            UIView fromView = fromViewController.View;
            UIView toView = toViewController.View;

            AnimateTransition (transitionContext, fromViewController, toViewController, fromView, toView);
        }
Beispiel #16
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var containerView      = transitionContext.ContainerView;
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            toViewController.View.Frame = fromViewController.View.Frame;

            if (IsPresenting)
            {
                var presentedControllerView = toViewController.View;
                var originalCenter          = presentedControllerView.Center;
                var originalSize            = presentedControllerView.Frame.Size;

                presentedControllerView.Center    = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                presentedControllerView.Transform = CGAffineTransform.MakeScale(0.001f, 0.001f);
                containerView.AddSubview(presentedControllerView);

                UIView.Animate(Duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                               () =>
                {
                    presentedControllerView.Transform = CGAffineTransform.MakeIdentity();
                    presentedControllerView.Center    = originalCenter;
                }, () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
            else
            {
                var returningControllerView = fromViewController.View;
                var originalSize            = returningControllerView.Frame.Size;

                containerView.AddSubview(toViewController.View);

                UIView.Animate(Duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                               () =>
                {
                    returningControllerView.Transform = CGAffineTransform.MakeScale(0.001f, 0.001f);
                    returningControllerView.Center    = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                    returningControllerView.Alpha     = .5f;
                    containerView.InsertSubview(returningControllerView, 1);
                }, () =>
                {
                    returningControllerView.Center = AnimationHelper.GetCenterPointFromFrame(StartingFrame);
                    returningControllerView.RemoveFromSuperview();

                    transitionContext.CompleteTransition(true);
                }
                               );
            }
        }
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var containerView      = transitionContext.ContainerView;

            //if we are presenting
            if (toViewController.View == this.View)
            {
                fromViewController.View.UserInteractionEnabled = false;

                containerView.AddSubview(dimmedView);
                containerView.AddSubview(toViewController.View);

                var frame = toViewController.View.Frame;
                frame.Y = toViewController.View.Bounds.Height;
                toViewController.View.Frame = frame;

                this.dimmedView.Alpha = 0f;

                UIView.Animate(AnimatedTransitionDuration, 0, UIViewAnimationOptions.CurveEaseIn,
                               () =>
                {
                    this.dimmedView.Alpha = 0.5f;
                    frame   = toViewController.View.Frame;
                    frame.Y = 0f;
                    toViewController.View.Frame = frame;
                },
                               () =>
                {
                    transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
                }
                               );
            }
            else
            {
                toViewController.View.UserInteractionEnabled = true;
                UIView.Animate(AnimatedTransitionDuration, 0.1f, UIViewAnimationOptions.CurveEaseIn,
                               () =>
                {
                    this.dimmedView.Alpha = 0f;
                    var frame             = fromViewController.View.Frame;
                    frame.Y = fromViewController.View.Bounds.Height;
                    fromViewController.View.Frame = frame;
                },
                               () =>
                {
                    transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
                }
                               );
            }
        }
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            UIView containerView = transitionContext.ContainerView;

            var  toView       = transitionContext.GetViewFor(UITransitionContext.ToViewKey);
            var  fromView     = transitionContext.GetViewFor(UITransitionContext.FromViewKey);
            bool isPresenting = (fromViewController == PresentingViewController);

            var fromViewFinalFrame = transitionContext.GetFinalFrameForViewController(fromViewController);
            var toViewInitialFrame = transitionContext.GetInitialFrameForViewController(toViewController);

            var toViewFinalFrame = transitionContext.GetFinalFrameForViewController(toViewController);

            if (toView != null)
            {
                containerView.AddSubview(toView);
            }

            if (isPresenting)
            {
                toViewInitialFrame.X    = containerView.Bounds.GetMinX();
                toViewInitialFrame.Y    = containerView.Bounds.GetMaxY();
                toViewInitialFrame.Size = toViewFinalFrame.Size;

                toView.Frame = toViewInitialFrame;
            }
            else
            {
                fromView.Frame.Offset(0f, fromView.Frame.Height);
                fromViewFinalFrame = new CGRect(fromView.Frame.X, fromView.Frame.Y + fromView.Frame.Height, fromViewFinalFrame.Width, fromViewFinalFrame.Height);
            }

            double transitionDuration = TransitionDuration(transitionContext);

            UIView.Animate(transitionDuration, 0, UIViewAnimationOptions.TransitionNone, () => {
                if (isPresenting)
                {
                    toView.Frame = toViewFinalFrame;
                }
                else
                {
                    fromView.Frame = fromViewFinalFrame;
                }
            }, () => {
                bool wasCancelled = transitionContext.TransitionWasCancelled;
                transitionContext.CompleteTransition(!wasCancelled);
            }
                           );
        }
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var    fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var    toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            UIView containerView      = transitionContext.ContainerView;

            var toView   = transitionContext.GetViewFor(UITransitionContext.ToViewKey);
            var fromView = transitionContext.GetViewFor(UITransitionContext.FromViewKey);

            bool isPresenting = (fromViewController == PresentingViewController);

            if (toView != null)
            {
                containerView.AddSubview(toView);
            }

            if (isPresenting)
            {
                toView.Alpha = 0f;

                if (fromView != null)
                {
                    fromView.Frame = transitionContext.GetFinalFrameForViewController(fromViewController);
                }

                toView.Frame = transitionContext.GetFinalFrameForViewController(toViewController);
            }
            else if (toView != null)
            {
                toView.Frame = transitionContext.GetFinalFrameForViewController(toViewController);
            }

            double transitionDuration = TransitionDuration(transitionContext);

            UIView.Animate(transitionDuration, 0, UIViewAnimationOptions.TransitionNone, () => {
                if (toView != null)
                {
                    toView.Alpha = isPresenting ? 1f : 0f;
                }
            }, () => {
                bool wasCancelled = transitionContext.TransitionWasCancelled;
                transitionContext.CompleteTransition(!wasCancelled);

                if (isPresenting == false)
                {
                    fromView.Alpha = 1f;
                }
            }
                           );
        }
		public override void StartInteractiveTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			context = transitionContext;
			var fromVC = (UICollectionViewController) context.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
			var toVC = (UICollectionViewController) context.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			transitionLayout = (APLTransitionLayout) fromVC.CollectionView.StartInteractiveTransition (toVC.Layout,
				delegate (bool finished, bool completed)  {
				context.CompleteTransition (completed);
				collectionView.WeakDelegate = completed ? toVC : fromVC;
				transitionLayout = null;
				context = null;
				HasActiveInteraction = false;
			});
		}
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			StatusViewController ToVC = (StatusViewController)transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			UIViewController FromVC = (UIViewController)transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);

			transitionContext.ContainerView.AddSubview (ToVC.View);
			ToVC.View.Frame = new CoreGraphics.CGRect (-FromVC.View.Frame.Size.Width, 0, FromVC.View.Frame.Size.Width, FromVC.View.Frame.Size.Height);

			UIView.Animate (.25, animation: () => {
				ToVC.View.Frame = new CoreGraphics.CGRect (0, 0, FromVC.View.Frame.Size.Width, FromVC.View.Frame.Size.Height);
			}, completion: () => {
				transitionContext.CompleteTransition(true);
			});
		}
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var toController      = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var fromController    = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var animationDuration = TransitionDuration(transitionContext);

            if (presenting)
            {
                transitionContext.ContainerView.AddSubview(toController.View);

                var finalFrame = transitionContext.GetFinalFrameForViewController(toController);

                var frame = new CGRect(finalFrame.Location, finalFrame.Size);
                frame.Offset(0.0f, transitionContext.ContainerView.Frame.Height - 20);
                toController.View.Frame = frame;
                toController.View.Alpha = 0.5f;

                AnimationExtensions.Animate(animationDuration, Curves.CardInCurve, () =>
                {
                    toController.View.Frame = finalFrame;
                    toController.View.Alpha = 1.0f;
                },
                                            () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled));
            }
            else
            {
                var initialFrame = transitionContext.GetInitialFrameForViewController(fromController);
                initialFrame.Offset(0.0f, transitionContext.ContainerView.Frame.Height);
                var finalFrame = initialFrame;

                if (transitionContext.IsInteractive)
                {
                    UIView.Animate(
                        animationDuration,
                        () => fromController.View.Frame = finalFrame,
                        () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled)
                        );
                }
                else
                {
                    AnimationExtensions.Animate(animationDuration, Curves.CardOutCurve, () =>
                    {
                        fromController.View.Frame = finalFrame;
                        fromController.View.Alpha = 0.5f;
                    },
                                                () => transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled));
                }
            }
        }
Beispiel #23
0
 public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
 {
     if (IsPresenting)
     {
         UIViewController toVC = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
         FlyingObjectsContainterViewController fromVC = (FlyingObjectsContainterViewController)transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
         OpenDrawer(transitionContext, toVC, fromVC);
     }
     else
     {
         FlyingObjectsContainterViewController toVC = (FlyingObjectsContainterViewController)transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
         UIViewController fromVC = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
         CloseDrawer(transitionContext, fromVC, toVC);
     }
 }
        public override void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            context = transitionContext;
            var fromVC = (UICollectionViewController)context.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toVC   = (UICollectionViewController)context.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            transitionLayout = (APLTransitionLayout)fromVC.CollectionView.StartInteractiveTransition(toVC.Layout,
                                                                                                     delegate(bool finished, bool completed)  {
                context.CompleteTransition(completed);
                collectionView.WeakDelegate = completed ? toVC : fromVC;
                transitionLayout            = null;
                context = null;
                HasActiveInteraction = false;
            });
        }
Beispiel #25
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            //1
            _transitionContext = transitionContext;

            //2
            var containerView      = _transitionContext.ContainerView;
            var fromViewController = _transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey) as OnboardingController;
            var toViewController   = _transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey) as ContainerController;
            var fromRect           = fromViewController.NavigationRect;
            var toRect             = new CGRect(-toViewController.View.Bounds.Width / 2, -toViewController.View.Bounds.Height / 2, toViewController.View.Bounds.Width * 2, toViewController.View.Bounds.Height * 2);

            //3
            containerView.AddSubview(toViewController.View);

            //4
            var circleMaskPathInitial = UIBezierPath.FromRoundedRect(fromRect, fromRect.Height / 2);

            var circleMaskPathFinal = UIBezierPath.FromRoundedRect(toRect, toRect.Height / 2);

            //5
            var maskLayer = new CAShapeLayer();

            maskLayer.Path = circleMaskPathFinal.CGPath;
            toViewController.View.Layer.Mask = maskLayer;

            //6
            var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");

            maskLayerAnimation.SetFrom(circleMaskPathInitial.CGPath);
            maskLayerAnimation.SetTo(circleMaskPathFinal.CGPath);
            maskLayerAnimation.Duration       = TransitionDuration(_transitionContext);
            maskLayerAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseIn);

            maskLayerAnimation.AnimationStopped += (object sender, CAAnimationStateEventArgs e) => {
                if (_transitionContext != null)
                {
                    _transitionContext.CompleteTransition(!_transitionContext.TransitionWasCancelled);
                    var controller = _transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
                    if (controller != null)
                    {
                        controller.View.Layer.Mask = null;
                    }
                }
            };

            maskLayer.AddAnimation(maskLayerAnimation, "path");
        }
Beispiel #26
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            UIViewController destinationController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            UIViewController originatingController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

            switch (TransitioningType)
            {
            case ModalAnimatedTransitioningType.ModalAnimatedTransitioningTypeDismiss:
                this.AnimateDismissingInContext(transitionContext, originatingController, destinationController);
                break;

            case ModalAnimatedTransitioningType.ModalAnimatedTransitioningTypePresent:
                this.AnimatePresentingInContext(transitionContext, originatingController, destinationController);
                break;
            }
        }
Beispiel #27
0
                public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
                {
                    var container = transitionContext.ContainerView;
                    var @to       = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

                    @to.View.Frame = UIScreen.MainScreen.Bounds;
                    @to.View.Alpha = 0;

                    var backgroundColor = Theme.ColorPalette.Background.ToUIColor();

                    var brightness = ((backgroundColor.CGColor.Components[0] * 299) + (backgroundColor.CGColor.Components[1] * 587) + (backgroundColor.CGColor.Components[2] * 114)) / 1000;

                    var visualEffectView = new UIVisualEffectView(UIBlurEffect.FromStyle(brightness > 0.5f ? UIBlurEffectStyle.ExtraLight : UIBlurEffectStyle.ExtraDark))
                    {
                        Frame = UIScreen.MainScreen.Bounds,
                        Tag   = VISUAL_EFFECT_TAG,
                        Alpha = 0
                    };

                    container.AddSubviews(
                        visualEffectView,
                        @to.View
                        );

                    UIView.AnimateNotify(ANIMATION_DURATION, 0.0, UIViewAnimationOptions.CurveEaseIn, () =>
                    {
                        visualEffectView.Alpha = 1f;
                        @to.View.Alpha         = 1f;
                    }, finished =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
            public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
            {
                var toViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
                var containerView    = transitionContext.ContainerView;

                var animationDuration = TransitionDuration(transitionContext);

                var animation = (CASpringAnimation)CASpringAnimation.FromKeyPath("position.y");

                animation.Damping         = 10;
                animation.InitialVelocity = 20;
                animation.Mass            = 1;
                animation.Stiffness       = 100;
                animation.From            = FromObject(containerView.Bounds.Height);
                animation.To                = FromObject(UIScreen.MainScreen.Bounds.Height / 2);
                animation.Duration          = TransitionDuration(transitionContext);
                animation.AnimationStopped += delegate
                {
                    transitionContext.CompleteTransition(true);
                };

                toViewController.View.Layer.AddAnimation(animation, null);

                containerView.AddSubview(toViewController.View);
            }
		public void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			UIView containerView = transitionContext.ContainerView;
			UIView toView = transitionContext.GetViewFor (UITransitionContext.ToViewKey);

			if (transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) == DestinationViewController) {
				// Presenting.
				UIView.PerformWithoutAnimation (() => {
					toView.Alpha = 0;
					containerView.AddSubview (toView);
				});

				double transitionContextDuration = TransitionDuration (transitionContext);

				UIView.AnimateNotify (transitionContextDuration, () => {
					toView.Alpha = 1;
				}, transitionContext.CompleteTransition);
			} else {
				// Dismissing.
				var fromView = transitionContext.GetViewFor (UITransitionContext.FromViewKey);
				UIView.PerformWithoutAnimation (() => containerView.InsertSubviewBelow (toView, fromView));

				var transitionContextDuration = TransitionDuration (transitionContext);

				UIView.AnimateNotify (transitionContextDuration, () => {
					fromView.Alpha = 0;
				}, transitionContext.CompleteTransition);
			}
		}
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            UIView containerView = transitionContext.ContainerView;
            UIView toView        = transitionContext.GetViewFor(UITransitionContext.ToViewKey);

            if (transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey) == DestinationViewController)
            {
                // Presenting.
                UIView.PerformWithoutAnimation(() => {
                    toView.Alpha = 0;
                    containerView.AddSubview(toView);
                });

                double transitionContextDuration = TransitionDuration(transitionContext);

                UIView.AnimateNotify(transitionContextDuration, () => {
                    toView.Alpha = 1;
                }, transitionContext.CompleteTransition);
            }
            else
            {
                // Dismissing.
                var fromView = transitionContext.GetViewFor(UITransitionContext.FromViewKey);
                UIView.PerformWithoutAnimation(() => containerView.InsertSubviewBelow(toView, fromView));

                var transitionContextDuration = TransitionDuration(transitionContext);

                UIView.AnimateNotify(transitionContextDuration, () => {
                    fromView.Alpha = 0;
                }, transitionContext.CompleteTransition);
            }
        }
Beispiel #31
0
            public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
            {
                var containerView = transitionContext.ContainerView;
                var toVC          = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
                var fromVC        = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

                if (Presenting)
                {
                    fromVC.View.UserInteractionEnabled = false;

                    containerView.AddSubview(fromVC.View);
                    containerView.AddSubview(toVC.View);

                    var endFrame = toVC.View.Frame;
                    var frame    = toVC.View.Frame;
                    frame.Y         = -frame.Height;
                    toVC.View.Frame = frame;

                    UIView.Animate(TransitionDuration(transitionContext), 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        toVC.View.Frame = endFrame;
                    },
                                   () =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
                else
                {
                    toVC.View.UserInteractionEnabled = true;

                    containerView.Add(toVC.View);
                    containerView.Add(fromVC.View);

                    var endFrame = fromVC.View.Frame;
                    endFrame.Y = -endFrame.Height;

                    UIView.Animate(TransitionDuration(transitionContext), 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        fromVC.View.Frame = endFrame;
                    }, () =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
            }
            public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
            {
                var containerView = transitionContext.ContainerView;
                var toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
                var fromVC = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);

                if (Presenting)
                {
                    fromVC.View.UserInteractionEnabled = false;

                    containerView.AddSubview(fromVC.View);
                    containerView.AddSubview(toVC.View);

                    var endFrame = toVC.View.Frame;
                    var frame = toVC.View.Frame;
                    frame.Y = -frame.Height;
                    toVC.View.Frame = frame;

                    UIView.Animate(TransitionDuration(transitionContext), 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        toVC.View.Frame = endFrame;
                    }, 
                        () =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
                else
                {
                    toVC.View.UserInteractionEnabled = true;

                    containerView.Add(toVC.View);
                    containerView.Add(fromVC.View);

                    var endFrame = fromVC.View.Frame;
                    endFrame.Y = -endFrame.Height;

                    UIView.Animate(TransitionDuration(transitionContext), 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        fromVC.View.Frame = endFrame;
                    }, () =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
            }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            UIView containerView = transitionContext.ContainerView;

            var fromView = transitionContext.GetViewFor(UITransitionContext.FromViewKey);
            var toView   = transitionContext.GetViewFor(UITransitionContext.ToViewKey);

            var fromFrame = transitionContext.GetInitialFrameForViewController(fromViewController);
            var toFrame   = transitionContext.GetFinalFrameForViewController(toViewController);

            var offset = new CGVector(0f, 0f);

            if (targetEdge == UIRectEdge.Left)
            {
                offset = new CGVector(-1f, 0f);
            }
            else if (targetEdge == UIRectEdge.Right)
            {
                offset = new CGVector(1f, 0f);
            }

            fromView.Frame = fromFrame;

            CGRect auxFrame = toFrame;

            auxFrame.Offset(toFrame.Width * offset.dx * -1f, toFrame.Height * offset.dy * -1f);
            toView.Frame = auxFrame;

            containerView.AddSubview(toView);

            var duration = TransitionDuration(transitionContext);

            UIView.Animate(duration, 0, UIViewAnimationOptions.TransitionNone, () => {
                var fromFrameAux = fromFrame;
                fromFrameAux.Offset(fromFrame.Width * offset.dx, fromFrame.Height * offset.dy);
                fromView.Frame = fromFrameAux;

                toView.Frame = toFrame;
            }, () => {
                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            }
                           );
        }
        public override async void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var containerView = transitionContext.ContainerView;

            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            var fromViewSnapshot = _fromView.SnapshotView(true);

            // This needs to be added to the hierarchy for the frame is correct, but we don't want it visible yet.
            containerView.InsertSubview(toViewController.View, 0);
            containerView.AddSubview(fromViewSnapshot);

            // Without this, the snapshots include the following "recent" changes
            await Task.Yield();

            _toView.Alpha   = 0f;
            _fromView.Alpha = 0f;

            var fromFrame = _fromView.ConvertRectToView(_fromView.Frame, containerView);
            var toFrame   = _toView.ConvertRectToView(_toView.Frame, containerView);


            containerView.InsertSubview(toViewController.View, 1);
            var toViewInitialX = _operation == UINavigationControllerOperation.Pop ? -toViewController.View.Frame.Width : toViewController.View.Frame.Width;

            toViewController.View.Frame = new CGRect(toViewInitialX, fromViewController.View.Frame.Y, toViewController.View.Frame.Width, toViewController.View.Frame.Height);

            fromViewSnapshot.Frame = fromFrame;

            UIView.AnimateNotify(0.250, () =>
            {
                fromViewSnapshot.Frame      = toFrame;
                fromViewSnapshot.Alpha      = 1;
                toViewController.View.Frame = new CGRect(fromViewController.View.Frame.X, fromViewController.View.Frame.Y, toViewController.View.Frame.Width, toViewController.View.Frame.Height);
            }, x =>
            {
                _toView.Alpha   = 1;
                _fromView.Alpha = 1;
                fromViewSnapshot.RemoveFromSuperview();
                transitionContext.CompleteTransition(x);
            });
        }
Beispiel #35
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var containerView      = transitionContext.ContainerView;

            if (fromViewController == null || toViewController == null || containerView == null)
            {
                return;
            }

            var snapshot = containerView.ViewWithTag(MenuHelper.SnapshotNumber);

            UIView.Animate(
                TransitionDuration(transitionContext),
                () =>
            {
                if (snapshot == null)
                {
                    return;
                }

                var frame = new CGRect(CGPoint.Empty, UIScreen.MainScreen.Bounds.Size);
                snapshot.Superview.Frame = frame;
            },
                () =>
            {
                var transitionComplete = !transitionContext.TransitionWasCancelled;

                if (transitionComplete && snapshot != null)
                {
                    containerView.InsertSubviewAbove(toViewController.View, fromViewController.View);
                    snapshot.Superview.RemoveFromSuperview();
                    snapshot.RemoveFromSuperview();
                }
                else if (transitionComplete)
                {
                    containerView.InsertSubviewAbove(toViewController.View, fromViewController.View);
                }

                transitionContext.CompleteTransition(transitionComplete);
            });
        }
        public async override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            UIViewController fromVC   = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            UIView           fromView = fromVC.View;
            UIViewController toVC     = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            UIView           toView   = toVC.View;

            UIView containerView = transitionContext.ContainerView;

            if (IsPresentation)
            {
                containerView.AddSubview(toView);
            }

            UIViewController animatingVC   = IsPresentation ? toVC : fromVC;
            UIView           animatingView = animatingVC.View;

            CGRect appearedFrame  = transitionContext.GetFinalFrameForViewController(animatingVC);
            CGRect dismissedFrame = appearedFrame;

            CGPoint targetLacation = dismissedFrame.Location;

            targetLacation.X       += dismissedFrame.Size.Width;
            dismissedFrame.Location = targetLacation;

            CGRect initialFrame = IsPresentation ? dismissedFrame : appearedFrame;
            CGRect finalFrame   = IsPresentation ? appearedFrame : dismissedFrame;

            animatingView.Frame = initialFrame;

            UIViewAnimationOptions opt = UIViewAnimationOptions.AllowUserInteraction
                                         | UIViewAnimationOptions.BeginFromCurrentState;
            await UIView.AnimateNotifyAsync(TransitionDuration (transitionContext), 0, 300, 5, opt, () => {
                animatingView.Frame = finalFrame;
            });

            if (!IsPresentation)
            {
                fromView.RemoveFromSuperview();
            }

            transitionContext.CompleteTransition(true);
        }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var containerView      = transitionContext.ContainerView;

            if (fromViewController == null || toViewController == null || containerView == null)
            {
                return;
            }

            containerView.InsertSubviewBelow(toViewController.View, fromViewController.View);

            var snapshot = fromViewController.View.SnapshotView(false);

            snapshot.Tag = MenuHelper.SnapshotNumber;
            snapshot.UserInteractionEnabled = false;
            snapshot.Layer.ShadowOpacity    = 0.7f;
            _snapshotContainerView.Frame    = snapshot.Frame;
            // Workaround for build up collection of snapshots inside snapshot container view
            foreach (var subView in _snapshotContainerView.Subviews)
            {
                subView.RemoveFromSuperview();
            }
            _snapshotContainerView.AddSubview(snapshot);
            containerView.InsertSubviewAbove(_snapshotContainerView, toViewController.View);
            fromViewController.View.Hidden = true;

            UIView.Animate(
                TransitionDuration(transitionContext),
                () =>
            {
                var center = _snapshotContainerView.Center;

                center.X += UIScreen.MainScreen.Bounds.Width * MenuHelper.MenuWidth;
                _snapshotContainerView.Center = center;
            },
                () =>
            {
                fromViewController.View.Hidden = false;
                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            });
        }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var containerView      = transitionContext.ContainerView;
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
            var toViewController   = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);

            toViewController.View.Alpha = 0f;

            containerView.AddSubview(toViewController.View);

            UIView.Animate(Duration, 0, UIViewAnimationOptions.CurveEaseInOut,
                           () =>
            {
                toViewController.View.Alpha = 1f;
            }, () =>
            {
                transitionContext.CompleteTransition(true);
            }
                           );
        }
		public async override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			UIViewController fromVC = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
			UIView fromView = fromVC.View;
			UIViewController toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			UIView toView = toVC.View;

			UIView containerView = transitionContext.ContainerView;

			if (IsPresentation)
				containerView.AddSubview (toView);

			UIViewController animatingVC = IsPresentation ? toVC : fromVC;
			UIView animatingView = animatingVC.View;

			CGRect appearedFrame = transitionContext.GetFinalFrameForViewController (animatingVC);
			CGRect dismissedFrame = appearedFrame;

			CGPoint targetLacation = dismissedFrame.Location;
			targetLacation.X += dismissedFrame.Size.Width;
			dismissedFrame.Location = targetLacation;

			CGRect initialFrame = IsPresentation ? dismissedFrame : appearedFrame;
			CGRect finalFrame = IsPresentation ? appearedFrame : dismissedFrame;

			animatingView.Frame = initialFrame;

			UIViewAnimationOptions opt = UIViewAnimationOptions.AllowUserInteraction
				                       | UIViewAnimationOptions.BeginFromCurrentState;
			await UIView.AnimateNotifyAsync (TransitionDuration (transitionContext), 0, 300, 5, opt, () => {
				animatingView.Frame = finalFrame;
			});

			if (!IsPresentation)
				fromView.RemoveFromSuperview ();

			transitionContext.CompleteTransition (true);
		}
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var inView = transitionContext.ContainerView;

            var toViewController = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey);
            var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

            inView.AddSubview(toViewController.View);

            toViewController.View.Frame = CGRect.Empty;

            var startingPoint = GetStartingPoint(fromViewController.InterfaceOrientation);
            
			if (fromViewController.InterfaceOrientation == UIInterfaceOrientation.Portrait)
            {
                toViewController.View.Frame = new CGRect(startingPoint.X, startingPoint.Y, 
                                                             fromViewController.View.Frame.Width,
                                                             fromViewController.View.Frame.Height);
            }
            else
            {
                toViewController.View.Frame = new CGRect(startingPoint.X, startingPoint.Y, 
                                                             fromViewController.View.Frame.Height,
                                                             fromViewController.View.Frame.Width);
            }

            UIView.AnimateNotify(_transitionDuration,
                                 () =>
            {
                var endingPoint = GetEndingPoint(fromViewController.InterfaceOrientation);
                toViewController.View.Frame = new CGRect(endingPoint.X, endingPoint.Y, fromViewController.View.Frame.Width,
                                                                 fromViewController.View.Frame.Height);
                fromViewController.View.Alpha = 0.5f;
            },
                                 (finished) => transitionContext.CompleteTransition(true)
                                );
        }
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			var inView = transitionContext.ContainerView;
			var toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			var toView = toVC.View;

			inView.AddSubview (toView);

			var frame = toView.Frame;
			toView.Frame = CGRect.Empty;

			UIView.Animate (TransitionDuration (transitionContext), () => {
				toView.Frame = new CGRect (20, 20, frame.Width - 40, frame.Height - 40);
			}, () => {
				transitionContext.CompleteTransition (true);
			});
		}
		/// <summary>
		/// Animates the transition.
		/// </summary>
		/// <param name="transitionContext">Transition context.</param>
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext) {
			var inView = transitionContext.ContainerView;
			var toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
			var toView = toVC.View;

			toView.Alpha = 0.0f;
			inView.AddSubview (toView);
			toView.TranslatesAutoresizingMaskIntoConstraints = false;
			inView.AddConstraint (NSLayoutConstraint.Create (inView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, toView, NSLayoutAttribute.Top, 1.0f, 0.0f));
			inView.AddConstraint (NSLayoutConstraint.Create (inView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, toView, NSLayoutAttribute.Trailing, 1.0f, 0.0f));
			inView.AddConstraint (NSLayoutConstraint.Create (inView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, toView, NSLayoutAttribute.Bottom, 1.0f, 0.0f));
			inView.AddConstraint (NSLayoutConstraint.Create (inView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, toView, NSLayoutAttribute.Leading, 1.0f, 0.0f));

			UIView.Animate (TransitionDuration (transitionContext), () => {
				toView.Alpha = 1.0f;
			}, () => {
				transitionContext.CompleteTransition (true);
			});
		}
        //Called when a Push/Pop/Swipe back happens
        public override void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            context = transitionContext;
            lastPercent = 1f;
            animationStarted = true;
            var inView = transitionContext.ContainerView;
            var fromVC = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
            var fromView = fromVC.View;
            var toVC = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
            var toView = toVC.View;

            var frame = toView.Frame;

            if (reverse) {
                inView.InsertSubviewBelow (toView, fromVC.View);
                toView.Frame = new CGRect (-inView.Frame.Width, 0, frame.Width, frame.Height);
            } else {
                inView.AddSubview (toView);
                toView.Frame = new CGRect (inView.Frame.Width, 0, frame.Width, frame.Height);
            }

            UIView.Animate (Duration,0,UIViewAnimationOptions.AllowUserInteraction, () => {
                if (reverse) {
                    fromView.Frame = new CGRect (inView.Frame.Width, 0, frame.Width, frame.Height);
                    toView.Frame = new CGRect (0, 0, frame.Width, frame.Height);
                } else {
                    fromView.Frame = new CGRect (-inView.Frame.Width, 0, frame.Width, frame.Height);
                    toView.Frame = new CGRect (0, 0, frame.Width, frame.Height);
                }
            }, () => {
                if (animationStarted){
                    context.FinishInteractiveTransition();
                    context.CompleteTransition (true);
                    context=null;
                }
                animationStarted=false;
            });
        }
            public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
            {
                var toController = (DurationChangeViewController)transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
                var fromController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
                var container = transitionContext.ContainerView;

                var imageView = (UIImageView)toController.View;
                imageView.Image = GetBlurred (fromController.View);

                toController.View.Frame = transitionContext.GetFinalFrameForViewController (toController);
                toController.View.Alpha = 0;
                container.InsertSubviewAbove (toController.View, fromController.View);

                UIView.Animate (TransitionDuration (transitionContext)
                                ,() => toController.View.Alpha = 1
                ,() => {
                    if (!transitionContext.TransitionWasCancelled) {
                        fromController.View.RemoveFromSuperview ();
                    }
                    transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
                });
            }
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			//1
			_transitionContext = transitionContext;

			//2
			var containerView = _transitionContext.ContainerView;
			var fromViewController = _transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as OnboardingController;
			var toViewController = _transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as ContainerController;
			var fromRect = fromViewController.NavigationRect;
			var toRect = new CGRect (-toViewController.View.Bounds.Width / 2, -toViewController.View.Bounds.Height / 2, toViewController.View.Bounds.Width * 2, toViewController.View.Bounds.Height * 2);

			//3
			containerView.AddSubview(toViewController.View);

			//4
			var circleMaskPathInitial = UIBezierPath.FromRoundedRect(fromRect, fromRect.Height/2);

			var circleMaskPathFinal = UIBezierPath.FromRoundedRect (toRect, toRect.Height/2);

			//5
			var maskLayer = new CAShapeLayer();
			maskLayer.Path = circleMaskPathFinal.CGPath;
			toViewController.View.Layer.Mask = maskLayer;

			//6
			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.SetFrom(circleMaskPathInitial.CGPath);
			maskLayerAnimation.SetTo(circleMaskPathFinal.CGPath);
			maskLayerAnimation.Duration =  TransitionDuration(_transitionContext);
			maskLayerAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseIn);

			maskLayerAnimation.AnimationStopped += (object sender, CAAnimationStateEventArgs e) => {
				if(_transitionContext != null) {
					_transitionContext.CompleteTransition (!_transitionContext.TransitionWasCancelled);
					var controller = _transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
					if(controller != null) {
						controller.View.Layer.Mask = null;	
					}
				}
			};

			maskLayer.AddAnimation (maskLayerAnimation, "path");
		}
            public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
            {
                var toController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey);
                var fromController = (DurationChangeViewController)transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey);
                var container = transitionContext.ContainerView;

                toController.View.Frame = transitionContext.GetFinalFrameForViewController (toController);
                container.InsertSubviewBelow (toController.View, fromController.View);
                fromController.View.Alpha = 1;

                UIView.Animate (
                    TransitionDuration (transitionContext),
                delegate {
                    fromController.View.Alpha = 0;
                },
                delegate {
                    if (!transitionContext.TransitionWasCancelled) {
                        fromController.View.RemoveFromSuperview ();
                    }
                    transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
                }
                );
            }