Example #1
0
 private void CloseDrawer(IUIViewControllerContextTransitioning transitionContext, UIViewController fromVC, FlyingObjectsContainterViewController toVC)
 {
     if (Direction == DrawerDirection.Left)
     {
         toVC.View.LayoutIfNeeded();
         toVC.ShiftContainerRight(0);
         UIView.Animate(0.25,
                        () =>
         {
             fromVC.View.Frame = new CGRect(-toVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, fromVC.View.Frame.Size.Width, toVC.View.Window.Frame.Size.Height);
             toVC.View.LayoutIfNeeded();
         },
                        () =>
         {
             transitionContext.CompleteTransition(true);
         }
                        );
     }
     else
     {
         toVC.View.LayoutIfNeeded();
         toVC.ShiftContainerRight(0);
         UIView.Animate(0.25,
                        () =>
         {
             fromVC.View.Frame = new CGRect(toVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, fromVC.View.Frame.Size.Width, toVC.View.Window.Frame.Size.Height);
             toVC.View.LayoutIfNeeded();
         },
                        () =>
         {
             fromVC = null;
             transitionContext.CompleteTransition(true);
         });
     }
 }
        protected override void AnimatePresentingInContext(IUIViewControllerContextTransitioning transitioningContext, UIViewController originatingController, UIViewController destinationController)
        {
            CGRect fromVCrect = transitioningContext.GetInitialFrameForViewController(originatingController);
            CGRect toVCRect   = fromVCrect;

            toVCRect.Y = (nfloat)(toVCRect.Size.Height - this.InitialY);

            destinationController.View.Frame = toVCRect;
            UIView container = transitioningContext.ContainerView;
            UIView imageView = new UIImageView(DummyImage);

            destinationController.View.AddSubview(imageView);

            container.AddSubview(originatingController.View);
            container.AddSubview(destinationController.View);

            UIView.Animate(AnimationDuration, () =>
            {
                destinationController.View.Frame = fromVCrect;
                imageView.Alpha = 0.0f;
            },
                           () =>
            {
                imageView.RemoveFromSuperview();
                if (transitioningContext.TransitionWasCancelled)
                {
                    transitioningContext.CompleteTransition(false);
                }
                else
                {
                    transitioningContext.CompleteTransition(true);
                }
            });
        }
Example #3
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 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));
                }
            }
        }
        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));
        }
            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 override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var toViewController = GetViewController(transitionContext, UITransitionContext.ToViewControllerKey);

            bool isPushing = TransitionOperation == UINavigationControllerOperation.Push;

            var detailView = toViewController.View;

            detailView.Frame = GetFrameWithNavigationBarOffset(detailView.Frame, toViewController, ToHasNavigationBar);

            transitionContext.ContainerView.AddSubview(detailView);

            detailView.Alpha = 0;

            if (!isPushing)
            {
                toViewController.View.Alpha = 0.0f;
            }

            UIView.Animate(Duration, () =>
            {
                detailView.Alpha = 1;
            }, () =>
            {
                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            });
        }
Example #9
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";
                }
            });
        }
Example #10
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);
                }
                    );
            }
Example #11
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 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);
            }
                           );
        }
Example #13
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 override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext,
                                               UIViewController fromViewController, UIViewController toViewController,
                                               UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;

            containerView.AddSubview(toView);
            containerView.SendSubviewToBack(toView);

            double   duration  = TransitionDuration(transitionContext);
            NSAction animation = () => {
                fromView.Alpha = 0f;
            };

            UIView.Animate(duration, animation, () => {
                if (transitionContext.TransitionWasCancelled)
                {
                    fromView.Alpha = 1f;
                }
                else
                {
                    fromView.RemoveFromSuperview();
                    fromView.Alpha = 1f;
                }

                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            });
        }
