Example #1
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);
            }
                           );
        }
        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));
        }
        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);
                }
            });
        }
        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 #6
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";
                }
            });
        }
            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);
            }
        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();
        }
		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);
			}
		}
        protected void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionCtx)
        {
            SlidingViewController sliding       = this.SlidingViewController;
            UIViewController      topController = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextTopViewControllerKey);

            // Disable user interaction of top controller's view
            topController.View.UserInteractionEnabled = false;
            if (_interactive)
            {
                UIViewController underController       = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextUnderLeftControllerKey);
                RectangleF       underViewInitialFrame = sliding.GetInitialFrameForViewController(underController);
                RectangleF       underViewFinalFrame   = sliding.GetFinalFrameForViewController(underController);

                // Update frame of under controller view
                underController.View.Frame = underViewInitialFrame.IsEmpty ? underViewFinalFrame : underViewInitialFrame;
                // Insert under view below top view
                sliding.ContainerView.InsertSubviewBelow(underController.View, topController.View);

                // Do some calculation
                float finalLeftEdge   = sliding.GetFinalFrameForViewController(topController).GetMinX();
                float initialLeftEdge = sliding.GetInitialFrameForViewController(topController).GetMinX();

                _fullWidth           = Math.Abs(finalLeftEdge - initialLeftEdge);
                _positiveLeftToRight = initialLeftEdge < finalLeftEdge;
            }
            else
            {
                this.AnimationController.AnimateTransition(transitionCtx);
            }
            // Enable user interaction of top controller's view
            topController.View.UserInteractionEnabled = true;
        }
        void PerformFadeAnimation(IUIViewControllerContextTransitioning transitionContext)
        {
            var fromView = transitionContext.GetViewFor(UITransitionContext.FromViewKey);
            var toView   = transitionContext.GetViewFor(UITransitionContext.ToViewKey);

            var viewToFade     = toView;
            var beginningAlpha = 0.0f;
            var endingAlpha    = 1.0f;

            if (IsDismissing)
            {
                viewToFade     = fromView;
                beginningAlpha = 1.0f;
                endingAlpha    = 0.0f;
            }

            viewToFade.Alpha = beginningAlpha;

            UIView.Animate(FadeDuration(transitionContext), () => { viewToFade.Alpha = endingAlpha; },
                           () => {
                if (!ShouldPerformZoomingAnimation)
                {
                    CompleteTransition(transitionContext);
                }
            });
        }
        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 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();
        }
Example #14
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);
            });
        }
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 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();
            }
        }
Example #17
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 #18
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);
        }
Example #19
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);
         });
     }
 }
Example #20
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);
            }
        }
        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);
            });
        }
        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 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 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();
        }
		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,
		                                        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 #27
0
 private void OnAnimationCompled(IUIViewControllerContextTransitioning context, UIView fromView)
 {
     if (!context.TransitionWasCancelled)
     {
         fromView.RemoveFromSuperview();
     }
     context.CompleteTransition(!context.TransitionWasCancelled);
 }
 public override void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionContext)
 {
     if (ViewToHideWhenBeginningTransition != null)
     {
         ViewToHideWhenBeginningTransition.Alpha = 0.0f;
     }
     _transitionContext = transitionContext;
 }
        nfloat FadeDuration(IUIViewControllerContextTransitioning transitionContext)
        {
            if (ShouldPerformZoomingAnimation)
            {
                return((nfloat)TransitionDuration(transitionContext) * AnimationDurationFadeRatio);
            }

            return((nfloat)TransitionDuration(transitionContext));
        }
        public double TransitionDuration(IUIViewControllerContextTransitioning transitionContext)
        {
            if (ShouldPerformZoomingAnimation)
            {
                return(AnimationDurationWithZooming);
            }

            return(AnimationDurationWithoutZooming);
        }
        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, UIViewController toViewController,
		                                        UIView fromView, UIView toView)
		{
			if (Reverse) {
				ExecuteReverseAnimation (transitionContext, fromViewController, toViewController, fromView, toView);
			} else {
				ExecuteForwardAnimation (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);
        }
        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);
            });
        }
        public void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
        {
            SetUpTransitionContainerHierarchy(transitionContext);

            PerformFadeAnimation(transitionContext);

            if (ShouldPerformZoomingAnimation)
            {
                PerformZoomingAnimation(transitionContext);
            }
        }
 public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
 {
     if (IsPresent)
     {
         AnimateTransitionForPresent(transitionContext);
     }
     else
     {
         AnimateTransitionForDismiss(transitionContext);
     }
 }
Example #37
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 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 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, 
		                                        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);
			});
		}
Example #43
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);
                    });
                }
            }
		/// <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
			CGRect offScreenFrame = containerView.Frame;
			offScreenFrame.Y = containerView.Frame.Height;
			toView.Frame = offScreenFrame;

			containerView.InsertSubviewAbove (toView, fromView);

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

			Action 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 CGRect (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);
            });
        }
		public double TransitionDuration (IUIViewControllerContextTransitioning transitionContext)
		{
			return 1.0f;
		}
        protected void StartInteractiveTransition(IUIViewControllerContextTransitioning transitionCtx)
        {
            SlidingViewController sliding = this.SlidingViewController;
            UIViewController topController = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextTopViewControllerKey);
            // Disable user interaction of top controller's view
            topController.View.UserInteractionEnabled = false;
            if (_interactive)
            {
                UIViewController underController = sliding.GetViewControllerForKey(ECSlidingViewController.ECTransitionContextUnderLeftControllerKey);
                RectangleF underViewInitialFrame = sliding.GetInitialFrameForViewController(underController);
                RectangleF underViewFinalFrame   = sliding.GetFinalFrameForViewController(underController);

                // Update frame of under controller view
                underController.View.Frame = underViewInitialFrame.IsEmpty ? underViewFinalFrame : underViewInitialFrame;
                // Insert under view below top view
                sliding.ContainerView.InsertSubviewBelow(underController.View, topController.View);

                // Do some calculation
                float  finalLeftEdge   = sliding.GetFinalFrameForViewController(topController).GetMinX();
                float  initialLeftEdge = sliding.GetInitialFrameForViewController(topController).GetMinX();

                _fullWidth           = Math.Abs(finalLeftEdge - initialLeftEdge);
                _positiveLeftToRight = initialLeftEdge < finalLeftEdge;
            }
            else
            {
                this.AnimationController.AnimateTransition(transitionCtx);
            }
            // Enable user interaction of top controller's view
            topController.View.UserInteractionEnabled = 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;
            });
        }
		/// <summary>
		/// Transitions the duration of the transition.
		/// </summary>
		/// <returns>The duration.</returns>
		/// <param name="transitionContext">Transition context.</param>
		public override double TransitionDuration (IUIViewControllerContextTransitioning transitionContext) {
			return 0.35;
		}
        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 AnimDoneDelegate(IUIViewControllerContextTransitioning transitionContext){
				_transitionContext = transitionContext;
			}
            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);
                });
            }
Example #57
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");
		}
		public void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{

		}
 public virtual void AnimateTransition(IUIViewControllerContextTransitioning transitionContext,
     UIViewController fromViewController, UIViewController toViewController,
     UIView fromView, UIView toView)
 {
 }
            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);
                }
                );
            }