// - (void)showMenuAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion;

        public void ShowLeftMenuAnimated(bool animated, UICompletionHandler completion)
        {
            if (leftMenuViewController == null)
            {
                return;
            }

            isOpeningLeftMenu = true;

            var duration = animated ? ANIMATION_DURATION : 0;

            UIView     contentView      = contentViewController.View;
            RectangleF contentViewFrame = contentView.Frame;

            contentViewFrame.X = OffsetXWhenMenuIsOpen();

            LoadLeftMenuViewControllerViewIfNeeded();
            leftMenuViewController.BeginAppearanceTransition(true, true);

            UIView.AnimateNotify(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
                contentView.Frame = contentViewFrame;
            }, (finished) => {
                leftMenuViewController.EndAppearanceTransition();

                TapGesture.Enabled = true;
                PanGesture.Enabled = true;

                if (completion != null)
                {
                    completion(finished);
                }

                isOpeningLeftMenu = false;
            });
        }
Esempio n. 2
0
        public override void Perform()
        {
            // Tag the destination with a local tag variable
            this.tmpTag = this.DestinationViewController.View.Tag;
            //this.DestinationViewController.View.Frame = this.iOSGlobals.G__RectWindowLandscape;

            // Landscape only segue
            tmpWidth  = this.iOSGlobals.G__RectWindowLandscape.Size.Width;
            tmpHeight = this.iOSGlobals.G__RectWindowLandscape.Size.Height;

            //Check the bounds, if they arent landscape, we have a LARGE problem...quit.
            if (this.SourceViewController.View.Bounds.Width == tmpHeight)
            {
                throw new System.ArgumentOutOfRangeException(this.SourceViewController.View.ToString(), "Bounds must be landscape");
            }

            //Check the SOURCE VIEW Frame orientation
            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources
            if (this.SourceViewController.View.Frame.Width == tmpWidth)
            {
                leftFull = new CGPoint(((tmpWidth / 2) * -1), (tmpHeight / 2));
            }
            else
            {
                leftFull = new CGPoint((tmpHeight / 2), ((tmpWidth / 2) * -1));
            }

            this.SourceViewController.View.AddSubview(this.DestinationViewController.View);

            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources - technically it should always be landscape after the preceding method...?
            if (this.SourceViewController.View.ViewWithTag(this.tmpTag).Frame.Width == tmpWidth)
            {
                rightFull = new CGPoint((tmpWidth + (tmpWidth / 2)), (tmpHeight / 2));
            }
            else
            {
                rightFull = new CGPoint((tmpHeight / 2), (tmpWidth + (tmpWidth / 2)));
            }


            // Put the destination view fully over to the right, off screen
            // Make sure the destinationview bounds are correct landscape
            this.SourceViewController.View.ViewWithTag(this.tmpTag).Center = this.leftFull;

            // Setup Action Delegates
            _slider            = new Action(animateSlide);
            _animationcomplete = new UICompletionHandler(animateComplete);


            UIView.AnimateNotify(
                kAnimationDuration,
                0,
                UIViewAnimationOptions.TransitionNone,
                _slider,
                _animationcomplete
                );
        }
        void AnimateStopButton()
        {
            UICompletionHandler completion = new UICompletionHandler(delegate(bool finished) {
                if (!finished)
                {
                    Log.Debug("stop animation didn't finish!");
                }
                else
                {
                    Log.Debug("stop animation finished");
                }
            });

            Action action = () => {
                if (!_stopButtonVisible)
                {
                    btnStopBottomConstraint.Constant = bottomView.Bounds.Y + bottomView.Bounds.Height + btnStop.Bounds.Height / 3;
                    stopButtonTranslation            = btnStopBottomConstraint.Constant;
                }
                else
                {
                    btnStopBottomConstraint.Constant = 0 - btnStop.Frame.Height;
                    stopButtonTranslation            = btnStopBottomConstraint.Constant;
                }
                btnStop.NeedsUpdateConstraints();
                _stopButtonVisible = !_stopButtonVisible;
                btnStop.LayoutIfNeeded();
            };

            float springValue   = 1.0f;
            float animationTime = 1.0f;

            if (!_stopButtonVisible)
            {
                springValue   = 0.3f;
                animationTime = 1.8f;
            }
            else
            {
                springValue   = 1.0f;
                animationTime = 0.8f;
            }

            InvokeOnMainThread(() => {
                UIView.AnimateNotify(
                    animationTime,            // animation time
                    0.0f,                     // animation delay
                    springValue,              // spring dampening ration (lower == springyer)
                    0.1f,                     // initial spring velocity
                    UIViewAnimationOptions.CurveEaseIn,
                    action,
                    completion
                    );
            });
        }