Example #15
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;
                    default:
                        break;
                }

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

            Action animation = null;

            if (IsPresenting)
            {
                toView.Frame     = transitionContext.ContainerView.Bounds;
                toView.Transform = CGAffineTransform.MakeTranslation(0, toView.Frame.Size.Height);
                transitionContext.ContainerView.AddSubview(toView);
                animation = () => toView.Transform = CGAffineTransform.MakeIdentity();
            }
            else
            {
                toView.Frame = transitionContext.ContainerView.Bounds;
                transitionContext.ContainerView.InsertSubviewBelow(toView, fromView);
                animation = () => fromView.Transform = CGAffineTransform.MakeTranslation(0, toView.Frame.Size.Height);
            }

            animator = CreateDefaultAnimator();
            animator.AddCompletion(position => transitionContext.CompleteTransition(true));
            animator.AddAnimations(animation);
            animator.StartAnimation();
        }
        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();
        }
        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();
        }
Example #20
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);
        }
        public override void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            base.StartInteractiveTransition(transitionContext);

            Action animation = null;

            if (IsPresenting)
            {
                toView.Frame     = transitionContext.ContainerView.Bounds;
                toView.Transform = CGAffineTransform.MakeTranslation(0, toView.Frame.Size.Height);
                transitionContext.ContainerView.AddSubview(toView);
                animation = () => toView.Transform = CGAffineTransform.MakeIdentity();
            }
            else
            {
            }

            if (WantsInteractiveStart)
            {
                animator = new UIViewPropertyAnimator(DEFAULT_DURATION, UIViewAnimationCurve.Linear, animation);
            }
            else
            {
                animator = CreateDefaultAnimator();
                animator.AddCompletion(position => transitionContext.CompleteTransition(true));
                animator.AddAnimations(animation);
                animator.StartAnimation();
            }
        }
		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);
		}
