Beispiel #1
0
        public void OpenRightWithVelocity(nfloat velocity)
        {
            nfloat xOrigin      = RightContainerView.Frame.X;
            nfloat finalXOrigin = View.Bounds.Width - RightContainerView.Frame.Size.Width;

            CGRect frame = RightContainerView.Frame;

            frame.X = finalXOrigin;

            nfloat duration = SlideMenuOptions.AnimationDuration;

            if (velocity != 0)
            {
                duration = (nfloat)Math.Abs(xOrigin - View.Bounds.Width) / velocity;
                duration = (nfloat)Math.Max(0.1f, Math.Min(1.0f, duration));
            }

            AddShadowToView(RightContainerView);

            UIView.Animate(duration, 0.0f, 0,
                           () =>
            {
                RightContainerView.Frame  = frame;
                OpacityView.Layer.Opacity = (float)SlideMenuOptions.ContentViewOpacity;

                if (SlideMenuOptions.AnimationType == SlideAnimation.ContentViewDrag)
                {
                    MainContainerView.Transform = CGAffineTransform.MakeTranslation(-SlideMenuOptions.RightViewWidth, 0);
                }
                else if (SlideMenuOptions.AnimationType == SlideAnimation.MakeScale)
                {
                    MainContainerView.Transform = CGAffineTransform.MakeScale(SlideMenuOptions.ContentViewScale, SlideMenuOptions.ContentViewScale);
                }
            },
                           () =>
            {
                DisableContentInteraction();
                if (RightViewController != null)
                {
                    RightViewController.EndAppearanceTransition();
                }
                if (RightDidOpen != null)
                {
                    RightDidOpen();
                }
            });
        }
 public void AppearanceTransition()
 {
     // this was retroactively documented as available in 5.0 (officially added in 6.0)
     // but respondToSelector return false
     using (var vc = new UIViewController()) {
         vc.BeginAppearanceTransition(true, true);
         vc.EndAppearanceTransition();
     }
 }
        // - (void)viewDidAppear:(BOOL)animated
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            if (contentViewController != null)
            {
                contentViewController.EndAppearanceTransition();
            }

            if (leftMenuViewController != null && leftMenuViewController.IsViewLoaded && leftMenuViewController.View.Superview != null)
            {
                leftMenuViewController.EndAppearanceTransition();
            }

            if (rightMenuViewController != null && rightMenuViewController.IsViewLoaded && rightMenuViewController.View.Superview != null)
            {
                rightMenuViewController.EndAppearanceTransition();
            }
        }
        private void CompleteBlock(UIViewController visibleMenuViewController)
        {
            if (visibleMenuViewController != null)
            {
                visibleMenuViewController.EndAppearanceTransition();
                if (!_visible)
                {
                    DidHideMenuViewController?.Invoke(this, visibleMenuViewController);
                }
            }

            LeftMenuVisible = RightMenuVisible = _visible = false;
            _menuState      = MenuState.None;
        }