Esempio n. 4
0
        private void AnimateMenu(int newHeight, UICompletionHandler completionBlock)
        {
            if (completionBlock == null)
            {
                completionBlock = (finished) => { };
            }

            var constraint = GetChangedConstraint();

            constraint.Constant = newHeight;

            // if using spring animation extend duration because spring animation is included
            //    in duration
            AnimateNotify(
                duration: AnimationDuration,
                delay: 0,
                springWithDampingRatio: UseSpringAnimation ? SpringWithDampingRatio : 1,               //0.5
                initialSpringVelocity: UseSpringAnimation ? InitialSpringVelocity : 1,                 //0.8
                options: UIViewAnimationOptions.CurveEaseInOut,
                animations: () => {
                // must call LayoutIfNeeded on Superview or change will not animate
                if (Superview != null)
                {
                    Superview.LayoutIfNeeded();
                }
            },
                completion: completionBlock);

            ViewExpanded = newHeight == ExpandedSize;

            if (ViewExpanded && MenuOpenHandler != null)
            {
                MenuOpenHandler();
            }
            else if (ViewExpanded == false && MenuClosedHandler != null)
            {
                MenuClosedHandler();
            }
        }
        private void Animation(float time, bool direction)
        {
            UICompletionHandler completion = new UICompletionHandler(delegate(bool finished) {
                if (!finished)
                {
                    Log.Debug("bottom view animation didn't finish!");
                }
                else
                {
                    Log.Debug("bottom view animation finished");
                }
            });

            Action action = () => {
                if (direction)
                {
                    alertViewTopConstraint.Constant = alertViewTopTranslation - bottomView.Frame.Height;
                }
                else
                {
                    alertViewTopConstraint.Constant = alertViewTopTranslation;
                }
                bottomView.NeedsUpdateConstraints();
                bottomView.LayoutIfNeeded();
            };

            InvokeOnMainThread(() => {
                UIView.AnimateNotify(
                    time,                     // animation time
                    0.0f,                     // animation delay
                    1.0f,                     // spring dampening ration (lower == springyer)
                    0.1f,                     // initial spring velocity
                    UIViewAnimationOptions.CurveLinear,
                    action,
                    completion
                    );
            });
        }