Example #23
0
        private void OpenDrawer(IUIViewControllerContextTransitioning transitionContext, UIViewController toVC, FlyingObjectsContainterViewController fromVC)
        {
            transitionContext.ContainerView.AddSubview(toVC.View);
            var container = (fromVC as FlyingObjectsContainterViewController).ContainerNavigationController;
            var height    = container.View.Window.Frame.Height - (container.View.Window.Frame.Height - container.View.Frame.GetMaxY());

            if (Direction == DrawerDirection.Left)
            {
                toVC.View.Frame = new CGRect(-fromVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                fromVC.View.LayoutIfNeeded();
                fromVC.ShiftContainerRight(270);

                UIView.Animate(TransitionDuration(transitionContext),
                               () =>
                {
                    if (fromVC.View.Frame.Size.Width - 50 > MaxX)
                    {
                        MaxX = 270;
                    }
                    toVC.View.Frame = new CGRect(0, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                    fromVC.View.LayoutIfNeeded();
                },
                               () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
            else
            {
                toVC.View.Frame = new CGRect(fromVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                fromVC.View.LayoutIfNeeded();
                fromVC.ShiftContainerRight(270);

                UIView.Animate(TransitionDuration(transitionContext),
                               () =>
                {
                    toVC.View.Frame = new CGRect(fromVC.View.Frame.Size.Width - MaxX, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                    fromVC.View.LayoutIfNeeded();
                },
                               () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
        }
		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext,
		                                        UIViewController fromViewController, UIViewController toViewController,
		                                        UIView fromView, UIView toView)
		{
			UIView containerView = transitionContext.ContainerView;
			containerView.AddSubview (toView);
			containerView.SendSubviewToBack (toView);

			var transform = CATransform3D.Identity;
			transform.m34 = -0.002f;
			containerView.Layer.SublayerTransform = transform;

			var initialFrame = transitionContext.GetInitialFrameForViewController (fromViewController);
			fromView.Frame = initialFrame;
			toView.Frame = initialFrame;

			List<UIView> toViewSnapshots = CreateSnapshots (toView, true);
			UIView flippedSectionOfToView = toViewSnapshots [Reverse ? 0 : 1];

			List<UIView> fromViewSnapshots = CreateSnapshots (fromView, false);
			UIView flippedSectionOfFromView = fromViewSnapshots [Reverse ? 1 : 0];

			flippedSectionOfFromView = AddShadowToView (flippedSectionOfFromView, !Reverse);
			UIView flippedSectionOfFromViewShadow = flippedSectionOfFromView.Subviews [1];
			flippedSectionOfFromViewShadow.Alpha = 0f;

			flippedSectionOfToView = AddShadowToView (flippedSectionOfToView, Reverse);
			UIView flippedSectionOfToViewShadow = flippedSectionOfToView.Subviews [1];
			flippedSectionOfToViewShadow.Alpha = 1f;

			// change the anchor point so that the view rotate around the correct edge
			UpdateAnchorPointAndOffset (new CGPoint (Reverse ? 0f : 1f, 0.5f), flippedSectionOfFromView);
			UpdateAnchorPointAndOffset (new CGPoint (Reverse ? 1f : 0f, 0.5f), flippedSectionOfToView);

			flippedSectionOfToView.Layer.Transform = Rotate (Reverse ? (float)Math.PI / 2 : -(float)Math.PI / 2);
			double duration = TransitionDuration (transitionContext);

			Action animations = () => {
				UIView.AddKeyframeWithRelativeStartTime (0.0, 0.5, () => {
					flippedSectionOfFromView.Layer.Transform = Rotate (Reverse ? -(float)Math.PI / 2 : (float)Math.PI / 2);
					flippedSectionOfFromViewShadow.Alpha = 1f;
				});

				UIView.AddKeyframeWithRelativeStartTime (0.5, 0.5, () => {
					flippedSectionOfToView.Layer.Transform = Rotate (Reverse ? 0.001f : -0.001f);
					flippedSectionOfToViewShadow.Alpha = 0f;
				});
			};

			UIView.AnimateKeyframes (duration, 0.0, UIViewKeyframeAnimationOptions.CalculationModeLinear, animations, (finished) => {
				if (transitionContext.TransitionWasCancelled) {
					RemoveOtherViews (fromView);
				} else {
					RemoveOtherViews (toView);
				}

				transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
			});
		}
Example #25
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);
                    });
                }
            }
Example #26
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);
                    });
                }
            }
Example #27
0
 private void OnAnimationCompled(IUIViewControllerContextTransitioning context, UIView fromView)
 {
     if (!context.TransitionWasCancelled)
     {
         fromView.RemoveFromSuperview();
     }
     context.CompleteTransition(!context.TransitionWasCancelled);
 }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext,
                                               UIViewController fromViewController, UIViewController toViewController,
                                               UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;

            containerView.AddSubview(toView);
            containerView.SendSubviewToBack(toView);

            var size      = toView.Frame.Size;
            var snapshots = new List <UIView> ();

            float  xFactor = 10f;
            nfloat yFactor = xFactor * size.Height / size.Width;

            for (nfloat x = 0; x < size.Width; x += size.Width / xFactor)
            {
                for (nfloat y = 0; y < size.Height; y += size.Height / yFactor)
                {
                    var    snapshotRegion = new CGRect(x, y, size.Width / xFactor, size.Height / yFactor);
                    UIView snapshot       = fromView.ResizableSnapshotView(snapshotRegion, false, UIEdgeInsets.Zero);

                    snapshot.Frame = snapshotRegion;
                    containerView.AddSubview(snapshot);
                    snapshots.Add(snapshot);
                }
            }

            containerView.SendSubviewToBack(fromView);

            var    rnd      = new Random();
            double duration = TransitionDuration(transitionContext);
            Action action   = () => {
                foreach (UIView view in snapshots)
                {
                    float xOffset = rnd.Next(-100, 100);
                    float yOffset = rnd.Next(-100, 100);
                    view.Frame = new CGRect(view.Frame.X + xOffset, view.Frame.Y + yOffset, view.Frame.Width, view.Frame.Height);
                    view.Alpha = 0f;
                    var transition = CGAffineTransform.MakeRotation(rnd.Next(-10, 10));
                    transition.Scale(0f, 0f);
                    view.Transform = transition;
                }
            };

            UIView.Animate(duration, action, () => {
                foreach (UIView view in snapshots)
                {
                    view.RemoveFromSuperview();
                }

                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            });
        }
