示例#1
0
        public async Task PushModalAsync(Page modal, bool animated)
        {
            CurrentPageController?.SendDisappearing();
            UpdateAccessibilityImportance(CurrentPage, ImportantForAccessibility.NoHideDescendants, false);

            _navModel.PushModal(modal);

            Task presentModal = PresentModal(modal, animated);

            await presentModal;

            UpdateAccessibilityImportance(modal, ImportantForAccessibility.Auto, true);

            // Verify that the modal is still on the stack
            if (_navModel.CurrentPage == modal)
            {
                ((IPageController)modal).SendAppearing();
            }
        }
示例#2
0
        public Task <Page> PopModalAsync(bool animated)
        {
            Page modal = _navModel.PopModal();

            ((IPageController)modal).SendDisappearing();
            var source = new TaskCompletionSource <Page>();

            var modalRenderer = modal.Handler as INativeViewHandler;

            if (modalRenderer != null)
            {
                ModalContainer?modalContainer = modalRenderer.NativeView?.Parent as ModalContainer ??
                                                throw new InvalidOperationException("Parent is not Modal Container");

                if (animated)
                {
                    modalContainer
                    .Animate()?.TranslationY(_renderer.Height)?
                    .SetInterpolator(new AccelerateInterpolator(1))?.SetDuration(300)?.SetListener(new GenericAnimatorListener
                    {
                        OnEnd = a =>
                        {
                            modalContainer.RemoveFromParent();
                            modalContainer.Dispose();
                            source.TrySetResult(modal);
                            CurrentPageController?.SendAppearing();
                            modalContainer = null;
                        }
                    });
                }
                else
                {
                    modalContainer.RemoveFromParent();
                    modalContainer.Dispose();
                    source.TrySetResult(modal);
                    CurrentPageController?.SendAppearing();
                }
            }

            UpdateAccessibilityImportance(CurrentPage, ImportantForAccessibility.Auto, true);

            return(source.Task);
        }
示例#3
0
        async Task INavigation.PushModalAsync(Page modal, bool animated)
        {
            CurrentPageController?.SendDisappearing();

            _navModel.PushModal(modal);

            modal.Platform = this;

            await PresentModal(modal, animated);

            // Verify that the modal is still on the stack
            if (_navModel.CurrentPage == modal)
            {
                ((IPageController)modal).SendAppearing();
            }

            _toolbarTracker.Target = _navModel.Roots.Last();

            UpdateActionBar();
        }
示例#4
0
        Task <Page> INavigation.PopModalAsync(bool animated)
        {
            Page modal = _navModel.PopModal();

            ((IPageController)modal).SendDisappearing();
            var source = new TaskCompletionSource <Page>();

            IVisualElementRenderer modalRenderer = GetRenderer(modal);

            if (modalRenderer != null)
            {
                if (animated)
                {
                    modalRenderer.ViewGroup.Animate().Alpha(0).ScaleX(0.8f).ScaleY(0.8f).SetDuration(250).SetListener(new GenericAnimatorListener
                    {
                        OnEnd = a =>
                        {
                            modalRenderer.ViewGroup.RemoveFromParent();
                            modalRenderer.Dispose();
                            source.TrySetResult(modal);
                            CurrentPageController?.SendAppearing();
                        }
                    });
                }
                else
                {
                    modalRenderer.ViewGroup.RemoveFromParent();
                    modalRenderer.Dispose();
                    source.TrySetResult(modal);
                    CurrentPageController?.SendAppearing();
                }
            }

            _toolbarTracker.Target = _navModel.Roots.Last();
            UpdateActionBar();

            return(source.Task);
        }