Esempio n. 6
0
        public static void MoveCluster(this MKMapView map, CKCluster cluster, CLLocationCoordinate2D from, CLLocationCoordinate2D to, UICompletionHandler completion)
        {
            cluster.SetCoordinate(from);

            if (GetClusterManager(map).Delegate != null)
            {
                GetClusterManager(map).Delegate.ClusterManager(GetClusterManager(map), () => { cluster.SetCoordinate(to); }, completion);
            }
            else
            {
                UIView.Animate(GetClusterManager(map).AnimationDuration,
                               0,
                               GetClusterManager(map).AnimationOptions,
                               () => { cluster.SetCoordinate(to); },
                               () => completion?.Invoke(true));
            }
        }
 public void SetViewControllers(UIViewController[] viewControllers, UIPageViewControllerNavigationDirection direction, bool animated, UICompletionHandler completion = null)
 {
     if (PageViewController != null)
     {
         PageViewController.SetViewControllers(viewControllers, direction, animated, completion);
     }
     Prepare();
 }
		// - (void)showContentViewControllerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion
		public void ShowContentViewControllerAnimated (bool animated, UICompletionHandler completion)
		{
			bool isLeftMenuOpen = IsLeftMenuOpen ();
			bool isRightMenuOpen = IsRightMenuOpen ();
			// Remove gestures
			TapGesture.Enabled = false;
			PanGesture.Enabled = _panEnabledWhenSlideMenuIsHidden;

			if (isLeftMenuOpen) {
				leftMenuViewController.View.UserInteractionEnabled = false;
			}

			if (isRightMenuOpen) {
				rightMenuViewController.View.UserInteractionEnabled = false;
			}

			var duration = animated ? ANIMATION_DURATION : 0;

			UIView contentView = contentViewController.View;
			RectangleF contentViewFrame = contentView.Frame;
			contentViewFrame.X = 0;

			if (isLeftMenuOpen) {
				leftMenuViewController.BeginAppearanceTransition (false, animated);
			}

			if (isRightMenuOpen) {
				rightMenuViewController.BeginAppearanceTransition (false, animated);
			}

			if (rightMenuViewController != null)
				this.View.SendSubviewToBack (rightMenuViewController.View);

			UIView.AnimateNotify(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
				contentView.Frame = contentViewFrame;
			}, (finished) => {

				if (isLeftMenuOpen) {
					leftMenuViewController.EndAppearanceTransition ();
					leftMenuViewController.View.UserInteractionEnabled = true;
				}

				if (isRightMenuOpen) {
					rightMenuViewController.EndAppearanceTransition();
					rightMenuViewController.View.UserInteractionEnabled = true;
				}

				if (leftMenuViewController != null && leftMenuViewController.View.Hidden) {
					leftMenuViewController.View.Hidden = false;
				}

				if (rightMenuViewController != null && rightMenuViewController.View.Hidden) {
					rightMenuViewController.View.Hidden = false;
				}

				if (completion != null) {
					completion (finished);
				}
			});
		}
        public override void Transition(UIViewController fromViewController, UIViewController toViewController, double duration, UIViewAnimationOptions options, Action animations, UICompletionHandler completionHandler)
        {
            base.Transition(fromViewController, toViewController, duration, options, animations, (finished) =>
            {
                var s = this;
                if (s == null)
                {
                    return;
                }

                s.View.SendSubviewToBack(s.ContentViewController.View);
                if (completionHandler != null)
                {
                    completionHandler(finished);
                }
            });
        }
        // - (void)showContentViewControllerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion
        public void ShowContentViewControllerAnimated(bool animated, UICompletionHandler completion)
        {
            bool isLeftMenuOpen  = IsLeftMenuOpen();
            bool isRightMenuOpen = IsRightMenuOpen();

            // Remove gestures
            TapGesture.Enabled = false;
            PanGesture.Enabled = _panEnabledWhenSlideMenuIsHidden;

            if (isLeftMenuOpen)
            {
                leftMenuViewController.View.UserInteractionEnabled = false;
            }

            if (isRightMenuOpen)
            {
                rightMenuViewController.View.UserInteractionEnabled = false;
            }

            var duration = animated ? ANIMATION_DURATION : 0;

            UIView     contentView      = contentViewController.View;
            RectangleF contentViewFrame = contentView.Frame;

            contentViewFrame.X = 0;

            if (isLeftMenuOpen)
            {
                leftMenuViewController.BeginAppearanceTransition(false, animated);
            }

            if (isRightMenuOpen)
            {
                rightMenuViewController.BeginAppearanceTransition(false, animated);
            }

            if (rightMenuViewController != null)
            {
                this.View.SendSubviewToBack(rightMenuViewController.View);
            }

            UIView.AnimateNotify(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
                contentView.Frame = contentViewFrame;
            }, (finished) => {
                if (isLeftMenuOpen)
                {
                    leftMenuViewController.EndAppearanceTransition();
                    leftMenuViewController.View.UserInteractionEnabled = true;
                }

                if (isRightMenuOpen)
                {
                    rightMenuViewController.EndAppearanceTransition();
                    rightMenuViewController.View.UserInteractionEnabled = true;
                }

                if (leftMenuViewController != null && leftMenuViewController.View.Hidden)
                {
                    leftMenuViewController.View.Hidden = false;
                }

                if (rightMenuViewController != null && rightMenuViewController.View.Hidden)
                {
                    rightMenuViewController.View.Hidden = false;
                }

                if (completion != null)
                {
                    completion(finished);
                }
            });
        }