Example #29
0
        void DismissAnimateTransition(IUIViewControllerContextTransitioning context)
        {
            var fromViewController = context.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);

            UIView.Animate(TransitionDuration(context), 0, UIViewAnimationOptions.CurveLinear, () =>
            {
                fromViewController.View.Alpha = 0;
            }, () =>
            {
                context.CompleteTransition(true);
            });
        }
        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 override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
            {
                var fromViewController = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey);
                var containerView      = transitionContext.ContainerView;

                var animationDuration = TransitionDuration(transitionContext);

                containerView.AddSubview(fromViewController.View);

                UIView.Animate(animationDuration,
                               () => fromViewController.View.Transform = CGAffineTransform.MakeTranslation(0, containerView.Bounds.Height),
                               () => 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);

            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);
			});
		}
Example #35
0
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            var destinationViewController = GetViewController(transitionContext, UITransitionContext.ToViewControllerKey);
            var sourceViewController      = GetViewController(transitionContext, UITransitionContext.FromViewControllerKey);

            var detailView = new UIView();

            if (TransitionOperation == UINavigationControllerOperation.Pop && ApplyPopTransitionToOrigin)
            {
                detailView       = sourceViewController.View;
                detailView.Frame = GetFrameWithNavigationBarOffset(detailView.Frame, sourceViewController, FromHasNavigationBar);
            }
            else
            {
                detailView       = destinationViewController.View;
                detailView.Frame = GetFrameWithNavigationBarOffset(detailView.Frame, destinationViewController, ToHasNavigationBar);
            }

            transitionContext.ContainerView.AddSubview(detailView);

            if (TransitionOperation == UINavigationControllerOperation.Pop && ApplyPopTransitionToOrigin)
            {
                var destinationView = destinationViewController.View;
                destinationView.Frame = GetFrameWithNavigationBarOffset(destinationView.Frame, sourceViewController, FromHasNavigationBar);
                transitionContext.ContainerView.InsertSubviewBelow(destinationView, detailView);
            }
            else
            {
                detailView.Transform = GetInitialTranslation(detailView);
            }

            UIView.Animate(Duration, () =>
            {
                if (TransitionOperation == UINavigationControllerOperation.Pop && ApplyPopTransitionToOrigin)
                {
                    detailView.Transform = GetOriginViewPopTranslation(detailView);
                }
                else
                {
                    detailView.Transform = CGAffineTransform.MakeIdentity();
                }
            }, () =>
            {
                if (TransitionOperation == UINavigationControllerOperation.Pop && ApplyPopTransitionToOrigin)
                {
                    detailView.RemoveFromSuperview();
                }
                transitionContext.CompleteTransition(!transitionContext.TransitionWasCancelled);
            });
        }
                public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
                {
                    var container = transitionContext.ContainerView;
                    var @from     = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey) as PaymentViewController;

                    UIView.Animate(ANIMATION_DURATION, 0.0, UIViewAnimationOptions.CurveLinear, () =>
                    {
                        @from._containerView.ChangeFrame(y: UIScreen.MainScreen.Bounds.Height);
                        @from.BackgroundView.Alpha = 0;
                    }, () =>
                    {
                        transitionContext.CompleteTransition(true);
                    });
                }
        public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext, 
		                                        UIViewController fromViewController, UIViewController toViewController, 
		                                        UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;
            containerView.AddSubview (toView);
            containerView.SendSubviewToBack (toView);

            var size = toView.Frame.Size;
            var snapshots = new List<UIView> ();

            float xFactor = 10f;
            float yFactor = xFactor * size.Height / size.Width;

            for (float x = 0; x < size.Width; x += size.Width / xFactor) {
                for (float y = 0; y < size.Height; y += size.Height / yFactor) {
                    var snapshotRegion = new RectangleF (x, y, size.Width / xFactor, size.Height / yFactor);
                    UIView snapshot = fromView.ResizableSnapshotView (snapshotRegion, false, UIEdgeInsets.Zero);

                    snapshot.Frame = snapshotRegion;
                    containerView.AddSubview (snapshot);
                    snapshots.Add (snapshot);
                }
            }

            containerView.SendSubviewToBack (fromView);

            var rnd = new Random ();
            double duration = TransitionDuration (transitionContext);
            NSAction action = () => {
                foreach (UIView view in snapshots) {
                    float xOffset = rnd.Next (-100, 100);
                    float yOffset = rnd.Next (-100, 100);
                    view.Frame = new RectangleF (view.Frame.X + xOffset, view.Frame.Y + yOffset, view.Frame.Width, view.Frame.Height);
                    view.Alpha = 0f;
                    var transition = CGAffineTransform.MakeRotation (rnd.Next (-10, 10));
                    transition.Scale (0f, 0f);
                    view.Transform = transition;
                }
            };

            UIView.Animate (duration, action, () => {
                foreach (UIView view in snapshots)
                    view.RemoveFromSuperview ();

                transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
            });
        }
		private void ExecuteReverseAnimation (IUIViewControllerContextTransitioning transitionContext,
		                                      UIViewController fromViewController, UIViewController toViewController,
		                                      UIView fromView, UIView toView)
		{
			UIView containerView = transitionContext.ContainerView;

			// positions the to- view behind the from- view
			toView.Frame = containerView.Frame;
			var scale = CATransform3D.Identity;
			toView.Layer.Transform = scale.Scale (0.6f, 0.6f, 1f);
			toView.Alpha = 0.6f;

			containerView.InsertSubviewAbove (toView, fromView);

			CGRect frameOffScreen = containerView.Frame;
			frameOffScreen.Y = containerView.Frame.Height;

			CATransform3D transform = GetFirstTransform ();

			Action animations = () => {

				// push the from- view off the bottom of the screen
				UIView.AddKeyframeWithRelativeStartTime (0.0, 0.5, () => {
					fromView.Frame = frameOffScreen;
				});

				// animate the to- view into place
				UIView.AddKeyframeWithRelativeStartTime (0.35, 0.35, () => {
					toView.Layer.Transform = transform;
					toView.Alpha = 1f;
				});

				UIView.AddKeyframeWithRelativeStartTime (0.75, 0.25, () => {
					toView.Layer.Transform = CATransform3D.Identity;
				});
			};

			UIView.AnimateKeyframes (Duration, 0.0, UIViewKeyframeAnimationOptions.CalculationModeCubic, animations, (finished) => {
				if (transitionContext.TransitionWasCancelled) {
					toView.Layer.Transform = CATransform3D.Identity;
					toView.Alpha = 1f;
				}

				transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
			});
		}
		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);
			});
		}
        private void ExecuteForwardAnimation(IUIViewControllerContextTransitioning transitionContext, 
		                                      UIViewController fromViewController, UIViewController toViewController, 
		                                      UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;

            // positions the to- view off the bottom of the sceen
            RectangleF offScreenFrame = containerView.Frame;
            offScreenFrame.Y = containerView.Frame.Height;
            toView.Frame = offScreenFrame;

            containerView.InsertSubviewAbove (toView, fromView);

            CATransform3D firstTransform = GetFirstTransform ();
            CATransform3D secondTrsnaform = GetSecondTransform (fromView);

            NSAction animations = () => {
                UIView.AddKeyframeWithRelativeStartTime (0.0, 0.4, () => {
                    fromView.Layer.Transform = firstTransform;
                    fromView.Alpha = 0.6f;
                });

                UIView.AddKeyframeWithRelativeStartTime (0.2, 0.4, () => {
                    fromView.Layer.Transform = secondTrsnaform;
                });

                UIView.AddKeyframeWithRelativeStartTime (0.6, 0.2, () => {
                    toView.Frame = new RectangleF (toView.Frame.X, containerView.Frame.Y - 30f,
                                                   toView.Frame.Width, toView.Frame.Height);
                });

                UIView.AddKeyframeWithRelativeStartTime (0.8, 0.2, () => {
                    toView.Frame = containerView.Frame;
                });
            };

            UIView.AnimateKeyframes (Duration, 0.0, UIViewKeyframeAnimationOptions.CalculationModeCubic, animations, (finished) => {

                transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
            });
        }
		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, 
		                                        UIViewController fromViewController, UIViewController toViewController, 
		                                        UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;
            containerView.AddSubview (toView);

            // Add a perspective transform
            var transform = CATransform3D.Identity;
            transform.m34 = -0.002f;
            containerView.Layer.SublayerTransform = transform;

            // Give both VCs the same start frame
            RectangleF initialFrame = transitionContext.GetInitialFrameForViewController (fromViewController);
            fromView.Frame = initialFrame;
            toView.Frame = initialFrame;

            float factor = Reverse ? 1f : -1f;

            // flip the to VC halfway round - hiding it
            toView.Layer.Transform = Rotate (factor * -(float)Math.PI / 2);
            double duration = TransitionDuration (transitionContext);

            NSAction animations = () => {
                UIView.AddKeyframeWithRelativeStartTime (0.0, 0.5, () => {
                    fromView.Layer.Transform = Rotate (factor * (float)Math.PI / 2);
                });

                UIView.AddKeyframeWithRelativeStartTime (0.5, 0.5, () => {
                    toView.Layer.Transform = Rotate (0f);
                });
            };

            UIView.AnimateKeyframes (duration, 0.0, UIViewKeyframeAnimationOptions.CalculationModeLinear, animations, (finished) => {
                transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
            });
        }
        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, 
		                                        UIViewController fromViewController, UIViewController toViewController, 
		                                        UIView fromView, UIView toView)
        {
            UIView containerView = transitionContext.ContainerView;
            containerView.AddSubview (toView);
            containerView.SendSubviewToBack (toView);

            double duration = TransitionDuration (transitionContext);
            NSAction animation = () => {
                fromView.Alpha = 0f;
            };

            UIView.Animate (duration, animation, () => {
                if (transitionContext.TransitionWasCancelled) {
                    fromView.Alpha = 1f;
                } else {
                    fromView.RemoveFromSuperview ();
                    fromView.Alpha = 1f;
                }

                transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
            });
        }
        //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,
            UIViewController fromViewController, UIViewController toViewController,
            UIView fromView, UIView toView)
        {
            // Add the toView to the container
            UIView containerView = transitionContext.ContainerView;

            toView.Center = new CGPoint (1000f, 0f);
            containerView.AddSubview (toView);

            // Add a perspective transform
            var transform = CATransform3D.Identity;
            transform.m34 = -0.005f;
            containerView.Layer.SublayerTransform = transform;

            CGSize size = toView.Frame.Size;

            float foldWidth = (float)(size.Width * 0.5f / Folds);

            // arrays that hold the snapshot views
            var fromViewFolds = new List<UIView> ();
            var toViewFolds = new List<UIView> ();

            for (int i = 0; i < Folds; i++) {
                float offset = i * foldWidth * 2;

                // the left and right side of the fold for the from- view, with identity transform and 0.0 alpha
                // on the shadow, with each view at its initial position
                UIView leftFromViewFold = CreateSnapshot (fromView, false, offset, true);
                leftFromViewFold.Layer.Position = new CGPoint (offset, size.Height / 2f);
                fromViewFolds.Add (leftFromViewFold);
                leftFromViewFold.Subviews [1].Alpha = 0f;

                UIView rightFromViewFold = CreateSnapshot (fromView, false, offset + foldWidth, false);
                rightFromViewFold.Layer.Position = new CGPoint (offset + foldWidth * 2f, size.Height / 2f);
                fromViewFolds.Add (rightFromViewFold);
                rightFromViewFold.Subviews [1].Alpha = 0f;

                // the left and right side of the fold for the to- view, with a 90-degree transform and 1.0 alpha
                // on the shadow, with each view positioned at the very edge of the screen
                UIView leftToViewFold = CreateSnapshot (toView, true, offset, true);
                leftToViewFold.Layer.Position = new CGPoint (Reverse ? size.Width : 0f, size.Height / 2f);
                leftToViewFold.Layer.Transform = CATransform3D.MakeRotation ((float)Math.PI / 2f, 0f, 1f, 0f);
                toViewFolds.Add (leftToViewFold);

                UIView rightToViewFold = CreateSnapshot (toView, true, offset + foldWidth, false);
                rightToViewFold.Layer.Position = new CGPoint (Reverse ? size.Width : 0f, size.Height / 2f);
                rightToViewFold.Layer.Transform = CATransform3D.MakeRotation (-(float)Math.PI / 2f, 0f, 1f, 0f);
                toViewFolds.Add (rightToViewFold);
            }

            //move the from- view off screen
            fromView.Center = new CGPoint (1000f, 0f);

            // create the animation
            double duration = TransitionDuration (transitionContext);

            Action animation = () => {
                for (int i = 0; i < Folds; i++) {

                    float offset = i * foldWidth * 2;

                    // the left and right side of the fold for the from- view, with 90 degree transform and 1.0 alpha
                    // on the shadow, with each view positioned at the edge of thw screen.
                    UIView leftFromView = fromViewFolds [i * 2];
                    leftFromView.Layer.Position = new CGPoint (Reverse ? 0f : size.Width, size.Height / 2f);
                    leftFromView.Layer.Transform = transform.Rotate ((float)Math.PI / 2f, 0f, 1f, 0f);
                    leftFromView.Subviews [1].Alpha = 1f;

                    UIView rightFromView = fromViewFolds [i * 2 + 1];
                    rightFromView.Layer.Position = new CGPoint (Reverse ? 0f : size.Width, size.Height / 2f);
                    rightFromView.Layer.Transform = transform.Rotate (-(float)Math.PI / 2f, 0f, 1f, 0f);
                    rightFromView.Subviews [1].Alpha = 1f;

                    // the left and right side of the fold for the to- view, with identity transform and 0.0 alpha
                    // on the shadow, with each view at its final position
                    UIView leftToView = toViewFolds [i * 2];
                    leftToView.Layer.Position = new CGPoint (offset, size.Height / 2f);
                    leftToView.Layer.Transform = CATransform3D.Identity;
                    leftToView.Subviews [1].Alpha = 0f;

                    UIView rightToView = toViewFolds [i * 2 + 1];
                    rightToView.Layer.Position = new CGPoint (offset + foldWidth * 2f, size.Height / 2f);
                    rightToView.Layer.Transform = CATransform3D.Identity;
                    rightToView.Subviews [1].Alpha = 0f;
                }
            };

            UIView.Animate (duration, animation, () => {
                // remove the snapshot views
                foreach (UIView view in toViewFolds) {
                    view.RemoveFromSuperview ();
                }

                foreach (UIView view in fromViewFolds) {
                    view.RemoveFromSuperview ();
                }

                // restore the to- and from- to the initial location
                toView.Frame = containerView.Bounds;
                fromView.Frame = containerView.Bounds;
                transitionContext.CompleteTransition (!transitionContext.TransitionWasCancelled);
            });
        }
            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)
            {
                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);
                }
                );
            }
Example #50
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");
		}