Beispiel #5
0
        public void UpdateContent()
        {
            if (lastSize.Width != ContainerView.Bounds.Size.Width)
            {
                lastSize = ContainerView.Bounds.Size;
                ContainerView.ContentOffset = new CGPoint(PageOffsetForChildIndex(CurrentIndex), 0);
            }

            lastSize = ContainerView.Bounds.Size;

            var pagerViewControllers = pagerTabStripChildViewControllersForScrolling ?? ViewControllers;

            ContainerView.ContentSize = new CGSize(ContainerView.Bounds.Width * new nfloat(pagerViewControllers.Count()), ContainerView.ContentSize.Height);

            int pagerViewControllersCount = pagerViewControllers.Count();

            for (int index = 0; index < pagerViewControllersCount; index++)
            {
                UIViewController childController = pagerViewControllers[index];
                var pageOffsetForChild           = PageOffsetForChildIndex((uint)index);

                if (Math.Abs(ContainerView.ContentOffset.X - pageOffsetForChild) < ContainerView.Bounds.Width)
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.View.Frame            = new CGRect(OffsetForChildIndex((uint)index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                    }
                    else
                    {
                        childController.BeginAppearanceTransition(true, animated: false);
                        AddChildViewController(childController);
                        childController.View.Frame            = new CGRect(OffsetForChildIndex((uint)index), 0, View.Bounds.Width, ContainerView.Bounds.Height);
                        childController.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                        ContainerView.AddSubview(childController.View);
                        childController.DidMoveToParentViewController(this);
                        childController.EndAppearanceTransition();
                    }
                }
                else
                {
                    if (childController.ParentViewController != null)
                    {
                        childController.BeginAppearanceTransition(false, animated: false);
                        childController.WillMoveToParentViewController(null);
                        childController.View.RemoveFromSuperview();
                        childController.RemoveFromParentViewController();
                        childController.EndAppearanceTransition();
                    }
                }
            }

            var oldCurrentIndex = CurrentIndex;
            var virtualPage     = VirtualPageForContentOffset(ContainerView.ContentOffset.X);
            var newCurrentIndex = PageForVirtualPage(virtualPage);

            CurrentIndex = (uint)newCurrentIndex;
            var changeCurrentIndex = newCurrentIndex != oldCurrentIndex;

            IPagerTabStripIsProgressiveDelegate progressiveDelegate = this as IPagerTabStripIsProgressiveDelegate;

            if (progressiveDelegate != null && PagerBehaviour.IsProgressiveIndicator)
            {
                Tuple <int, int, nfloat> data = ProgressiveIndicatorData((uint)virtualPage);
                progressiveDelegate.PagerTabStripViewController(this, data.Item1, data.Item2, data.Item3, changeCurrentIndex);
            }
            else
            {
                Delegate?.PagerTabStripViewController(this, Math.Min((int)oldCurrentIndex, pagerViewControllers.Count() - 1), (int)newCurrentIndex);
            }
        }
        private void ShowRightMenuViewController()
        {
            if (RightMenuViewController == null)
            {
                return;
            }
            RightMenuViewController.BeginAppearanceTransition(true, true);
            RightMenuViewController.View.Hidden = false;
            if (LeftMenuViewController != null)
            {
                LeftMenuViewController.View.Hidden = true;
            }
            View.Window.EndEditing(true);
            AddContentButton();

            UpdateContentViewShadow();
            ResetContentViewScale();


            UIApplication.SharedApplication.BeginIgnoringInteractionEvents();
            UIView.Animate(AnimationDuration, () =>
            {
                if (ScaleContentView)
                {
                    _contentViewContainer.Transform = CGAffineTransform.MakeScale(ContentViewScaleValue, ContentViewScaleValue);
                }
                else
                {
                    _contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
                }

                var currentOrientation = UIApplication.SharedApplication.StatusBarOrientation;
                bool isPortrait        = currentOrientation == UIInterfaceOrientation.Portrait ||
                                         currentOrientation == UIInterfaceOrientation.PortraitUpsideDown;

                var centerPointX             = isPortrait ? -ContentViewInPortraitOffsetCenterX : -ContentViewInLandscapeOffsetCenterX;
                var centerPointY             = _contentViewContainer.Center.Y;
                _contentViewContainer.Center = new CGPoint(centerPointX, centerPointY);


                _menuViewContainer.Alpha     = !FadeMenuView ? 0 : 1.0f;
                _contentViewContainer.Alpha  = ContentViewFadeOutAlpha;
                _menuViewContainer.Transform = CGAffineTransform.MakeIdentity();
                if (ScaleBackgroundImageView)
                {
                    _backgroundImageView.Transform = CGAffineTransform.MakeIdentity();
                }
            },
                           () =>
            {
                RightMenuViewController.EndAppearanceTransition();
                if (!_visible)
                {
                    DidShowMenuViewController?.Invoke(this, RightMenuViewController);
                }
                _visible         = !(_contentViewContainer.Frame.Width == View.Bounds.Width && _contentViewContainer.Frame.Height == View.Bounds.Height && _contentViewContainer.Frame.X == 0 && _contentViewContainer.Frame.Y == 0);
                RightMenuVisible = _visible;
                _menuState       = MenuState.RightOpened;
                UIApplication.SharedApplication.EndIgnoringInteractionEvents();
                AddContentViewControllerMotionEffects();
            });
            StatusBarNeedsAppearanceUpdate();
        }