Esempio n. 11
0
 public void SetViewControllers(UIViewController[] viewControllers, UIPageViewControllerNavigationDirection direction, bool animated, UICompletionHandler completionHandler)
 {
     pageViewController.SetViewControllers(viewControllers, direction, animated, completionHandler);
 }
		// - (void)showMenuAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
		public void ShowMenuAnimated (bool animated, UICompletionHandler completion)
		{
			var duration = animated ? ANIMATION_DURATION : 0;

			UIView contentView = contentViewController.View;
			RectangleF contentViewFrame = contentView.Frame;
			contentViewFrame.X = OffsetXWhenMenuIsOpen();

			LoadMenuViewControllerViewIfNeeded();
			menuViewController.BeginAppearanceTransition(true, true);

			UIView.AnimateNotify(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
				contentView.Frame = contentViewFrame;
			}, (finished) => {
				menuViewController.EndAppearanceTransition ();

				TapGesture.Enabled = true;
				PanGesture.Enabled = true;
				
				if (completion != null) {
					completion (finished);
				}
			});
		}
Esempio n. 13
0
 public override void SetViewControllers(
     UIViewController[] viewControllers,
     UIPageViewControllerNavigationDirection direction,
     bool animated,
     UICompletionHandler completionHandler)
 {
     DisposeChildViewControllers();
     base.SetViewControllers(viewControllers, direction, animated, completionHandler);
 }
Esempio n. 14
0
        public override void Perform()
        {
            // Tag the destination with a local tag variable
            this.tmpTag = this.DestinationViewController.View.Tag;

            // Landscape only segue
            tmpWidth  = this.iOSGlobals.G__RectWindowLandscape.Size.Width;
            tmpHeight = this.iOSGlobals.G__RectWindowLandscape.Size.Height;

            //Check the bounds, if they arent landscape, we have a LARGE problem...quit.
            if (this.SourceViewController.View.Bounds.Width == tmpHeight)
            {
                throw new System.ArgumentOutOfRangeException(this.SourceViewController.View.ToString(), "Bounds must be landscape");
            }

            //Check the SOURCE VIEW Frame orientation
            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources
            if (this.SourceViewController.View.Frame.Width == tmpWidth)
            {
                upFull = new CGPoint(((tmpHeight / 2) * -1), (tmpWidth / 2));
            }
            else
            {
                upFull = new CGPoint((tmpWidth / 2), ((tmpHeight / 2) * -1));
            }

            //TODO:  Create a tagging dictionary to tag all views? That would be cool.

            this.SourceViewController.View.AddSubview(this.DestinationViewController.View);

            //Check the DESTINATION VIEW Bounds orientation
            //These values can be randomised depending on the destinations position in relation to receiving messages from Window
            //ie Rotation messages. We will swap bounds and frame to Landscape. This is purely for animation purposes.
            if (this.SourceViewController.View.ViewWithTag(this.tmpTag).Bounds.Width == tmpHeight)
            {
                this.SourceViewController.View.ViewWithTag(this.tmpTag).Bounds = iOSGlobals.G__RectWindowLandscape;
                this.SourceViewController.View.ViewWithTag(this.tmpTag).Frame  = iOSGlobals.G__RectWindowLandscape;
            }
            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources - technically it should always be landscape after the preceding method...?
            if (this.SourceViewController.View.ViewWithTag(this.tmpTag).Frame.Width == tmpWidth)
            {
                downFull = new CGPoint((tmpHeight + (tmpHeight / 2)), (tmpWidth / 2));
            }
            else
            {
                downFull = new CGPoint((tmpWidth / 2), (tmpHeight + (tmpHeight / 2)));
            }

            // Put the destination view fully over to the right, off screen
            // Make sure the destinationview bounds are correct landscape
            this.SourceViewController.View.ViewWithTag(this.tmpTag).Center = this.upFull;

            #if DEBUG
            //this.SourceViewController.View.Center = this.upFull;
            #endif

            // Setup Action Delegates
            _slider            = new Action(animateSlide);
            _animationcomplete = new UICompletionHandler(animateComplete);


            UIView.AnimateNotify(
                kAnimationDuration,
                0,
                UIViewAnimationOptions.TransitionNone,
                _slider,
                _animationcomplete
                );
        }
