public static TutorialPage CreatePage(PageInfo page){

			var tutorialPage = new TutorialPage { PageInfo = page };

			return tutorialPage;
		}
Exemple #2
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            _finalize = new UIButton(UIButtonType.RoundedRect);
            _finalize.BackgroundColor = _closeButtonBackgroundColor;
            _finalize.SetTitleColor(_closeButtonTitleColor, UIControlState.Normal);
            _finalize.Alpha = 0f;
            _finalize.UserInteractionEnabled = false;
            _finalize.SetTitle(_closeButtonTitle, UIControlState.Normal);
            _finalize.TranslatesAutoresizingMaskIntoConstraints = false;
            _finalize.Layer.CornerRadius = 6f;
            _finalize.TouchUpInside     += _finalize_TouchUpInside;
            this.Add(_finalize);
            this.View.SendSubviewToBack(_finalize);

            View.AddConstraint(
                NSLayoutConstraint.Create(
                    _finalize, NSLayoutAttribute.Leading,
                    NSLayoutRelation.Equal,
                    View, NSLayoutAttribute.Leading,
                    1.0f, HorizontalButtonPadding
                    )
                );

            View.AddConstraint(
                NSLayoutConstraint.Create(
                    _finalize, NSLayoutAttribute.Trailing,
                    NSLayoutRelation.Equal,
                    View, NSLayoutAttribute.Trailing,
                    1.0f, -HorizontalButtonPadding
                    )
                );

            View.AddConstraint(
                NSLayoutConstraint.Create(
                    _finalize, NSLayoutAttribute.Bottom,
                    NSLayoutRelation.Equal,
                    View, NSLayoutAttribute.Bottom,
                    1.0f, -VerticalButtonPadding
                    )
                );

            this.GetPreviousViewController = (pvc, vc) => {
                var tutorialPage = vc as TutorialPage;

                var currentIndex = _pageInfos.IndexOf(tutorialPage?.PageInfo);
                return(currentIndex == 0 ? null : TutorialPage.CreatePage(_pageInfos[currentIndex - 1]));
            };

            this.GetNextViewController = (nvc, vc) => {
                var tutorialPage = vc as TutorialPage;

                var currentIndex = _pageInfos.IndexOf(tutorialPage?.PageInfo);
                var isFinalPage  = currentIndex + 1 == _pageInfos.Count;

                BeginInvokeOnMainThread(() => {
                    if (isFinalPage)
                    {
                        UIView.Animate(.1d, 0d, UIViewAnimationOptions.CurveEaseIn,
                                       () => {
                            View.BringSubviewToFront(_finalize);
                            _finalize.Alpha = 1f;
                            _finalize.UserInteractionEnabled = true;
                        },
                                       () => {});
                    }
//					else {
//						_finalize.Alpha = 0f;
//						_finalize.UserInteractionEnabled = false;
//						View.SendSubviewToBack (_finalize);
//					}
                });

                return(isFinalPage ? null : TutorialPage.CreatePage(_pageInfos[currentIndex + 1]));
            };

            this.GetPresentationCount = (pvc) => _pageInfos.Count;

            this.GetPresentationIndex = (pvc) => 0;

            await SetViewControllersAsync(
                new [] { TutorialPage.CreatePage(_pageInfos[0]) },
                UIPageViewControllerNavigationDirection.Forward,
                false);
        }