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(); } }
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); }
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(); }
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); }