Esempio n. 15
0
        public override void Perform()
        {
            // Tag the destination with a local tag variable
            this.tmpTag = this.DestinationViewController.View.Tag;
            //this.DestinationViewController.View.Frame = this.iOSGlobals.G__RectWindowLandscape;

            // Landscape only segue
            tmpWidth  = this.iOSGlobals.G__RectWindowLandscape.Size.Width;
            tmpHeight = this.iOSGlobals.G__RectWindowLandscape.Size.Height;

            //Check the bounds, if they arent landscape, we have a LARGE problem...quit.
            if (this.SourceViewController.View.Bounds.Width == tmpHeight)
            {
                throw new System.ArgumentOutOfRangeException(this.SourceViewController.View.ToString(), "AspyCore - Bounds must be landscape");
            }

            // Check the SOURCE VIEW Frame orientation
            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources
            if (this.SourceViewController.View.Frame.Width == tmpWidth)
            {
                rightFull = new CGPoint((tmpWidth + (tmpWidth / 2)), (tmpHeight / 2));
            }
            else
            {
                rightFull = new CGPoint((tmpHeight / 2), (tmpWidth + (tmpWidth / 2)));
            }

            //TODO:  Create a tagging dictionary to tag all views? That would be cool.

            this.SourceViewController.View.AddSubview(this.DestinationViewController.View);

            // If the frame is Portait (can happen due to rotation message delays?)
            // swap the Point sources - technically it should always be landscape after the preceding method...?
            if (this.SourceViewController.View.ViewWithTag(this.tmpTag).Frame.Width == tmpWidth)
            {
                leftFull = new CGPoint(((tmpWidth / 2) * -1), (tmpHeight / 2));
            }
            else
            {
                leftFull = new CGPoint((tmpHeight / 2), ((tmpWidth / 2) * -1));
            }

            // Put the destination view fully over to the right, off screen
            // Make sure the destinationview bounds are correct landscape
            this.SourceViewController.View.ViewWithTag(this.tmpTag).Center = this.rightFull;

            // Setup Action Delegates
            _slider            = new Action(animateSlide);
            _animationcomplete = new UICompletionHandler(this.animateComplete);
            //_animationcomplete (true);

            UIView.AnimateNotify(
                kAnimationDuration,
                0,
                UIViewAnimationOptions.TransitionNone,
                _slider,
                _animationcomplete
                );

            #region ObjCCode
            // **************************************************************************
            // This code is for view ccontroller containment only.
            // To work on just views we should use the animate feature
            //CGFloat width = self.view.frame.size.width;
            //CGFloat height = self.view.frame.size.height;

            //secondController.view.frame = CGRectMake(width, 0, width, height);

            //[self transitionFromViewController:firstController
            //toViewController:secondController
            //duration:0.4
            //options:UIViewAnimationOptionTransitionNone
            //animations:^(void) {
            //    firstController.view.frame = CGRectMake(0 - width, 0, width, height);
            //    secondController.view.frame = CGRectMake(0, 0, width, height);
            //}
            //completion:^(BOOL finished){}
            //];
            // **************************************************************************

            // **************************************************************************
            // Animate between views in the one controller.
            //[self.view addSubview:toViewController.view];
            //[UIView animateWithDuration:0.25
            //delay:0
            //options:UIViewAnimationOptionCurveEaseOut
            //animations:^{
            //fromViewController.view.alpha = 0;
            //toViewController.view.alpha = 1;
            //}
            //completion:^(BOOL finished){
            //[fromViewController.view removeFromSuperview];
            //[fromViewController removeFromParentViewController];
            //[toViewController didMoveToParentViewController:self];
            //}];
            // **************************************************************************

            // **************************************************************************
            // Perfom method override - add Coreanimation to libs

            //UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
            //UIViewController *destinationController = (UIViewController*)[self destinationViewController];

            //CATransition* transition = [CATransition animation];
            //transition.duration = .25;
            //transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            //transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
            //transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom



            //[sourceViewController.navigationController.view.layer addAnimation:transition
            //forKey:kCATransition];

            //[sourceViewController.navigationController pushViewController:destinationController animated:NO];
            // **************************************************************************

            #endregion
        }
		// #pragma mark - Navigation


		// - (void)setContentViewController:(UIViewController *)contentViewController animated:(BOOL)animated completion:(void(^)(BOOL finished))completion
		public void SetContentViewControllerAnimated (UIViewController controller, bool animated, UICompletionHandler completion)
		{
			if (controller == null)
				throw new InvalidOperationException ("Can't show a null content view controller");

			if (contentViewController != controller) 
			{
				// Preserve the frame
				RectangleF frame = contentViewController.View.Frame;

				// Remove old content view
				contentViewController.View.RemoveGestureRecognizer(TapGesture);
				contentViewController.View.RemoveGestureRecognizer(PanGesture);
				contentViewController.BeginAppearanceTransition(false, false);
				contentViewController.View.RemoveFromSuperview();
				contentViewController.EndAppearanceTransition();

				// Add the new content view
				SetContentViewController(controller);
				//contentViewController = controller;
				contentViewController.View.Frame = frame;
				contentViewController.View.AddGestureRecognizer(TapGesture);
				contentViewController.View.AddGestureRecognizer(PanGesture);
				SetShadowOnContentViewControllerView();
				contentViewController.BeginAppearanceTransition(true, false);
				View.AddSubview(contentViewController.View);
				contentViewController.EndAppearanceTransition();
			}

			// Perform the show animation
			ShowContentViewControllerAnimated(animated, completion);
		}
		// - (void)showContentViewControllerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion
		public void ShowContentViewControllerAnimated (bool animated, UICompletionHandler completion)
		{
			// Remove gestures
			TapGesture.Enabled = false;
			PanGesture.Enabled = panEnabledWhenSlideMenuIsHidden;

			menuViewController.View.UserInteractionEnabled = false;

			var duration = animated ? ANIMATION_DURATION : 0;

			UIView contentView = contentViewController.View;
			RectangleF contentViewFrame = contentView.Frame;
			contentViewFrame.X = 0;

			menuViewController.BeginAppearanceTransition(false, animated);

			UIView.AnimateNotify(duration, 0, UIViewAnimationOptions.CurveEaseInOut, () => {
				contentView.Frame = contentViewFrame;
			}, (finished) => {
				menuViewController.EndAppearanceTransition ();
				menuViewController.View.UserInteractionEnabled = true;

				if (completion != null) {
					completion (finished);
				}
			});
		}
Esempio n. 18
0
 public void AnimateClosed(UICompletionHandler completionHandler)
 {
     AnimateMenu(CollapsedSize, completionHandler);
 }
        protected override void HandlePanGesture()
        {
            switch (PanGestureRecognizer.State)
            {
            case UIGestureRecognizerState.Began:
            case UIGestureRecognizerState.Changed:
            {
                if (CurrentView == null)
                {
                    return;
                }
                PanTranslationInCollectionView = PanGestureRecognizer.TranslationInView(CollectionView);
                var pt         = CurrentView.Center = AddPoints(CurrentViewCenter, PanTranslationInCollectionView);
                var viewCenter = DragSurface.ConvertPointToView(pt, Target.CollectionView);

                // Logic on what to do when we go over the Target Collection View
                if (Target != null && Target.CollectionView.Frame.Contains(viewCenter))
                {
                    // clone the current item, because we will be placing it into the target
                    var result = DataSource.ItemAtIndexPath(SelectedItemIndexPath);

                    // get the path for where we are inserting the new item into the target
                    var path = Target.CollectionView.IndexPathForItemAtPoint(viewCenter);
                    if (path == null)
                    {
                        // there are a few cases to cover
                        // if the list is empty, we add it to the first index path
                        // if the list is not empty, we add it to the end of the list if we are dragging it over any position right of the right-most item
                        //    this is a relevant case for when we are just building up the collection
                        var count = (Target.DataSource as IUICollectionViewDataSource).GetItemsCount(Target.CollectionView, 0);

                        if (count == 0)
                        {
                            path = NSIndexPath.FromItemSection(0, 0);
                        }
                        else if (count > 0)
                        {
                            var cell = Target.CollectionView.CellForItem(NSIndexPath.FromItemSection(count - 1, 0));
                            if (viewCenter.X > cell.Frame.GetMaxX())
                            {
                                path = NSIndexPath.FromItemSection(count, 0);
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }

                    // once we know where we are putting it into the target, we simply add it and commit that change
                    // if the user needs to reorder, start long press on the target list
                    Target.DataSource.ItemWillAddToIndexPath(path, result);

                    NSAction updates = () =>
                    {
                        Target.CollectionView.InsertItems(new[] { path });
                    };
                    UICompletionHandler completion = (bool finished) =>
                    {
                        Target.DataSource.ItemDidAddToIndexPath(path, result);
                    };
                    PanGestureRecognizer.Enabled       = false;
                    PanGestureRecognizer.Enabled       = true;
                    LongPressGestureRecognizer.Enabled = false;
                    LongPressGestureRecognizer.Enabled = true;

                    Target.CollectionView.PerformBatchUpdates(updates, completion);
                }
            }
            break;

            case UIGestureRecognizerState.Cancelled:
            case UIGestureRecognizerState.Ended:
            {
            }
            break;

            default:
                break;
            }
        }
Esempio n. 20
0
 public void AnimateOpen(UICompletionHandler completionHandler)
 {
     AnimateMenu(ExpandedSize, completionHandler);
 }
Esempio n. 21
0
        public override void Transition(UIViewController fromViewController, UIViewController toViewController, double duration, UIViewAnimationOptions options, Action animations, UICompletionHandler completionHandler)
        {
            TotalCalculationController totalTrans = this.Storyboard.InstantiateViewController("TotalCalculationController") as TotalCalculationController;

            if (fromViewController == totalTrans)
            {
                alertInstructions("Vault Updated!", "Your vault has been updated with your income and expenses. You can view your vault at any time and you can now start another manual entry of your financials.");
            }
        }
        // #pragma mark - Navigation


        // - (void)setContentViewController:(UIViewController *)contentViewController animated:(BOOL)animated completion:(void(^)(BOOL finished))completion
        public void SetContentViewControllerAnimated(UIViewController controller, bool animated, UICompletionHandler completion)
        {
            if (controller == null)
            {
                throw new InvalidOperationException("Can't show a null content view controller");
            }

            if (contentViewController != controller)
            {
                // Preserve the frame
                RectangleF frame = contentViewController.View.Frame;

                // Remove old content view
                contentViewController.View.RemoveGestureRecognizer(TapGesture);
                contentViewController.View.RemoveGestureRecognizer(PanGesture);
                contentViewController.BeginAppearanceTransition(false, false);
                contentViewController.View.RemoveFromSuperview();
                contentViewController.EndAppearanceTransition();

                // Add the new content view
                SetContentViewController(controller);
                //contentViewController = controller;
                contentViewController.View.Frame = frame;
                contentViewController.View.AddGestureRecognizer(TapGesture);
                contentViewController.View.AddGestureRecognizer(PanGesture);
                SetShadowOnContentViewControllerView();
                contentViewController.BeginAppearanceTransition(true, false);
                View.AddSubview(contentViewController.View);
                contentViewController.EndAppearanceTransition();
            }

            // Perform the show animation
            ShowContentViewControllerAnimated(animated, completion);
        }